InOut.cpp
1 /*---------------------------------------------------------------------------*\
2 *
3 * mimmo
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of mimmo.
10 *
11 * mimmo is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * mimmo is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with mimmo. If not, see <http://www.gnu.org/licenses/>.
22 *
23 \*---------------------------------------------------------------------------*/
24 #include "InOut.hpp"
25 #include "BaseManipulation.hpp"
26 
27 //==============================================================//
28 // DATA TYPE CLASS IMPLEMENTATION //
29 // //==============================================================//
30 namespace mimmo{
31 
36  m_conType = "MC_SCALAR";
37  m_dataType = "MD_INT";
38 };
39 
46  m_conType = conType;
47  m_dataType = dataType;
48  return;
49 };
50 
55 
56 
60 bool DataType::operator==(const DataType & other){
61  bool check = true;
62  check = check && (m_conType == other.m_conType);
63  check = check && (m_dataType == other.m_dataType);
64  return(check);
65 };
66 
67 
68 //==============================================================//
69 // BASE INOUT CLASS IMPLEMENTATION //
70 //==============================================================//
71 
76  m_objLink.clear();
77 };
78 
83 
87 PortOut::PortOut(const PortOut & other){
88  m_objLink = other.m_objLink;
89  m_obuffer = other.m_obuffer;
90  m_portLink = other.m_portLink;
91  m_datatype = other.m_datatype;
92  return;
93 };
94 
98 bool PortOut::operator==(const PortOut & other){
99  bool check = true;
100  check = check && (m_portLink == other.m_portLink);
101  check = check && (m_objLink == other.m_objLink);
102  check = check && (m_datatype == other.m_datatype);
103  return(check);
104 };
105 
110 std::vector<mimmo::BaseManipulation*>
112  return(m_objLink);
113 }
114 
119 std::vector<PortID>
121  return(m_portLink);
122 }
123 
128 DataType
130  return(m_datatype);
131 }
132 
136 void
138  m_obuffer.seekg(0);
139 }
140 
144 void
146  m_objLink.clear();
147  m_portLink.clear();
148 }
149 
154 void
156  if (j < (int)m_objLink.size() && j >= 0){
157  m_objLink.erase(m_objLink.begin() + j);
158  m_portLink.erase(m_portLink.begin() + j);
159  }
160 }
161 
167 void
169  if (m_objLink.size() > 0){
170  writeBuffer();
171  mimmo::IBinaryStream input(m_obuffer.data(), m_obuffer.getSize());
172  cleanBuffer();
173  for (int j=0; j<(int)m_objLink.size(); j++){
174  if (m_objLink[j] != nullptr){
175  m_objLink[j]->setBufferIn(m_portLink[j], input);
176  m_objLink[j]->readBufferIn(m_portLink[j]);
177  m_objLink[j]->cleanBufferIn(m_portLink[j]);
178  }
179  }
180  }
181 };
182 
187  m_mandatory =false;
188  m_familym = 0;
189 };
190 
195 
199 PortIn::PortIn(const PortIn & other){
200  m_objLink = other.m_objLink;
201  m_ibuffer = other.m_ibuffer;
202  m_datatype = other.m_datatype;
203  m_mandatory = other.m_mandatory;
204  m_familym = other.m_familym;
205  return;
206 };
207 
211 bool PortIn::operator==(const PortIn & other){
212  bool check = true;
213  check = check && (m_objLink == other.m_objLink);
214  check = check && (m_datatype == other.m_datatype);
215  check = check && (m_mandatory = other.m_mandatory);
216  check = check && (m_familym = other.m_familym);
217  return(check);
218 };
219 
224 std::vector<mimmo::BaseManipulation*>
226  return(m_objLink);
227 }
228 
233 DataType
235  return(m_datatype);
236 }
237 
242 bool
244  return(m_mandatory);
245 }
246 
251 int
253  return(m_familym);
254 }
255 
259 void
261  m_objLink.clear();
262 }
263 
268 void
270  if (j < (int)m_objLink.size() && j >= 0){
271  m_objLink.erase(m_objLink.begin() + j);
272  }
273 }
274 
275 
279 void
281  m_ibuffer.seekg(0);
282 }
283 
284 }
std::vector< BaseManipulation * > m_objLink
Definition: InOut.hpp:205
DataType getDataType()
Definition: InOut.cpp:234
Class DataType defines the container and the type of data communicated by ports.
Definition: InOut.hpp:53
std::vector< BaseManipulation * > getLink()
Definition: InOut.cpp:111
std::string dataTAG
Definition: InOut.hpp:40
void clear()
Definition: InOut.cpp:260
std::string containerTAG
Definition: InOut.hpp:39
std::vector< BaseManipulation * > m_objLink
Definition: InOut.hpp:100
bool operator==(const PortIn &other)
Definition: InOut.cpp:211
bool operator==(const PortOut &other)
Definition: InOut.cpp:98
std::vector< PortID > m_portLink
Definition: InOut.hpp:101
virtual ~PortOut()
Definition: InOut.cpp:82
void cleanBuffer()
Definition: InOut.cpp:137
virtual ~DataType()
Definition: InOut.cpp:54
DataType getDataType()
Definition: InOut.cpp:129
void clear()
Definition: InOut.cpp:145
void exec()
Definition: InOut.cpp:168
DataType m_datatype
Definition: InOut.hpp:206
int getFamily()
Definition: InOut.cpp:252
bool operator==(const DataType &other)
Definition: InOut.cpp:60
PortIn is the abstract PIN base class dedicated to carry data to a target class from other ones (inpu...
Definition: InOut.hpp:201
PortOut is the abstract PIN base class dedicated to exchange data from a target class to other ones (...
Definition: InOut.hpp:96
virtual ~PortIn()
Definition: InOut.cpp:194
std::vector< PortID > getPortLink()
Definition: InOut.cpp:120
mimmo::OBinaryStream m_obuffer
Definition: InOut.hpp:99
std::vector< mimmo::BaseManipulation * > getLink()
Definition: InOut.cpp:225
DataType m_datatype
Definition: InOut.hpp:102
bool isMandatory()
Definition: InOut.cpp:243
containerTAG m_conType
Definition: InOut.hpp:55
mimmo custom derivation of bitpit IBinaryStream (see relative doc)
bool m_mandatory
Definition: InOut.hpp:207
mimmo::IBinaryStream m_ibuffer
Definition: InOut.hpp:204
void cleanBuffer()
Definition: InOut.cpp:280
int m_familym
Definition: InOut.hpp:208
dataTAG m_dataType
Definition: InOut.hpp:56