00001 #include "Event/selectionManager.h"
00002
00003 #include "Event/centellaCuts.h"
00004 #include "centella/userCuts.h"
00005
00006 #include "Event/optionManager.h"
00007 #include "Event/messageManager.h"
00008
00009 selectionManager* selectionManager::m_instance = 0;
00010
00011
00012 selectionManager::selectionManager()
00013
00014 {
00015 if (m_instance !=0) return;
00016
00018 m_serverCut = new serverVI<cutVI>();
00019 m_serverSelection = new serverVI<cutSelectionTask>();
00020
00024 addCutSelectionTask("selRead", new cutSelectionTask("selRead") );
00025 addCutSelectionTask("selWrite", new cutSelectionTask("selWrite"));
00026
00027 m_selName = "";
00028
00029 m_instance = this;
00030
00032 setName("selectionManager");
00033
00035 centellaCuts();
00037 userCuts();
00038
00039 }
00040
00041 selectionManager::~selectionManager()
00042
00043 {
00044 delete m_serverCut;
00045 delete m_serverSelection;
00046 }
00047
00048
00049 cutVI* selectionManager::getCut(std::string name) const
00050
00051 {
00052 if (m_serverCut->search(name)) return m_serverCut->get(name);
00053 else message(" the following cut has not been found in server "+name);
00054 return 0;
00055 }
00056
00057 cutSelectionTask* selectionManager::getCutSelectionTask(std::string name) const
00058
00059 {
00060 if (m_serverSelection->search(name)) return m_serverSelection->get(name);
00061 message(" the following cutSelectionTask has not been found in server "+name);
00062 return 0;
00063 }
00064
00065 void selectionManager::addCut(std::string name, cutVI* cut)
00066
00067 {
00068 if (!m_serverCut->search(name)) m_serverCut->add(name, cut);
00069 else message(" the following cut was already in the server "+name);
00070 }
00071
00072 void selectionManager::addCutSelectionTask(std::string name, cutSelectionTask* sel)
00073
00074 {
00075 if (!m_serverCut->search(name)) {
00076 addCut(name,sel);
00077 m_serverSelection->add(name, sel);
00078 } else message(" the following cutSelectionTask was already in the server "+name);
00079 }
00080
00081 void selectionManager::setOption(std::string var, std::string content)
00082
00083 {
00084 optionVI::setOption(var,content);
00085 if (var == "newCutSelectionTask"){
00086 if (!m_serverSelection->search(content)) {
00087 addCutSelectionTask(content,new cutSelectionTask(content));
00088 message(" created cutSelectionTask "+content,"RELEASE");
00089 } else message(" already existing cutSelectionTask "+content,"RELEASE");
00090 }
00091 }
00092
00093 void selectionManager::defineOption()
00094
00095 {
00097 optionVI::defineOption("newCutSelectionTask",&m_selName);
00098 }
00099
00100 void selectionManager::writeOut() const
00101
00102 {
00103 if (!acceptLevel()) return;
00104
00105 std::ostream& out = messageManager::instance()->out();
00106
00107 messageVI::writeOut();
00108
00110 if (m_serverCut->size() > 0) {
00111 out << " -- cuts in cuts server -- " <<"\n";
00112 out << m_serverCut->nameList();
00113 }
00114
00116 if (m_serverSelection->size() > 0 ) {
00117 out << " -- cutSelectionTasks in cutSelectionTasks server -- " << "\n";
00118 out << m_serverSelection->nameList();
00119 }
00120
00122 for (int isel = 0; isel < m_serverSelection->size(); isel++)
00123 m_serverSelection->get(isel)->writeOut();
00124 }