00001 #ifndef BaseOutControl_hxx 00002 #define BaseOutControl_hxx 00003 00004 #include <string> 00005 #include <list> 00006 #include <typeinfo> 00007 #include <CLAM/Assert.hxx> 00008 #include <CLAM/InControlBase.hxx> 00009 00010 00011 namespace CLAM { 00012 class Processing; 00013 class InControlBase; 00020 class OutControlBase 00021 { 00022 std::string mName; 00023 Processing * mProcessing; 00024 protected: 00025 typedef std::list<InControlBase*> Peers; 00027 Peers mLinks; 00029 OutControlBase(const OutControlBase & toBeCopied ) {} 00030 public: 00036 OutControlBase(const std::string &name, Processing * proc = 0); 00042 virtual ~OutControlBase(); 00044 const std::string& GetName() const { return mName; } 00046 Processing * GetProcessing() const { return mProcessing; } 00048 bool IsConnected() { return not mLinks.empty(); } 00050 bool IsConnectedTo(InControlBase& in) 00051 { 00052 Peers::iterator it; 00053 for (it=mLinks.begin(); it!=mLinks.end(); it++) 00054 if ((*it) == &in) return true; 00055 return false; 00056 } 00057 virtual const std::type_info& GetTypeId() const = 0; 00064 virtual bool IsLinkable(const InControlBase& in) = 0; 00069 void AddLink(InControlBase& in) 00070 { 00071 CLAM_ASSERT(IsLinkable(in), 00072 "Connecting controls which are not linkable (different types?). " 00073 "You can use IsLinkable before connecting to ensure that they are compatible."); 00074 mLinks.push_back(&in); 00075 in.OutControlInterface_AddLink(*this); 00076 } 00081 void RemoveLink(InControlBase& in) 00082 { 00083 CLAM_ASSERT(IsConnectedTo(in), 00084 "Removing a control connection that doesn't exist." 00085 "You can check that with IsConnectedTo to ensure that this condition is meet."); 00086 mLinks.remove( &in ); 00087 in.OutControlInterface_RemoveLink(*this); 00088 } 00089 Peers::iterator BeginInControlsConnected(); 00090 Peers::iterator EndInControlsConnected(); 00091 }; 00092 } // END NAMESPACE CLAM 00093 #endif // BaseOutControl_hxx