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_eventTasks = new serverVI<eventTask>();
00019         m_algorithmTasks = new serverVI<algorithmTask>();
00021         m_algConditionalTasks = new serverVI<algConditionalTask>();
00022 
00024         addAlgorithmTask("iniOfRun", new algorithmTask("iniOfRun"));
00027         addEventTask("runEvent", new eventTask("runEvent"));
00029         addAlgorithmTask("endOfRun", new algorithmTask("endOfRun") );
00030 
00032         m_applicationName = "centellaAlg";
00033 
00035         m_eventTaskName = "";
00036         m_algorithmTaskName = "";
00037 
00038         m_instance = this;
00039 
00041         setName("processManager");
00043         centellaAlgorithms();
00045         userAlgorithms();
00046 }
00047 //#####################################
00048 void processManager::setOption(std::string type, std::string name)
00049 //#####################################
00050 {
00052         optionVI::setOption(type,name);
00053         if (type == "newEventTask") {
00055                 addEventTask(name, new eventTask(name));
00056                 message(" processManager: create eventTask "+name);
00057         } else if (type == "newAlgorithmTask") {
00059                 addAlgorithmTask(name, new algorithmTask(name));
00060                 message(" created algorithmTask : "+name);
00061         } else if (type == "newAlgConditionalTask") {
00063                 addAlgConditionalTask(name, new algConditionalTask(name));
00064                 message(" created algConditialTask : "+name);
00065         }
00066 }
00067 //#####################################
00068 processManager::~processManager()
00069 //#####################################
00070 {
00071         delete m_algorithms;
00072         delete m_eventTasks;
00073         delete m_algorithmTasks;
00074         delete m_algConditionalTasks;
00075 }
00076 //#####################################
00077 void processManager::addAlgorithm(std::string name, algorithmVI* alg) 
00078 //#####################################
00079 {
00080         if (!m_algorithms->search(name)) m_algorithms->add(name,alg);
00081         else message(" algorithm already included in server "+name);
00082 }
00083 //#####################################
00084 void processManager::addAlgorithmTask(std::string name, algorithmTask* alg)
00085 //#####################################
00086 {
00087         if (!m_algorithms->search(name)) {
00088                 m_algorithmTasks->add(name,alg);
00089                 addAlgorithm(name,alg);
00090         } else message(" algorithmTask already included in server "+name);
00091 }
00092 //#####################################
00093 void processManager::addEventTask(std::string name, eventTask* evt)
00094 //#####################################
00095 {
00096         if (!m_algorithms->search(name)) {
00097                 m_eventTasks->add(name,evt);
00098                 addAlgorithm(name,evt);
00099         } else message(" not found evtProcess "+name,"GENERAL");
00100 }
00101 //#####################################
00102 void processManager::addAlgConditionalTask(std::string name, algConditionalTask* alg)
00103 //#####################################
00104 {
00105         if (!m_algorithms->search(name)) {
00106                 m_algConditionalTasks->add(name,alg);
00107                 addAlgorithm(name,alg);
00108         } else message(" not found algConditionalTask "+name,"GENERAL");
00109 }
00110 //#####################################
00111 algorithmVI* processManager::getAlgorithm(std::string name) const
00112 //#####################################
00113 {
00116         if (m_algorithms->search(name)) return m_algorithms->get(name);
00117         else message(" not found algorithm "+name,"GENERAL");
00118         return 0;
00119 }
00120 //#####################################
00121 eventTask* processManager::getEventTask(std::string name) const
00122 //#####################################
00123 {
00124         if (m_eventTasks->search(name)) return m_eventTasks->get(name);
00125         message(" not found evtProcess "+name,"GENERAL");
00126         return 0;
00127 }
00128 //#####################################
00129 algorithmTask* processManager::getAlgorithmTask(std::string name) const
00130 //#####################################
00131 {
00132         if (m_algorithmTasks->search(name)) return m_algorithmTasks->get(name);
00133         message(" not found algorithmTask "+name,"GENERAL");
00134         return 0;
00135 }
00136 //#####################################
00137 algConditionalTask* processManager::getAlgConditionalTask(std::string name) const
00138 //#####################################
00139 {
00140         if (m_algConditionalTasks->search(name)) return m_algConditionalTasks->get(name);
00141         message(" not found algConditionalTask "+name,"GENERAL");
00142         return 0;
00143 }
00144 //########################################
00145 void processManager::defineOption()
00146 //########################################
00147 {
00149         optionVI::defineOption("newEventTask",&m_eventTaskName);
00151         optionVI::defineOption("newAlgorithmTask",&m_algorithmTaskName);
00153         optionVI::defineOption("newAlgConditionalTask",&m_algConditionalTaskName);
00155         optionVI::defineOption("application",&m_applicationName);
00156 }
00157 //########################################
00158 void processManager::writeOut() const
00159 //########################################
00160 {
00161         if (!acceptLevel()) return;     
00162         std::ostream& out = messageManager::instance()->out();
00163 
00164         messageVI::writeOut();
00165 
00167         out << " application = " << m_applicationName <<"\n";
00168 
00170         if (m_algorithms->size() > 0) {
00171                 out << " -- Algorithms declared in algorithms server --" << "\n";
00172                 out << m_algorithms->nameList();
00173         }
00175         if (m_eventTasks->size() > 0) {
00176                 out << " -- eventTasks declared in the eventTasks server --" << "\n";
00177                 out << m_eventTasks->nameList();
00178         }
00180         if (m_algorithmTasks->size() > 0) {
00181                 out << " -- algorithmTask declared in the algorithmTask server --" << "\n";
00182                 out << m_algorithmTasks->nameList();
00183         }
00184                 
00186         if (m_algConditionalTasks->size() > 0) {
00187                 out << " -- algConditionalTask declared in the algConditionalTask server --" << "\n";
00188                 out << m_algConditionalTasks->nameList(); 
00189         }
00190 
00192         for (int ievt = 0; ievt < m_eventTasks->size(); ievt++ )
00193                 m_eventTasks->get(ievt)->writeOut();
00194 
00196         for (int itask = 0; itask < m_algorithmTasks->size(); itask++ )
00197                 m_algorithmTasks->get(itask)->writeOut();
00198         
00200         for (int ic = 0; ic < m_algConditionalTasks->size(); ic++ )
00201                 m_algConditionalTasks->get(ic)->writeOut();
00202 }

Generated at Wed Jun 28 17:41:07 2000 for Centella Framework by doxygen 1.1.3 written by Dimitri van Heesch, © 1997-2000