24 #include "IOConnections.hpp"
25 #include "portManager.hpp"
39 m_log = &bitpit::log::cout(MIMMO_LOG_FILE);
41 for(
auto &val: mapConn){
42 if(val.second ==
nullptr)
continue;
59 m_log = &bitpit::log::cout(MIMMO_LOG_FILE);
76 m_log->setPriority(bitpit::log::NORMAL);
78 if(slotXML.getSectionCount() == 0) {
79 (*m_log)<<
"IOConnections::absorbConnections does not found any connection to read in current XML slot."<<std::endl;
82 bool checkConnection =
true;
84 for(
auto & sect : slotXML.getSections()){
90 if(sect.second->hasOption(
"sender")) snd_str = sect.second->get(
"sender");
91 if(sect.second->hasOption(
"receiver")) rcv_str = sect.second->get(
"receiver");
92 if(sect.second->hasOption(
"senderPort")) sndP_str = sect.second->get(
"senderPort");
93 if(sect.second->hasOption(
"receiverPort")) rcvP_str = sect.second->get(
"receiverPort");
95 snd_str = bitpit::utils::string::trim(snd_str);
96 rcv_str = bitpit::utils::string::trim(rcv_str);
97 sndP_str = bitpit::utils::string::trim(sndP_str);
98 rcvP_str = bitpit::utils::string::trim(rcvP_str);
107 (*m_log)<<
"---------------------------------------------"<<std::endl;
108 (*m_log)<<
"sender: "<<snd_str<<std::endl;
109 (*m_log)<<
"receiver: "<<rcv_str<<std::endl;
110 (*m_log)<<
"senderPort: "<<sndP_str<<std::endl;
111 (*m_log)<<
"receiverPort: "<<rcvP_str<<std::endl;
112 (*m_log)<<
"---------------------------------------------"<<std::endl;
113 (*m_log)<<
""<<std::endl;
114 (*m_log)<<
"IOConnections::absorbConnections does not found any sender/receiver and/or port compatible with API."<<std::endl;
115 (*m_log)<<
"Please control connection data entries in your XML file"<<std::endl;
116 (*m_log)<<
""<<std::endl;
120 m_log->setPriority(bitpit::log::NORMAL);
121 bool check =
pin::addPin(itSend->second, itRece->second, sndP_str, rcvP_str);
122 if(!debug)
m_log->setPriority(bitpit::log::DEBUG);
125 (*m_log)<<
"---------------------------------------------"<<std::endl;
126 (*m_log)<<
"sender: "<<snd_str<<std::endl;
127 (*m_log)<<
"receiver: "<<rcv_str<<std::endl;
128 (*m_log)<<
"senderPort: "<<sndP_str<<std::endl;
129 (*m_log)<<
"receiverPort: "<<rcvP_str<<std::endl;
130 (*m_log)<<
"---------------------------------------------"<<std::endl;
131 (*m_log)<<
""<<std::endl;
132 (*m_log)<<
"IOConnections::absorbConnections failed creating connection."<<std::endl;
133 (*m_log)<<
""<<std::endl;
134 checkConnection =
false;
137 (*m_log)<<
"IOConnections::absorbConnections successfully created connection."<<std::endl;
141 m_log->setPriority(bitpit::log::DEBUG);
142 if(!checkConnection){
143 throw std::runtime_error (
"IOConnections : one or more failed pin connections found.");
165 auto mapPOut = (
object.second)->getPortsOut();
168 for(
auto & pOut : mapPOut ){
170 std::string senderPort = pOut.first;
172 std::vector<BaseManipulation * > links = (pOut.second)->getLink();
173 std::vector<PortID> lids = (pOut.second)->getPortLink();
176 for(
auto & val : links){
178 std::string receiverPort = lids[counter];
180 std::string title =
"conn" + std::to_string(counter+counterGlob);
181 bitpit::Config::Section & conn = slotXML.addSection(title);
182 conn.set(
"sender", sender);
183 conn.set(
"senderPort", senderPort);
184 conn.set(
"receiver", receiver);
185 conn.set(
"receiverPort", receiverPort);
189 counterGlob += counter;
194 m_log->setPriority(bitpit::log::NORMAL);
195 (*m_log)<<
"IOConnections::flushConnections wrote "<< slotXML.getSectionCount()<<
" active connections."<<std::endl;
196 m_log->setPriority(bitpit::log::DEBUG);