00001 #ifndef MCP_H 00002 #define MCP_H 00003 00004 #include <CommsManager.H> 00005 #include <Logger.H> 00006 #include <Heartbeat.H> 00007 #include <MCPControl.H> 00008 #include <unistd.h> 00009 #include <string> 00010 #include <errno.h> 00011 #include <vector> 00012 00013 namespace MCP { 00014 00015 struct Mapping { 00016 std::string object; 00017 std::string source; 00018 std::string interface; 00019 }; 00020 00024 class Module { 00025 00026 public: 00027 Module(std::string name); 00028 00029 Module(WURDE::HeartbeatInfoStruct &info); 00030 Module(WURDE::HeartbeatDataStruct &data); 00031 00032 bool stale(); 00033 00034 WURDE::RunState getState(){return m_state;}; 00035 WURDE::ProcessLocale getLocale(){return m_locale;}; 00036 WURDE::ProcessType getType(){return m_managedType;}; 00037 string getModuleName(){return m_moduleName;}; 00038 string getBinary(){return m_binary;}; 00039 00040 void setState(WURDE::RunState somestate){m_state=somestate;}; 00041 void setLocale(WURDE::ProcessLocale somelocale){m_locale=somelocale;}; 00042 void setType(WURDE::ProcessType sometype){m_managedType=sometype;}; 00043 void setTTL(double seconds); 00044 void setModuleName(std::string name){WURDE::g_logdebug << "Old name: " << m_moduleName << " new name: " << name << endl; m_moduleName=name;}; 00045 void setBinary(std::string bin){m_binary=bin;}; 00046 // void setCommandLineOptions(std::string options){m_options=options;} 00047 void addCommandLineOption(std::string option){m_options.push_back(option);} 00048 void addInterface(std::string interface){addInterface(interface,"Unknown");}; 00049 void addInterface(std::string interface, std::string name); 00050 // void addInterface(string interface){m_interfaces.push_back(interface);}; 00051 00052 bool beat(WURDE::HeartbeatDataStruct beat); 00053 bool refresh(WURDE::HeartbeatInfoStruct info); 00054 00055 std::string findObjectMapping(std::string object, std::string interface, WURDE::ConnectionStrategy strat); 00056 00057 void setMappings(std::vector<Mapping> mappings){m_mappings=mappings;}; 00058 bool hasSupplier(std::string streamname,std::string type); 00059 bool startUp(WURDE::CommsManager &myManager, std::string someArgs); 00060 00061 int m_attemptedStarts; 00062 int m_maxAttempts; 00063 00064 protected: 00065 Module(); 00066 private: 00067 WURDE::Time m_lastTimestamp; 00068 struct timeval m_TTL; 00069 WURDE::RunState m_state; 00070 WURDE::ProcessType m_managedType; 00071 WURDE::ProcessLocale m_locale; 00072 std::string m_moduleName; 00073 std::string m_binary; 00074 std::vector<std::string> m_options; 00075 std::vector<WURDE::InterfaceStream> m_interfaces; 00076 std::vector<Mapping> m_mappings; 00081 std::vector<Mapping> m_occupiedResources; 00082 pid_t m_process; 00083 }; 00084 00085 //assorted functions 00086 00091 std::vector<Module> parseConfigFile(std::string config); 00092 std::vector<Module> parseMapFile(std::string config,std::vector<Module> &theModules); 00093 } 00094 00095 #endif