Difference between revisions of "NodeSpace.h"

From Organic Design wiki
m (add nodal-constants)
(change variant to void*)
Line 25: Line 25:
 
//  we could get state to return a struct with STRING, INT, CODE
 
//  we could get state to return a struct with STRING, INT, CODE
 
//  the caller knows which field is populated
 
//  the caller knows which field is populated
variant nodeGetState(int subject) {
+
void* nodeGetState(int subject) {
variant state;
+
void* state;
 
return state;
 
return state;
 
}
 
}
  
void nodeSetState(int subject, variant state) {
+
void nodeSetState(int subject, void* state) {
 
}
 
}
  
Line 51: Line 51:
 
nodeSetValue(subject, CURRENT, nodeGetValue(node, AND));
 
nodeSetValue(subject, CURRENT, nodeGetValue(node, AND));
 
if (nodeGetValue(node, CODE)) {
 
if (nodeGetValue(node, CODE)) {
void (*code)() = nodeGetState(node).code;
+
void (*code)() = nodeGetState(node);
 
code();
 
code();
 
// Later this must declare and build if no function-reference
 
// Later this must declare and build if no function-reference

Revision as of 05:35, 4 July 2006

  1. define CURRENT 2
  2. define AND 3
  3. define THEN 4
  4. define CODE 5

int nodeTraverse(int subject, int path) { // select node wco selNode return subject; }

// set nodal value of node/path // - path is array-of-node int nodeGetValue(int subject, int path) { int value; return value; }

void nodeSetValue(int subject, int path, int value) { }

// PROBLEM: // - currently this code assumes all states are text, // but we need to be able to return function references too. // - not sure how to handle this in C++ properly, // we could get state to return a struct with STRING, INT, CODE // the caller knows which field is populated void* nodeGetState(int subject) { void* state; return state; }

void nodeSetState(int subject, void* state) { }

int nodeInsertKey(int subject, int key) { int instance; return instance; }

void nodeRemoveKey(int subject, int key) { }

// - Consumes quanta of execution // - Creates History from change events // - Builds, declares and executes functionality // - Should reduction handle cyles (current-cycle etc), or a separate root-thread void nodeReduce(int subject) { // return if no CURRENT node (either nonexistent, or ref to node 0) int node; if ((node = nodeGetValue(subject, CURRENT)) == 0) return; nodeSetValue(subject, CURRENT, nodeGetValue(node, AND)); if (nodeGetValue(node, CODE)) { void (*code)() = nodeGetState(node); code(); // Later this must declare and build if no function-reference // replace self in loop with node.THEN if non-zero } else nodeReduce(node); }