00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _BaseNetwork_hxx_
00022 #define _BaseNetwork_hxx_
00023
00024 #include "Processing.hxx"
00025 #include "InPort.hxx"
00026 #include "OutPort.hxx"
00027 #include "InControl.hxx"
00028 #include "OutControl.hxx"
00029 #include <string>
00030 #include <list>
00031 #include <map>
00032 #include <set>
00033 #include "Component.hxx"
00034
00035 namespace CLAM
00036 {
00037
00038 class BaseNetwork : public Component
00039 {
00040 public:
00041
00042 typedef std::list<std::string> NamesList;
00043 typedef std::map <std::string, Processing* > ProcessingsMap;
00044 typedef std::list<InPortBase *> InPortsList;
00045
00046 typedef struct { int x, y, width, height; } Geometry;
00047 typedef std::map <std::string, Geometry> ProcessingsGeometriesMap;
00048 typedef struct { std::string sourceName, sinkName; } Connection;
00049 typedef std::list<Connection> ConnectionsList;
00050
00051
00052 BaseNetwork() {}
00053 virtual ~BaseNetwork() {}
00054 virtual const char * GetClassName() const = 0;
00055 virtual void Clear() = 0;
00056
00057
00058 virtual void StoreOn( Storage & storage) const = 0;
00059 virtual void LoadFrom( Storage & storage) = 0;
00060
00061
00062 virtual const std::string& GetName() const = 0;
00063 virtual void SetName( const std::string& name ) = 0;
00064 virtual const std::string & GetNetworkId(const Processing * proc) const = 0;
00065
00066
00067 virtual ProcessingsMap::iterator BeginProcessings() = 0;
00068 virtual ProcessingsMap::iterator EndProcessings() = 0;
00069 virtual ProcessingsMap::const_iterator BeginProcessings() const = 0;
00070 virtual BaseNetwork::ProcessingsMap::const_iterator EndProcessings() const = 0;
00071
00072 virtual NamesList GetInPortsConnectedTo( const std::string & producer ) const = 0;
00073 virtual NamesList GetInControlsConnectedTo( const std::string & producer ) const = 0;
00074 virtual InPortsList GetInPortsConnectedTo( OutPortBase & producer ) const = 0;
00075 virtual std::string GetConnectorIdentifier( const std::string& ) const = 0;
00076 virtual std::string GetProcessingIdentifier( const std::string& ) const = 0;
00077 virtual InPortBase & GetInPortByCompleteName( const std::string & name ) const = 0;
00078 virtual OutPortBase & GetOutPortByCompleteName( const std::string & name ) const = 0;
00079 virtual InControl & GetInControlByCompleteName( const std::string & name ) const = 0;
00080 virtual OutControl & GetOutControlByCompleteName( const std::string & name ) const = 0;
00081
00082
00083 virtual bool ConnectPorts( const std::string &, const std::string & ) = 0;
00084 virtual bool ConnectControls( const std::string &, const std::string & ) = 0;
00085 virtual bool DisconnectPorts( const std::string &, const std::string & ) = 0;
00086 virtual bool DisconnectControls( const std::string &, const std::string & ) = 0;
00087
00092 virtual std::string GetUnconnectedInPorts() const = 0;
00094 virtual bool HasProcessing( const std::string & name ) const = 0;
00095 virtual Processing& GetProcessing( const std::string & name ) const = 0;
00097 virtual void AddProcessing( const std::string &, Processing* ) = 0;
00099 virtual void AddProcessing( const std::string & name, const std::string & key ) = 0;
00100 virtual std::string AddProcessing( const std::string& key ) = 0;
00101 virtual std::string GetUnusedName( const std::string& prefix ) const = 0;
00102 virtual bool RenameProcessing( const std::string & oldName, const std::string & newName ) = 0;
00103 virtual void RemoveProcessing ( const std::string & ) = 0;
00104
00110 virtual bool IsReady() const = 0;
00112 virtual bool IsEmpty() const = 0;
00114 virtual bool HasMisconfiguredProcessings() const = 0;
00116 virtual bool HasUnconnectedInPorts() const = 0;
00121 virtual bool HasSyncSource() const = 0;
00125 virtual bool ConfigureProcessing( const std::string &, const ProcessingConfig & ) = 0;
00127 virtual void ReconfigureAllProcessings() = 0;
00132 virtual std::string GetConfigurationErrors() const = 0;
00133
00134 virtual bool UpdateSelections (const NamesList & processingsNamesList) = 0;
00135 virtual void setPasteMode() = 0;
00136
00137 virtual bool SetProcessingsGeometries (const ProcessingsGeometriesMap & processingsGeometries) = 0;
00138 virtual const ProcessingsGeometriesMap GetAndClearGeometries() = 0;
00139
00140
00141
00142 virtual unsigned BackendBufferSize() = 0;
00143 virtual unsigned BackendSampleRate() = 0;
00144
00145 protected:
00146 static std::size_t PositionOfLastIdentifier( const std::string& str)
00147 {
00148 std::size_t result = str.find_last_of( NamesIdentifiersSeparator() );
00149 CLAM_ASSERT( result!=std::string::npos, "Malformed port/control name. It should be ProcessingName.[Port/Control]Name");
00150 return result;
00151 }
00152 static std::size_t PositionOfProcessingIdentifier( const std::string& str)
00153 {
00154 std::size_t endPos = PositionOfLastIdentifier(str)-1;
00155 std::size_t last_ofResult = str.find_last_of( NamesIdentifiersSeparator(), endPos );
00156 return last_ofResult == std::string::npos ? 0 : last_ofResult+1;
00157 }
00158 static char NamesIdentifiersSeparator()
00159 {
00160 return '.';
00161 }
00162
00163 typedef std::set<std::string> NamesSet;
00164 virtual bool HasSelectionAndContains(const std::string & name) const = 0;
00165
00166
00167
00168
00169 };
00170 }
00171 #endif