00001 /* 00002 * This file is part of Micole Architecture 00003 * 00004 * Copyright (C) 2007 Micole partners 00005 * 00006 * Micole Architecture is free software: you can redistribute it 00007 * and/or modify it under the terms of the GNU Lesser General 00008 * Public License as published by the Free Software Foundation, 00009 * either version 3 of the License, or (at your option) any 00010 * later version. 00011 * 00012 * Micole Architecture is distributed in the hope that it will be 00013 * useful, * but WITHOUT ANY WARRANTY; without even the implied 00014 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00015 * PURPOSE. See the GNU Lesser General Public License for more 00016 * details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with Micole Architecture. If not, see 00020 * <http://www.gnu.org/licenses/>. 00021 */ 00022 00023 //#include "agentmodule.h" 00024 //#include <cc++/tokenizer.h> 00025 //#include <cc++\thread.h> 00026 #include "soundplayeragent.h" 00027 00028 00029 #include <string> 00030 00031 using namespace std; 00032 using namespace AgentModuleConstants; 00033 //using ost::StringTokenizer; 00034 00035 SoundPlayerAgent::SoundPlayerAgent(string name, string type, const char* domain):MicoleAgent(name,type,domain) 00036 { 00037 bindMessage( SOUND, BUS_CALLBACK_OF(SoundPlayerAgent, handleOutputMessage )); 00038 bindMessage( "^Bye$", BUS_CALLBACK_OF(SoundPlayerAgent, handleQuitMessage )); 00039 } 00040 00041 SoundPlayerAgent::SoundPlayerAgent():MicoleAgent("SoundPlayerAgent","SoundAgent","127.255.255.255:2010") 00042 { 00043 bindMessage( SOUND, BUS_CALLBACK_OF(SoundPlayerAgent, handleOutputMessage )); 00044 //count = bindMessage( "^Quit$", BUS_CALLBACK_OF(SoundPlayerAgent, &SoundPlayerAgent::handleQuitMessage )); 00045 } 00046 00047 void SoundPlayerAgent::handleOutputMessage(IvyApplication *app, int argc, const char **argv) 00048 { 00049 /* 00050 StringTokenizer st(*argv,";:=",false,true); 00051 //char *c = "file"; 00052 string str = "file"; 00053 string name = "name"; 00054 bool fileb = false; 00055 bool nameb = false; 00056 00057 StringTokenizer::iterator i; 00058 for (i = st.begin() ; i != st.end() ; ++i) 00059 { 00060 if (*i == str) 00061 { 00062 cout<<"We have a match!"<<endl; 00063 fileb = true; 00064 } 00065 else if (*i == name) 00066 nameb = true; 00067 cout << "Token: '" << *i << "'\t"; 00068 cout << " next Delim: '" << i.nextDelimiter() << "'" << endl; 00069 }*/ 00070 } 00071 00072 void SoundPlayerAgent::handleQuitMessage( IvyApplication *app, int argc, const char **argv ) 00073 { 00074 cout << "HelloAgent stops bus" << endl; 00075 cont = false; 00076 if (bus) 00077 { 00078 //agent->stop(); 00079 bus->stop(); 00080 delete bus; // This statement is never reached! Don't know why! 00081 } 00082 }