00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TORC_PACKER_CONNECTION_HPP
00017 #define TORC_PACKER_CONNECTION_HPP
00018
00019 #include "torc/physical/Named.hpp"
00020 #include "torc/physical/Progeny.hpp"
00021 #include "torc/packer/ConnectionPin.hpp"
00022
00023 #include <string>
00024
00025 namespace torc {
00026 namespace physical {
00027
00028
00029 class Connection : public Named {
00030
00031
00032 friend class RcFactory; protected: typedef std::string string;
00033 ConnectionPinVector mConnectionPins;
00034
00035
00036 public:
00037
00038 Connection(const string& inName) : Named(inName){}
00039
00040 typedef ConnectionPinVector::const_iterator ConnectionPinSharedPtrConstIterator;
00041 typedef ConnectionPinVector::iterator ConnectionPinSharedPtrIterator;
00042
00043 ConnectionPinSharedPtrConstIterator connectionPinsBegin(void) const { return mConnectionPins.begin(); }
00044 ConnectionPinSharedPtrConstIterator connectionPinsEnd(void) const { return mConnectionPins.end(); }
00045 ConnectionPinSharedPtrIterator connectionPinsBegin(void) { return mConnectionPins.begin(); }
00046 ConnectionPinSharedPtrIterator connectionPinsEnd(void) { return mConnectionPins.end(); }
00047 ConnectionPinSharedPtrConstIterator getSource(void) const { return mConnectionPins.begin(); }
00048 ConnectionPinSharedPtrConstIterator getSink(void) const { ConnectionPinSharedPtrConstIterator cp = mConnectionPins.begin();; ++cp; return cp; }
00049 size_t getConnectionPinCount(void) const { return mConnectionPins.size(); }
00050
00051 bool addConnectionPin(ConnectionPin& inConnectionPinPtr) {
00052
00053 ConnectionPinSharedPtrIterator e = connectionPinsEnd();
00054 ConnectionPinSharedPtrIterator result = std::find(connectionPinsEnd(), e, inConnectionPinPtr);
00055 if(result != e) return false;
00056 mConnectionPins.push_back(inConnectionPinPtr);
00057 return true;
00058
00059 }
00060
00061
00062 bool removeConnectionPin(ConnectionPin& inConnectionPinPtr) {
00063
00064 ConnectionPinSharedPtrIterator e = connectionPinsEnd();
00065 ConnectionPinSharedPtrIterator result = std::find(connectionPinsBegin(), e, inConnectionPinPtr);
00066 if(result == e) return false;
00067 mConnectionPins.erase(result);
00068
00069 return true;
00070 }
00071
00072
00073
00074
00075
00076
00077 bool operator ==(const Connection& rhs) const { return mName == rhs.mName; }
00078
00079 };
00080
00081
00082 typedef boost::shared_ptr<Connection> ConnectionSharedPtr;
00083
00084
00085 typedef boost::weak_ptr<Connection> ConnectionWeakPtr;
00086
00087
00088 typedef std::vector<ConnectionSharedPtr> ConnectionSharedPtrVector;
00089
00090 }
00091 }
00092
00093 #endif // TORC_PACKER_CONNECTION_HPP