00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "secstwomsg.h"
00021
00022 using namespace freesecs;
00023 using namespace freesecs::secstwo;
00024
00025
00026
00027 data_item_t::data_item_t(const char * name)
00028 :_name(name)
00029 {}
00030
00031 data_item_t::data_item_t()
00032 {}
00033
00034 data_item_t::~data_item_t()
00035 {}
00036
00037 data_item_t::operator bool () const
00038 {
00039 return 0;
00040 }
00041 data_item_t::operator int8_t () const
00042 {
00043 return 0;
00044 }
00045 data_item_t::operator uint8_t () const
00046 {
00047 return 0;
00048 }
00049 data_item_t::operator int16_t () const
00050 {
00051 return 0;
00052 }
00053 data_item_t::operator uint16_t () const
00054 {
00055 return 0;
00056 }
00057 data_item_t::operator int32_t () const
00058 {
00059 return 0;
00060 }
00061 data_item_t::operator uint32_t () const
00062 {
00063 return 0;
00064 }
00065 data_item_t::operator int64_t () const
00066 {
00067 return 0;
00068 }
00069 data_item_t::operator uint64_t () const
00070 {
00071 return 0;
00072 }
00073
00074 data_item_t::operator float () const
00075 {
00076 return 0.0f;
00077 }
00078
00079 data_item_t::operator double () const
00080 {
00081 return 0.0f;
00082 }
00083
00084 data_item_t::operator std::string () const
00085 {
00086 std::string var = "";
00087 return var;
00088 }
00089
00090 data_item_t&
00091 data_item_t::operator[](uint32_t)
00092 {
00093 return *this;
00094 }
00095
00096 data_item_t&
00097 data_item_t::operator[](const char*)
00098 {
00099 return *this;
00100 }
00101
00102 const char *
00103 data_item_t::name()const
00104 {
00105 return _name.c_str();
00106 }
00107
00108 data_type_t
00109 data_item_t::type()const
00110 {
00111 return e_none_t;
00112 }
00113
00114 uint32_t
00115 data_item_t::size()const
00116 {
00117 return 0;
00118 }
00119 bool
00120 data_item_t::operator == (const bool&)const
00121 {
00122 return false;
00123 }
00124 bool
00125 data_item_t::operator == (const int8_t&)const
00126 {
00127 return false;
00128 }
00129 bool
00130 data_item_t::operator == (const uint8_t&)const
00131 {
00132 return false;
00133 }
00134 bool
00135 data_item_t::operator == (const int16_t&)const
00136 {
00137 return false;
00138 }
00139 bool
00140 data_item_t::operator == (const uint16_t&)const
00141 {
00142 return false;
00143 }
00144 bool
00145 data_item_t::operator == (const int32_t&)const
00146 {
00147 return false;
00148 }
00149 bool
00150 data_item_t::operator == (const uint32_t&)const
00151 {
00152 return false;
00153 }
00154 bool
00155 data_item_t::operator == (const int64_t&)const
00156 {
00157 return false;
00158 }
00159 bool
00160 data_item_t::operator == (const uint64_t&)const
00161 {
00162 return false;
00163 }
00164 bool
00165 data_item_t::operator == (const float&)const
00166 {
00167 return false;
00168 }
00169 bool
00170 data_item_t::operator == (const double&)const
00171 {
00172 return false;
00173 }
00174 bool
00175 data_item_t::operator == (const std::string&)const
00176 {
00177 return false;
00178 }
00179 bool
00180 data_item_t::operator != (const bool& v)const
00181 {
00182 return !this->operator == (v);
00183 }
00184 bool
00185 data_item_t::operator != (const int8_t &v)const
00186 {
00187 return !this->operator == (v);
00188 }
00189 bool
00190 data_item_t::operator != (const uint8_t &v)const
00191 {
00192 return !this->operator == (v);
00193 }
00194 bool
00195 data_item_t::operator != (const int16_t &v)const
00196 {
00197 return !this->operator == (v);
00198 }
00199 bool
00200 data_item_t::operator != (const uint16_t &v)const
00201 {
00202 return !this->operator == (v);
00203 }
00204 bool
00205 data_item_t::operator != (const int32_t &v)const
00206 {
00207 return !this->operator == (v);
00208 }
00209 bool
00210 data_item_t::operator != (const uint32_t &v)const
00211 {
00212 return !this->operator == (v);
00213 }
00214 bool
00215 data_item_t::operator != (const int64_t &v)const
00216 {
00217 return !this->operator == (v);
00218 }
00219 bool
00220 data_item_t::operator != (const uint64_t &v)const
00221 {
00222 return !this->operator == (v);
00223 }
00224 bool
00225 data_item_t::operator != (const float &v)const
00226 {
00227 return !this->operator == (v);
00228 }
00229 bool
00230 data_item_t::operator != (const double &v)const
00231 {
00232 return !this->operator == (v);
00233 }
00234 bool
00235 data_item_t::operator != (const std::string &v)const
00236 {
00237 return !this->operator == (v);
00238 }
00239 bool
00240 data_item_t::operator == (const data_item_t& other)const
00241 {
00242 return match(other);
00243 }
00244 bool
00245 data_item_t::operator != (const data_item_t& it)const
00246 {
00247 return !this->operator==(it);
00248 }
00249
00250 bool
00251 data_item_t::match(const data_item_t&, match_t match)const
00252 {
00253 return false;
00254 }
00255
00256 data_item_t&
00257 data_item_t::operator = (const bool&)
00258 {
00259 return *this;
00260 }
00261 data_item_t&
00262 data_item_t::operator = (const uint8_t&)
00263 {
00264 return *this;
00265 }
00266 data_item_t&
00267 data_item_t::operator = (const int8_t&)
00268 {
00269 return *this;
00270 }
00271 data_item_t&
00272 data_item_t::operator = (const uint16_t&)
00273 {
00274 return *this;
00275 }
00276 data_item_t&
00277 data_item_t::operator = (const int16_t&)
00278 {
00279 return *this;
00280 }
00281 data_item_t&
00282 data_item_t::operator = (const uint32_t&)
00283 {
00284 return *this;
00285 }
00286 data_item_t&
00287 data_item_t::operator = (const int32_t&)
00288 {
00289 return *this;
00290 }
00291 data_item_t&
00292 data_item_t::operator = (const uint64_t&)
00293 {
00294 return *this;
00295 }
00296 data_item_t&
00297 data_item_t::operator = (const int64_t&)
00298 {
00299 return *this;
00300 }
00301 data_item_t&
00302 data_item_t::operator = (const float&)
00303 {
00304 return *this;
00305 }
00306 data_item_t&
00307 data_item_t::operator = (const double&)
00308 {
00309 return *this;
00310 }
00311 data_item_t&
00312 data_item_t::operator = (const char *)
00313 {
00314 return *this;
00315 }
00316 data_item_t&
00317 data_item_t::operator = (const std::string&)
00318 {
00319 return *this;
00320 }
00321 data_item_t&
00322 data_item_t::operator += (const pdata_item_t&)
00323 {
00324 return *this;
00325 }
00326 data_item_t&
00327 data_item_t::operator += (const bool&)
00328 {
00329 return *this;
00330 }
00331 data_item_t&
00332 data_item_t::operator += (const uint8_t&)
00333 {
00334 return *this;
00335 }
00336 data_item_t&
00337 data_item_t::operator += (const int8_t&)
00338 {
00339 return *this;
00340 }
00341 data_item_t&
00342 data_item_t::operator += (const uint16_t&)
00343 {
00344 return *this;
00345 }
00346 data_item_t&
00347 data_item_t::operator += (const int16_t&)
00348 {
00349 return *this;
00350 }
00351 data_item_t&
00352 data_item_t::operator += (const uint32_t&)
00353 {
00354 return *this;
00355 }
00356 data_item_t&
00357 data_item_t::operator += (const int32_t&)
00358 {
00359 return *this;
00360 }
00361 data_item_t&
00362 data_item_t::operator += (const uint64_t&)
00363 {
00364 return *this;
00365 }
00366 data_item_t&
00367 data_item_t::operator += (const int64_t&)
00368 {
00369 return *this;
00370 }
00371 data_item_t&
00372 data_item_t::operator += (const float&)
00373 {
00374 return *this;
00375 }
00376 data_item_t&
00377 data_item_t::operator += (const double&)
00378 {
00379 return *this;
00380 }
00381 data_item_t&
00382 data_item_t::operator += (const char *)
00383 {
00384 return *this;
00385 }
00386 data_item_t&
00387 data_item_t::operator += (const std::string&)
00388 {
00389 return *this;
00390 }
00391 int
00392 data_item_t::copy_data(const data_item_t&)
00393 {
00394 return -1;
00395 }
00396 std::ostream & freesecs::secstwo::operator << (std::ostream &os, pdata_item_t it)
00397 {
00398 it->print(os);
00399 return os;
00400 };
00401
00402 msg_t::msg_t( const char *n,
00403 unsigned short s,
00404 unsigned short f)
00405 :name(n),stream(s),function(f)
00406 ,wbit(0),sysbytes(0),_pitem(NULL)
00407 {}
00408
00409 data_item_t&
00410 msg_t::operator[](uint32_t ix)
00411 {
00412 if(!ix)
00413 {
00414 return *_pitem.get();
00415 }
00416
00417 return _pitem->operator[](ix);
00418 }
00419 data_item_t&
00420 msg_t::operator[](const char* name)
00421 {
00422 if(0 == strcmp(name, _pitem->name()))
00423 {
00424 return *_pitem.get();
00425 }
00426
00427 return _pitem->operator[](name);
00428 }
00429 void
00430 msg_t::print(std::ostream& os, const char *prefix)const
00431 {
00432 if(prefix)
00433 {
00434 os << prefix;
00435 }
00436
00437 os << "S" << stream << "F" << function << " \'" << name << "\' " << "wbit=" << (int)wbit << " sysbytes=" << sysbytes << std::endl;
00438
00439 if(_pitem.get())
00440 {
00441 _pitem->print(os, prefix);
00442 }
00443 }
00444
00445 bool
00446 msg_t::match(const msg_t& other, match_t match)const
00447 {
00448 if( stream != other.stream
00449 || function != other.function)
00450 {
00451 return false;
00452 }
00453
00454 if( (!_pitem.get() && other._pitem.get())
00455 || (_pitem.get() && !other._pitem.get()))
00456 {
00457 return false;
00458 }
00459
00460 return _pitem->match(*other._pitem, match);
00461 }
00462
00463 bool
00464 msg_t::operator == (const msg_t& other)const
00465 {
00466 return match(other);
00467 }
00468
00469 bool
00470 msg_t::operator != (const msg_t& other)const
00471 {
00472 return !(*this == other);
00473 }
00474
00475 pmsg_t
00476 msg_t::clone() const
00477 {
00478 pmsg_t pmsg = new msg_t(name.c_str(), stream, function);
00479 pmsg->wbit = wbit;
00480 pmsg->sysbytes = sysbytes;
00481 if(_pitem.get())
00482 {
00483 pmsg->_pitem = _pitem->clone();
00484 }
00485 return pmsg;
00486 }
00487
00488 void
00489 msg_t::clear_data()
00490 {
00491 if(_pitem.get())_pitem->clear_data();
00492 }
00493
00494 int
00495 msg_t::copy_data(const msg_t &o)
00496 {
00497 if(!_pitem.get() || ! o._pitem.get()) return -1;
00498
00499 return _pitem->copy_data(*o._pitem.get());
00500 }
00501
00502 std::ostream &
00503 operator << (std::ostream &os, pmsg_t pmsg)
00504 {
00505 if(pmsg.get())
00506 {
00507 pmsg->print(os);
00508 }
00509
00510 return os;
00511 }
00512
00513