00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TORC_PACKER_ELEMENT_HPP
00017 #define TORC_PACKER_ELEMENT_HPP
00018
00019 #include <string>
00020 #include <map>
00021 #include <algorithm>
00022 #include <iostream>
00023 #include <sstream>
00024 #include <iterator>
00025 #include <functional>
00026 #include <boost/smart_ptr.hpp>
00027
00028 #include "torc/packer/Component.hpp"
00029 #include "torc/packer/Connection.hpp"
00030
00031 namespace torc {
00032 namespace physical {
00033
00034 using namespace std;
00035
00036 typedef vector<string> ConfigVector;
00037
00038
00039
00040
00041 class Element : public Component{
00042
00043
00044 friend class RcFactory;
00045 protected:
00046
00047 ConnectionSharedPtrVector mConnections;
00048 ConfigVector mConfigs;
00049
00050
00051 Element(const string& inName) : Component(inName){}
00052 public:
00053
00054 typedef ConnectionSharedPtrVector::const_iterator ConnectionSharedPtrConstIterator;
00055 typedef ConnectionSharedPtrVector::iterator ConnectionSharedPtrIterator;
00056
00057 typedef ConfigVector::const_iterator ConfigConstIterator;
00058 typedef ConfigVector::iterator ConfigIterator;
00059
00060
00061 bool addConnection(ConnectionSharedPtr& inConnectionPtr) {
00062
00063 mConnections.push_back(inConnectionPtr);
00064 return true;
00065
00066 }
00067 bool removeConnection(ConnectionSharedPtr& inConnectionPtr) {
00068
00069 ConnectionSharedPtrIterator e = connectionsEnd();
00070 ConnectionSharedPtrIterator result = std::find(connectionsBegin(), e, inConnectionPtr);
00071 if(result == e) return false;
00072 mConnections.erase(result);
00073
00074 return true;
00075 }
00076
00077 bool removeConnection(ConnectionSharedPtrIterator inConnectionIter) {
00078
00079
00080 mConnections.erase(inConnectionIter);
00081
00082 return true;
00083 }
00084
00085
00086 ConnectionSharedPtrConstIterator connectionsBegin(void) const { return mConnections.begin(); }
00087 ConnectionSharedPtrConstIterator connectionsEnd(void) const { return mConnections.end(); }
00088 ConnectionSharedPtrIterator connectionsBegin(void) { return mConnections.begin(); }
00089 ConnectionSharedPtrIterator connectionsEnd(void) { return mConnections.end(); }
00090 size_t getConnectionCount(void) const { return mConnections.size(); }
00091
00092 bool addConfig(string& inConfigPtr) {
00093
00094 ConfigIterator e = mConfigs.end();
00095 ConfigIterator result = std::find(mConfigs.begin(), e, inConfigPtr);
00096 if(result != e) return false;
00097 mConfigs.push_back(inConfigPtr);
00098 return true;
00099
00100 }
00101 bool removeConfig(string& inConfigPtr) {
00102
00103 ConfigIterator e = mConfigs.end();
00104 ConfigIterator result = std::find(mConfigs.begin(), e, inConfigPtr);
00105 if(result == e) return false;
00106 mConfigs.erase(result);
00107
00108 return true;
00109 }
00110
00111 ConfigConstIterator confsBegin(void) const { return mConfigs.begin(); }
00112 ConfigConstIterator confsEnd(void) const { return mConfigs.end(); }
00113 ConfigIterator confsBegin(void) { return mConfigs.begin(); }
00114 ConfigIterator confsEnd(void) { return mConfigs.end(); }
00115 size_t getConfigCount(void) const { return mConfigs.size(); }
00116 };
00117
00118
00119 typedef boost::shared_ptr<Element> ElementSharedPtr;
00120
00121
00122 typedef boost::weak_ptr<Element> ElementWeakPtr;
00123
00124
00125 typedef std::vector<ElementSharedPtr> ElementSharedPtrVector;
00126
00127
00128 }
00129 }
00130
00131 #endif // TORC_PACKER_ELEMENT_HPP