00001
00002
00003 #ifndef _NETWORK_H_
00004 #define _NETWORK_H_
00005
00006 #include "Node.h"
00007 #include <map>
00008 #include <string>
00009 #include "NodeFactory.h"
00010
00011 #include "Exception.h"
00012
00013 namespace FD {
00014
00025
00026
00027
00028 class Network : public Node {
00029
00030 public:
00031
00032
00034 Network (std::string nodeName, ParameterSet params);
00035
00037 ~Network ();
00038
00043 Node* getNodeNamed (const std::string &name);
00044
00047 void addNode (const std::string &factoryName,const std::string &nodeName, const ParameterSet ¶meters);
00048
00050 void addNode (Node &node);
00051
00053 virtual void connect (const std::string ¤tNodeName,const std::string &inputName,
00054 const std::string &inputNodeName, const std::string &outputName);
00055
00057 Node* removeNode (const std::string &nodeName);
00058
00060 std::string getName() {return name;}
00061
00063 void setName(const std::string &my_name) {name = my_name;}
00064
00066 Node* getSinkNode () {return sinkNode;}
00067
00069 virtual void setSinkNode (Node* node) {sinkNode = node;}
00070
00072 Node* getInputNode () {return inputNode;}
00073
00075 virtual void setInputNode (Node* node) {inputNode = node;}
00076
00078 virtual std::vector<NodeInput>& getInputs () {
00079 if (!inputNode) throw new NodeException(this,std::string("No inputNode in :") + getName(),__FILE__,__LINE__);
00080 return inputNode->getInputs();
00081 }
00082
00084 virtual void reset();
00085
00087 virtual void stop();
00088
00090 virtual void cleanupNotify();
00091
00093 virtual void request(int outputID, const ParameterSet &req) {sinkNode->request(outputID,req);}
00094
00096 virtual void initialize();
00097
00099 virtual ObjectRef getOutput (int output_id, int count);
00100
00102 virtual bool hasOutput (int output_id) const;
00103
00105 virtual void connectToNode(std::string in, Node *inNode, std::string out);
00106
00108 virtual void verifyConnect();
00109
00110 protected:
00111
00112
00114 virtual int translateInput (std::string inputName);
00115
00117 virtual int translateOutput (std::string outputName);
00118
00120 virtual void connectToNode(unsigned int in, Node *inNode, unsigned int out);
00121
00123 int numNodes;
00124
00126 std::map<std::string,Node*> nodeDictionary;
00128 Node *sinkNode;
00130 Node *inputNode;
00131
00132
00133
00135 Network () {
00136 throw new NodeException (NULL,"The default constructor should not be called from Network",__FILE__,__LINE__);
00137 }
00138
00139 };
00140
00141 }
00142 #endif