CLAM-Development
1.1
|
00001 /* 00002 * Copyright (c) 2001-2007 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 00022 00023 00024 #ifndef _FlattenedNetwork_hxx_ 00025 #define _FlattenedNetwork_hxx_ 00026 00027 #include "Processing.hxx" 00028 #include "InPort.hxx" 00029 #include "OutPort.hxx" 00030 #include "InControl.hxx" 00031 #include "OutControl.hxx" 00032 #include <string> 00033 #include <list> 00034 #include <map> 00035 #include <set> 00036 00037 //#include "Component.hxx" 00038 //#include "Storage.hxx" 00039 #include "BaseNetwork.hxx" 00040 00041 namespace CLAM 00042 { 00043 class NetworkPlayer; 00044 class FlowControl; 00045 00046 class FlattenedNetwork : public BaseNetwork 00047 { 00048 00049 public: 00050 // constructor / destructor 00051 FlattenedNetwork(); 00052 virtual ~FlattenedNetwork(); 00053 00054 // Methods related to network itself 00055 const std::string& GetName() const { return _name; } 00056 void SetName( const std::string& name ) { _name=name; } 00057 virtual const char * GetClassName() const 00058 { 00059 return "FlattenedNetwork"; 00060 } 00061 00062 // Methods related with player and flow 00063 bool IsStopped() const; 00064 void Start(); 00065 void Stop(); 00066 void Do(); 00068 void AddFlowControl( FlowControl* ); 00069 void Clear(); 00071 void SetPlayer( NetworkPlayer* player); 00072 unsigned BackendBufferSize(); 00073 unsigned BackendSampleRate(); 00074 00075 00077 virtual void StoreOn( Storage & storage) const; 00078 virtual void LoadFrom( Storage & storage); 00079 00081 bool UpdateSelections (const NamesList & processingsNamesList); 00082 void setPasteMode() { _setPasteMode=true; } 00083 00085 bool SetProcessingsGeometries (const ProcessingsGeometriesMap & processingsGeometries); 00086 const ProcessingsGeometriesMap GetAndClearGeometries(); 00087 00088 /*// TODO: make individual geometries loadings/storings?? 00089 const Geometry GetAndEraseGeometry(std::string name);*/ 00091 bool ConnectPorts( const std::string &, const std::string & ); 00092 bool ConnectControls( const std::string &, const std::string & ); 00093 bool DisconnectPorts( const std::string &, const std::string & ); 00094 bool DisconnectControls( const std::string &, const std::string & ); 00095 00097 Processing& GetProcessing( const std::string & name ) const; 00099 void AddProcessing( const std::string &, Processing* ); 00101 void AddProcessing( const std::string & name, const std::string & key ); 00102 std::string AddProcessing( const std::string& key ); 00103 std::string GetUnusedName( const std::string& prefix ) const; 00104 void RemoveProcessing ( const std::string & ); 00105 bool HasProcessing( const std::string & name ) const; 00109 bool ConfigureProcessing( const std::string &, const ProcessingConfig & ); 00111 void ReconfigureAllProcessings(); 00112 bool RenameProcessing( const std::string & oldName, const std::string & newName ); 00113 00114 const std::string & GetNetworkId(const Processing * proc) const; 00115 00116 // accessors to nodes and processing 00117 ProcessingsMap::iterator BeginProcessings(); 00118 ProcessingsMap::iterator EndProcessings(); 00119 ProcessingsMap::const_iterator BeginProcessings() const; 00120 ProcessingsMap::const_iterator EndProcessings() const; 00121 00122 InPortBase & GetInPortByCompleteName( const std::string& ) const; 00123 OutPortBase & GetOutPortByCompleteName( const std::string& ) const; 00124 InControl & GetInControlByCompleteName( const std::string& ) const; 00125 OutControl & GetOutControlByCompleteName( const std::string& ) const; 00126 00127 NamesList GetInPortsConnectedTo( const std::string & ) const; 00128 NamesList GetInControlsConnectedTo( const std::string & ) const; 00129 InPortsList GetInPortsConnectedTo( OutPortBase & ) const; 00130 00131 std::string GetConnectorIdentifier( const std::string& ) const; 00132 std::string GetProcessingIdentifier( const std::string& ) const; 00133 00139 bool IsReady() const; 00140 00142 bool IsEmpty() const; 00143 00145 bool HasMisconfiguredProcessings() const; 00146 00148 bool HasUnconnectedInPorts() const; 00149 00154 bool HasSyncSource() const; 00155 00160 std::string GetConfigurationErrors() const; 00165 std::string GetUnconnectedInPorts() const; 00166 00167 private: 00168 // fields 00169 std::string _name; 00170 ProcessingsMap _processings; 00171 FlowControl* _flowControl; 00172 NetworkPlayer* _player; 00173 00174 // attributes for canvas copy & paste 00175 mutable NamesSet _selectedProcessings; 00176 bool _setPasteMode; 00177 00178 bool HasSelectionAndContains(const std::string & name) const; 00179 00180 // attributes for canvas processing geometries 00181 mutable ProcessingsGeometriesMap _processingsGeometries; 00182 void StringPairToInts(const std::string & geometryInString, int & a, int & b); 00183 const std::string IntsToString (const int & a, const int & b) const; 00184 00185 }; 00186 00187 }// namespace 00188 #endif 00189