Skip to content

Instantly share code, notes, and snippets.

@underdoeg
Created August 4, 2011 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save underdoeg/1125795 to your computer and use it in GitHub Desktop.
Save underdoeg/1125795 to your computer and use it in GitHub Desktop.
planing for dataS
///////////////// PIN
class BasePin //Ein base pin einfach damit wir einen pin so ohne spezifischen typen speichern können
{
public:
std::string name;
protected:
std::vector<int> connectableIds;
};
template <class type> //einen pin mit einem generischen type für operationen und funktionen am datentyp die immer gleich sind, zB type getData();
class Pin: public BasePin
{
public:
const char* getType(){
return typeid(type).name();
}
type data;
};
////////////////// NODE
class BaseNode //Der BaseNode hat einfach irgendwelche pins, ohne zu wissen welche
{
public:
void addIn(BasePin* p) {
in.push_back(p);
}
void addOut(BasePin* p) {
out.push_back(p);
}
std::vector<BasePin*> in;
std::vector<BasePin*> out;
};
class VecNode: public BaseNode
{
public:
VecNode(){
addIn(&x);
addIn(&y);
addIn(&z);
}
ofVec3f getVector(){
return ofVec3f(x.data, y.data, z.data);
}
private:
Pin<float> x;
Pin<float> y;
Pin<float> z;
};
//--------------------------------------------------------------
void nodesAndPinsApp::setup()
{
ofSetWindowTitle("nodesAndPinsApp");
ofBackground(0,0,0);
ofSetFrameRate(60);
VecNode();
Pin<int> intPin;
cout << "INT HAS TYPE " << intPin.getType() << endl;
cout << "FLOAT HAS TYPE " << Pin<float>().getType() << endl;
cout << "ofMesh HAS TYPE " << Pin<ofMesh*>().getType() << endl;
cout << "ofImage HAS TYPE " << Pin<ofImage*>().getType() << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment