Plugin.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2013, Institute for Artificial Intelligence,
00005  *  Universität Bremen.
00006  *  All rights reserved.
00007  *
00008  *  Redistribution and use in source and binary forms, with or without
00009  *  modification, are permitted provided that the following conditions
00010  *  are met:
00011  *
00012  *   * Redistributions of source code must retain the above copyright
00013  *     notice, this list of conditions and the following disclaimer.
00014  *   * Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions and the following
00016  *     disclaimer in the documentation and/or other materials provided
00017  *     with the distribution.
00018  *   * Neither the name of the Institute for Artificial Intelligence,
00019  *     Universität Bremen, nor the names of its contributors may be
00020  *     used to endorse or promote products derived from this software
00021  *     without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *********************************************************************/
00036 
00040 #ifndef __PLUGIN_H__
00041 #define __PLUGIN_H__
00042 
00043 
00044 // System
00045 #include <cstdlib>
00046 #include <mutex>
00047 #include <list>
00048 #include <string>
00049 #include <sstream>
00050 
00051 // Private
00052 #include <Types.h>
00053 #include <ForwardDeclarations.h>
00054 #include <ArbitraryMappingsHolder.h>
00055 
00056 
00057 namespace beliefstate {
00058   namespace plugins {
00059     class Plugin : public ArbitraryMappingsHolder {
00060     private:
00061       std::list<std::string> m_lstDependencies;
00062       std::string m_strName;
00063       std::string m_strVersion;
00064       int m_nID;
00065       bool m_bRunCycle;
00066       std::mutex m_mtxRunCycle;
00067       bool m_bDevelopmentPlugin;
00068       
00069     protected:
00070       std::list<Event> m_lstEvents;
00071       std::mutex m_mtxEventsStore;
00072       std::list<string> m_lstSubscribedEventNames;
00073       std::list<ServiceEvent> m_lstServiceEvents;
00074       std::mutex m_mtxServiceEventsStore;
00075       std::list<std::string> m_lstOfferedServices;
00076       std::list<int> m_lstOpenRequestIDs;
00077       std::list<ServiceEvent> m_lstReceivedServiceEventResponses;
00078       std::mutex m_mtxReceivedServiceEventResponses;
00079       
00080     public:
00081       Plugin();
00082       virtual ~Plugin();
00083       
00084       void setPluginID(int nID);
00085       int pluginID();
00086       
00087       void setPluginName(std::string strName);
00088       std::string pluginName();
00089       
00090       virtual Result init(int argc, char** argv);
00091       virtual Result deinit();
00092       
00093       virtual Result cycle();
00094       Result cycleResults();
00095       
00096       CDesignator* getIndividualConfig();
00097       
00098       void setDevelopmentPlugin(bool bDevelopmentPlugin);
00099       bool developmentPlugin();
00100       void setPluginVersion(std::string strVersion);
00101       std::string pluginVersion();
00102       
00103       void setSubscribedToEvent(std::string strEventName, bool bSubscribed);
00104       bool subscribedToEvent(std::string strEventName);
00105       virtual void consumeEvent(Event evEvent);
00106       
00107       void setOffersService(std::string strServiceName, bool bOffering);
00108       bool offersService(std::string strServiceName);
00109       virtual Event consumeServiceEvent(ServiceEvent seServiceEvent);
00110       
00111       void addDependency(std::string strPluginName);
00112       bool dependsOn(std::string strPluginName);
00113       std::list<std::string> dependencies();
00114       
00115       void deployCycleData(Result& resDeployTo);
00116       
00117       void deployEvent(Event evDeploy, bool bWaitForEvent = false);
00118       ServiceEvent deployServiceEvent(ServiceEvent seDeploy, bool bWaitForEvent = false);
00119       
00120       std::string pluginIdentifierString(bool bBold);
00121       void unimplemented(std::string strMessage);
00122       
00123       int openNewRequestID();
00124       bool isRequestIDOpen(int nID);
00125       void closeRequestID(int nID);
00126       bool isAnyRequestIDOpen();
00127       
00128       void setRunning(bool bRunCycle);
00129       bool running();
00130       
00131       void waitForEvent(Event evWait);
00132       ServiceEvent waitForEvent(ServiceEvent seWait);
00133       
00134       void success(std::string strMessage, bool bImportant = false);
00135       void info(std::string strMessage, bool bImportant = false);
00136       void warn(std::string strMessage, bool bImportant = false);
00137       void fail(std::string strMessage, bool bImportant = false);
00138     };
00139   }
00140 }
00141 
00142 
00143 #endif /* __PLUGIN_H__ */


beliefstate
Author(s): Jan Winkler
autogenerated on Sun Oct 5 2014 22:30:15