- Timestamp:
- 02/25/07 04:14:33 (17 years ago)
- Files:
-
- branches/streaming-rework/src/bebob/bebob_avdevice.cpp (modified) (2 diffs)
- branches/streaming-rework/src/libutil/OptionContainer.cpp (modified) (3 diffs)
- branches/streaming-rework/src/libutil/OptionContainer.h (modified) (4 diffs)
- branches/streaming-rework/src/ser.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/streaming-rework/src/bebob/bebob_avdevice.cpp
r416 r418 1372 1372 i++; 1373 1373 } 1374 1375 result &= serializeOptions( basePath + "Options", ser ); 1374 1376 1375 1377 // result &= ser.write( basePath + "m_id", id ); … … 1416 1418 } 1417 1419 } 1418 1419 // result &= deser.read( basePath + "m_id", pDev->m_id ); 1420 1421 result &= deserializeOptions( basePath + "Options", deser, *pDev ); 1422 1420 1423 } 1421 1424 branches/streaming-rework/src/libutil/OptionContainer.cpp
r416 r418 28 28 29 29 #include "OptionContainer.h" 30 31 #include <iostream> 32 #include <sstream> 30 33 31 34 namespace FreebobUtil { … … 108 111 void OptionContainer::Option::set(int64_t v) { m_intValue = v; m_Type=EInt;} 109 112 void OptionContainer::Option::set(uint64_t v) { m_uintValue = v; m_Type=EUInt;} 113 114 bool 115 OptionContainer::Option::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const 116 { 117 bool result; 118 result = ser.write( basePath + "m_Name", Glib::ustring(m_Name) ); 119 result &= ser.write( basePath + "m_stringValue", Glib::ustring(m_stringValue) ); 120 result &= ser.write( basePath + "m_boolValue", m_boolValue ); 121 result &= ser.write( basePath + "m_doubleValue", m_doubleValue ); 122 result &= ser.write( basePath + "m_intValue", m_intValue ); 123 result &= ser.write( basePath + "m_uintValue", m_uintValue ); 124 result &= ser.write( basePath + "m_Type", m_Type ); 125 126 return result; 127 } 128 129 130 OptionContainer::Option 131 OptionContainer::Option::deserialize( Glib::ustring basePath, 132 Util::IODeserialize& deser ) 133 { 134 bool result; 135 Option op=Option(); 136 Glib::ustring tmpstr; 137 138 result = deser.read( basePath + "m_Name", tmpstr ); 139 op.m_Name = tmpstr; 140 result &= deser.read( basePath + "m_stringValue", tmpstr ); 141 op.m_stringValue = tmpstr; 142 result &= deser.read( basePath + "m_boolValue", op.m_boolValue ); 143 result &= deser.read( basePath + "m_doubleValue", op.m_doubleValue ); 144 result &= deser.read( basePath + "m_intValue", op.m_intValue ); 145 result &= deser.read( basePath + "m_uintValue", op.m_uintValue ); 146 result &= deser.read( basePath + "m_Type", op.m_Type ); 147 148 if(result) { 149 return op; 150 } else { 151 return Option(); 152 } 153 } 110 154 111 155 // ------------------------ … … 370 414 } 371 415 416 // serialization support 417 418 bool 419 OptionContainer::serializeOptions( Glib::ustring basePath, 420 Util::IOSerialize& ser) const 421 { 422 bool result = true; 423 int i = 0; 424 425 for ( OptionVector::const_iterator it = m_Options.begin(); 426 it != m_Options.end(); 427 ++it ) 428 { 429 const Option& pOption = *it; 430 431 std::ostringstream strstrm; 432 strstrm << basePath << "/" << "Option" << i; 433 result &= pOption.serialize( strstrm.str() + "/", ser ); 434 i++; 435 } 436 437 return result; 438 } 439 440 bool 441 OptionContainer::deserializeOptions( Glib::ustring basePath, 442 Util::IODeserialize& deser, 443 OptionContainer& container) 444 { 445 int i = 0; 446 bool bFinished = false; 447 bool result=true; 448 do { 449 std::ostringstream strstrm; 450 strstrm << basePath << "/" << "Option" << i; 451 452 Option pOption = Option::deserialize( strstrm.str() + "/", 453 deser ); 454 if ( pOption.getType() != Option::EInvalid ) { 455 result &= container.addOption(pOption); 456 i++; 457 } else { 458 bFinished = true; 459 } 460 } while ( !bFinished ); 461 462 return result; 463 } 464 465 372 466 } // end of namespace FreebobUtil branches/streaming-rework/src/libutil/OptionContainer.h
r416 r418 28 28 29 29 #include "../debugmodule/debugmodule.h" 30 #include "libutil/serialize.h" 30 31 31 32 #include <vector> … … 40 41 public: 41 42 enum EType { 42 EInvalid ,43 EString ,44 EBool ,45 EDouble ,46 EInt ,47 EUInt ,43 EInvalid = 0, 44 EString = 1, 45 EBool = 2, 46 EDouble = 3, 47 EInt = 4, 48 EUInt = 5, 48 49 }; 49 50 … … 73 74 int64_t getInt() {return m_intValue;}; 74 75 uint64_t getUInt() {return m_uintValue;}; 75 76 77 public: // serialization support 78 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 79 static Option deserialize( Glib::ustring basePath, 80 Util::IODeserialize& deser); 76 81 private: 77 82 std::string m_Name; … … 148 153 return(m_Options.end()); 149 154 } 150 155 156 protected: // serialization support 157 bool serializeOptions( Glib::ustring basePath, 158 Util::IOSerialize& ser) const; 159 static bool deserializeOptions( Glib::ustring basePath, 160 Util::IODeserialize& deser, 161 OptionContainer& container); 162 151 163 private: 152 164 int findOption(Option o); branches/streaming-rework/src/ser.cpp
r417 r418 7 7 8 8 static bool 9 serialize( const char* pFileName )9 serialize( const char* pFileName, int port ) 10 10 { 11 11 DeviceManager devMgr; 12 if (!devMgr.initialize( 0)) {12 if (!devMgr.initialize( port )) { 13 13 std::cerr << "could not init DeviceManager" << std::endl; 14 14 return false; … … 35 35 main( int argc, char** argv ) 36 36 { 37 if ( !serialize( FileName ) ) { 37 int port=0; 38 if (argc==2) { 39 port=atoi(argv[1]); 40 } 41 42 if ( !serialize( FileName, port ) ) { 38 43 std::cerr << "serializing failed" << std::endl; 39 44 return -1;