00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00043
00044
00045 #ifndef _NODE_H
00046 #define _NODE_H
00047
00048 #include "../dllinclude.h"
00049
00059 #include <string>
00060 #include <vector>
00061
00062 namespace ot {
00063
00064 class Context;
00065 class ConfigurationParser;
00066 class Node;
00067 class NodePort;
00068
00069 #ifdef USE_LIVE
00070 class LiveContext;
00071 #endif
00072
00073 }
00074
00075 #include "StringTable.h"
00076 #include <OpenTracker/core/IRefCounted.h>
00077 #include <OpenTracker/misc/Cptr.h>
00078
00079 #include "Event.h"
00080 #ifdef USE_LIVE
00081 #include <OpenTracker/skeletons/OTGraph.hh>
00082 #endif
00083
00084 namespace ot {
00085
00086
00087
00096 #ifdef USE_LIVE
00097 class OPENTRACKER_API Node : public POA_OTGraph::Node,
00098 public PortableServer::RefCountServantBase
00099 #else
00100 class OPENTRACKER_API Node
00101 #endif
00102 {
00103
00104
00105 public:
00106 #ifdef USE_LIVE
00107 typedef Node* Ptr;
00108 #else
00109 OT_DECLARE_IREFCOUNTED;
00110 typedef Cptr<Node> Ptr;
00111 #endif
00112
00117 typedef std::vector<Ptr> NodeVector;
00118
00119 protected:
00123 NodeVector parents;
00124 NodeVector children;
00125
00126 StringTable attributes;
00127
00131
00132 std::string name;
00133
00134
00136 std::string type;
00137
00138 public:
00140 enum error { OK=0,
00141 GRAPH_CONSTRAINT,
00142 READONLY,
00143 CONTEXT_ERROR,
00144 NOT_FOUND
00145 };
00146
00147 protected:
00148
00149
00150 public:
00151
00160 Node();
00161
00169
00170
00174 const std::string get( const std::string & key ) const;
00184 int get(const std::string & key, int * value, int len = 1 ) ;
00194 int get(const std::string & key, float * value, int len = 1 ) ;
00204 int get(const std::string & key, double * value, int len = 1 ) ;
00205
00210 void put( const std::string &key, const std::string &value );
00214 void remove( const std::string &key );
00215
00222 void put(const std::string & key, const int value);
00229 void put(const std::string & key, const float value);
00236 void put(const std::string & key, const double value);
00237
00246 void put(const std::string & key, const int * value, int len);
00255 void put(const std::string & key, const float * value, int len);
00264 void put(const std::string & key, const double * value, int len);
00266
00267 public:
00268
00272 virtual ~Node();
00273
00280 const std::string & getType() const
00281 {
00282 return type;
00283 }
00284
00290 const std::string & getName() const
00291 {
00292 return name;
00293 }
00294
00295 void setName(const std::string & name_){
00296 name = name_;
00297 }
00298
00303 Context * getContext() const;
00304
00309
00310
00319 Node * getParent();
00320
00326 Node * getParent( unsigned int index);
00327
00332 unsigned int countParents();
00337 unsigned int countChildren();
00338
00339
00340
00347 Node * getChild( unsigned int index );
00348
00355 error addChild(Node & child);
00356
00364 error removeChild(Node & child);
00365
00366
00372 unsigned int countPorts();
00373 #ifdef USE_LIVE
00374 char* get_type();
00375 char* get_name();
00376 char* get_id();
00377 char* get_attribute(const char* _key);
00378 OTGraph::StringTable* get_attributes();
00379 #endif
00380
00381
00389 NodePort * getPort( const std::string & name, unsigned int index = 0 );
00390
00397 NodePort * getPort( unsigned int index );
00398
00405 error addPort( const std::string & name );
00406
00414 error removePort( const std::string & name );
00415
00416 error removePort( NodePort & port);
00417
00418 error removePort( unsigned int index );
00419
00421
00429
00437 virtual int isEventGenerator()
00438 {
00439 return 0;
00440 }
00441
00450 virtual void onEventGenerated( Event& event, Node& generator)
00451 {
00452 }
00453
00460 void updateObservers( Event &data );
00461
00463
00472
00479 virtual int isEventQueue()
00480 {
00481 return 0;
00482 }
00489 virtual Event& getEvent(unsigned int index = 0)
00490 {
00491 return Event::null;
00492 }
00497 virtual Event& getEventNearTime(double time)
00498 {
00499 return Event::null;
00500 }
00504 virtual unsigned int getSize()
00505 {
00506 return 0;
00507 }
00508
00510
00517
00524 virtual int isTimeDependend()
00525 {
00526 return 0;
00527 }
00528
00534 virtual Event& getEventAtTime(double time)
00535 {
00536 return Event::null;
00537 }
00538
00540
00548 virtual int isNodePort()
00549 {
00550 return 0;
00551 }
00552
00553
00554
00559 Node * findNode(const std::string & key, const std::string & val);
00560
00561
00562
00563 void addParent( Node * parent);
00564
00569 unsigned int countAllChildren();
00570
00575 Node * getAnyChild( unsigned int index);
00576
00577 StringTable & getAttributes();
00578
00579
00580
00581 friend class Context;
00582
00583 #ifdef USE_LIVE
00584 friend class LiveContext;
00585 #endif
00586 };
00587
00588 }
00589
00590 #endif
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606