Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

processManager.cpp

Go to the documentation of this file.
00001 #include "Event/processManager.h"
00002 #include "Event/centellaAlgorithms.h"
00003 #include "Event/userAlgorithms.h"
00004 #include "Event/messageManager.h"
00005 
00006 processManager* processManager::m_instance = 0;
00007 
00008 //#####################################
00009 processManager::processManager() 
00010 //#####################################
00011 {
00012         if (m_instance != 0) return;
00013 
00015         m_algorithms     = new serverVI<algorithmVI>();
00017         m_eventProcesses = new serverVI<eventProcess>();
00019         m_algorithmTasks = new serverVI<algorithmTask>();
00020 
00022         m_iniRun   = new algorithmTask("iniOfRun");
00025         m_runEvent = new eventProcess("runEvent");
00027         m_endRun   = new algorithmTask("endOfRun");
00028 
00029         m_algorithmTasks->add("iniOfRun",m_iniRun);
00030         m_eventProcesses->add("runEvent",m_runEvent);
00031         m_algorithmTasks->add("endOfRun",m_endRun);
00032 
00034         m_applicationName = "centellaAlg";
00035 
00037         m_eventProcessName = "";
00038         m_algorithmTaskName = "";
00039 
00040         m_instance = this;
00041 
00043         setName("processManager");
00045         centellaAlgorithms();
00047         userAlgorithms();
00048 }
00049 //#####################################
00050 void processManager::setOption(std::string type, std::string name)
00051 //#####################################
00052 {
00054         optionVI::setOption(type,name);
00055         if (type == "newEventProcess") {
00057                 eventProcess* evtP = new eventProcess(name);
00058                 m_eventProcesses->add(name,evtP);
00059                 message(" processManager: create eventProcess "+name,"RELEASE");
00060         } else if (type == "newAlgorithmTask") {
00062                 algorithmTask* task = new algorithmTask(name);
00063                 m_algorithmTasks->add(name,task);
00064                 message(" created algorithmTask : "+name,"RELASE");
00065         }
00066 }
00067 //#####################################
00068 processManager::~processManager()
00069 //#####################################
00070 {
00071         delete m_algorithms;
00072         delete m_eventProcesses;
00073         delete m_algorithmTasks;
00074 }
00075 //#####################################
00076 void processManager::addAlgorithm(std::string name, algorithmVI* alg) 
00077 //#####################################
00078 {
00079         if ( !(m_algorithms->search(name)) && 
00080                  !(m_eventProcesses->search(name)) &&
00081                  !(m_algorithmTasks->search(name)) ) m_algorithms->add(name,alg);
00082         else message(" algorithm already included in server "+name);
00083 }
00084 //#####################################
00085 algorithmVI* processManager::getAlgorithm(std::string name) const
00086 //#####################################
00087 {
00090         if (m_algorithms->search(name)) return m_algorithms->get(name);
00091         else if (m_eventProcesses->search(name)) return m_eventProcesses->get(name);
00092         else if (m_algorithmTasks->search(name)) return m_algorithmTasks->get(name);
00093         message(" not found algorithm "+name,"GENERAL");
00094         return 0;
00095 }
00096 //#####################################
00097 eventProcess* processManager::getEventProcess(std::string name) const
00098 //#####################################
00099 {
00100         if (m_eventProcesses->search(name)) return m_eventProcesses->get(name);
00101         message(" not found evtProcess "+name,"GENERAL");
00102         return 0;
00103 }
00104 //#####################################
00105 algorithmTask* processManager::getAlgorithmTask(std::string name) const
00106 //#####################################
00107 {
00108         if (m_algorithmTasks->search(name)) return m_algorithmTasks->get(name);
00109         message(" not found algorithmTask "+name,"GENERAL");
00110         return 0;
00111 }
00112 
00113 //########################################
00114 void processManager::defineOption()
00115 //########################################
00116 {
00118         optionVI::defineOption("newEventProcess",&m_eventProcessName);
00120         optionVI::defineOption("newAlgorithmTask",&m_algorithmTaskName);
00122         optionVI::defineOption("application",&m_applicationName);
00123 }
00124 //########################################
00125 void processManager::writeOut() const
00126 //########################################
00127 {
00128         if (!acceptLevel()) return;     
00129         std::ostream& out = messageManager::instance()->out();
00130 
00131         messageVI::writeOut();
00132 
00134         out << " application = " << m_applicationName <<"\n";
00135 
00137         if (m_algorithms->size() > 0) {
00138                 out << " -- Algorithms declared in algorithms server --" << "\n";
00139                 out << m_algorithms->nameList();
00140         }
00142         if (m_eventProcesses->size() > 0) {
00143                 out << " -- eventProcesses declared in the eventProcesses server --" << "\n";
00144                 out << m_eventProcesses->nameList();
00145         }
00147         if (m_algorithmTasks->size() > 0) {
00148                 out << " -- algorithmTask declared in the algorithmTask server --" << "\n";
00149                 out << m_algorithmTasks->nameList(); 
00150         }
00151 
00153         for (int ievt = 0; ievt < m_eventProcesses->size(); ievt++ )
00154                 m_eventProcesses->get(ievt)->writeOut();
00155 
00157         for (int itask = 0; itask < m_algorithmTasks->size(); itask++ )
00158                 m_algorithmTasks->get(itask)->writeOut();
00159 
00160 }

Generated at Thu Jun 22 16:53:25 2000 for Centella Framework by doxygen 1.1.3 written by Dimitri van Heesch, © 1997-2000