00001 00030 #ifndef _SOUNDCONTROLLER_H 00031 #define _SOUNDCONTROLLER_H 00032 #include <WritableType.H> 00033 #include <Capability.H> 00034 #include <COMObject.H> 00035 #include <queue> 00036 #include <vector> 00037 00038 // $Id: Type.H 66 2007-01-23 20:53:23Z fwph $ 00039 00040 #define SOUNDCONTROLLER "SoundController" 00041 // IDNUMBER is used to identify data events . IDNUMBER+1 is the info event. this 00042 // system will probably go away soon... 00043 //#define SOUNDCONTROLLERIDNUMBER 34 00044 00045 namespace WURDE { 00046 class Capability; 00047 class CommsManager; 00048 class Logger; 00049 00050 00051 00052 00053 class SoundControllerInfoStruct { 00054 public: std::string source; 00055 Writable< bool > playSound; 00056 MessageType mType; 00057 Writable< int > secondsToLive; 00058 std::string target; 00059 Time timestamp; 00060 Writable< int > repeat; 00061 Writable< std::string > currentSet; 00062 Writable< std::string > currentSound; 00063 }; 00064 00065 00066 class SoundControllerDataStruct { 00067 public: std::string source; 00068 std::vector< std::string > soundSets; 00069 Time timestamp; 00070 std::vector< std::string > availableSounds; 00071 }; 00072 00078 class SoundController : virtual public Capability { 00079 00080 public: 00086 explicit SoundController(const std::string & streamname); 00087 00093 SoundController(const ConnectionStrategy & strategy,const std::string & gblName); 00094 00100 SoundController(const std::string & streamname,const std::string & gblName); 00101 00102 ~SoundController(); 00103 00104 00108 void init(const std::string & streamname,const ConnectionStrategy & strategy, const std::string & gblName); 00109 00110 00115 SoundControllerDataStruct data; 00116 00120 SoundControllerInfoStruct info; 00121 00125 SoundControllerInfoStruct requests; 00126 00127 //RobotObject imps 00128 void runUpdate(); 00129 void setManager(CommsManager *myManager_); 00130 void setCOMObject(COMBase *object){ myCOMObject = dynamic_cast<COMObject<SoundControllerInfoStruct,SoundControllerDataStruct> *> (object);} 00131 void disconnect(){if(myCOMObject){myCOMObject->disconnect();}} 00132 void activateSupplier(); 00133 void activateConsumer(); 00134 std::string getInterfaceName(){ return SOUNDCONTROLLER;} 00135 void setStreamName(const std::string & name); 00136 void setGlobalName(const std::string & name); 00137 bool newData(); 00138 bool newInfo(); 00139 void setAutoPing(const bool & val); 00140 void doPing(); 00141 // int getID(){return SOUNDCONTROLLERIDNUMBER;} 00142 00146 bool getQueueMode(){return m_queue;}; 00147 00151 void setQueueMode(const bool & val); 00152 00157 SoundControllerDataStruct getNextData(); 00158 00163 SoundControllerInfoStruct getNextInfo(); 00164 00168 SoundControllerInfoStruct getNextRequest(){return getNextInfo();} 00169 00170 void publishData(); 00171 void publishInfo(); 00172 //void publishRequest(); 00173 00174 protected: 00175 COMObject<SoundControllerInfoStruct, SoundControllerDataStruct> *myCOMObject; 00176 00177 bool m_queue; 00178 00179 //notes that the object should be initialized as soon as a streamname is received 00180 bool m_initialize; 00181 std::queue<SoundControllerDataStruct> m_dataVector; 00182 std::queue<SoundControllerInfoStruct> m_infoVector; 00183 std::queue<SoundControllerInfoStruct> m_requestVector; 00184 00185 }; 00186 00187 } 00188 00189 00190 #endif