Changeset 172 for XMLIO_V2/dev/dev_rv/src/xmlio/group_template_impl.hpp
- Timestamp:
- 04/12/11 16:54:20 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/xmlio/group_template_impl.hpp
r168 r172 25 25 CGroupTemplate<U, V, W>::~CGroupTemplate(void) 26 26 { /* Ne rien faire de plus */ } 27 28 ///-------------------------------------------------------------- 29 30 template <class U, class V, class W> 31 void CGroupTemplate<U, V, W>::toBinary(StdOStream & os) const 32 { 33 SuperClass::toBinary(os); 34 35 const StdSize grpnb = this->groupList.size(); 36 const StdSize chdnb = this->childList.size(); 37 tree::ENodeType cenum = U::GetType(); 38 tree::ENodeType genum = V::GetType(); 39 40 os.write (reinterpret_cast<const char*>(&grpnb) , sizeof(StdSize)); 41 os.write (reinterpret_cast<const char*>(&chdnb) , sizeof(StdSize)); 42 43 typename std::vector<boost::shared_ptr<V> >::const_iterator 44 itg = this->groupList.begin(), endg = this->groupList.end(); 45 typename std::vector<boost::shared_ptr<U> >::const_iterator 46 itc = this->childList.begin(), endc = this->childList.end(); 47 48 for (; itg != endg; itg++) 49 { 50 boost::shared_ptr<V> group = *itg; 51 bool hid = group->hasId(); 52 53 os.write (reinterpret_cast<const char*>(&genum), sizeof(tree::ENodeType)); 54 os.write (reinterpret_cast<const char*>(&hid), sizeof(bool)); 55 56 if (hid) 57 { 58 const StdString & id = group->getId(); 59 const StdSize size = id.size(); 60 61 os.write (reinterpret_cast<const char*>(&size), sizeof(StdSize)); 62 os.write (id.data(), size * sizeof(char)); 63 } 64 group->toBinary(os); 65 } 66 67 for (; itc != endc; itc++) 68 { 69 boost::shared_ptr<U> child = *itc; 70 bool hid = child->hasId(); 71 72 os.write (reinterpret_cast<const char*>(&cenum), sizeof(tree::ENodeType)); 73 os.write (reinterpret_cast<const char*>(&hid), sizeof(bool)); 74 75 if (hid) 76 { 77 const StdString & id = child->getId(); 78 const StdSize size = id.size(); 79 80 os.write (reinterpret_cast<const char*>(&size), sizeof(StdSize)); 81 os.write (id.data(), size * sizeof(char)); 82 } 83 child->toBinary(os); 84 } 85 86 } 87 88 template <class U, class V, class W> 89 void CGroupTemplate<U, V, W>::fromBinary(StdIStream & is) 90 { 91 SuperClass::fromBinary(is); 92 93 boost::shared_ptr<V> group_ptr = (this->hasId()) 94 ? CObjectFactory::GetObject<V>(this->getId()) 95 : CObjectFactory::GetObject(boost::polymorphic_downcast<V*>(this)); 96 97 StdSize grpnb = 0; 98 StdSize chdnb = 0; 99 tree::ENodeType renum = Unknown; 100 101 is.read (reinterpret_cast<char*>(&grpnb), sizeof(StdSize)); 102 is.read (reinterpret_cast<char*>(&chdnb), sizeof(StdSize)); 103 104 for (StdSize i = 0; i < grpnb; i++) 105 { 106 bool hid = false; 107 is.read (reinterpret_cast<char*>(&renum), sizeof(tree::ENodeType)); 108 is.read (reinterpret_cast<char*>(&hid), sizeof(bool)); 109 110 if (renum != V::GetType()) 111 ERROR("CGroupTemplate<U, V, W>::fromBinary(StdIStream & is)", 112 << "[ renum = " << renum << "] Bad type !"); 113 114 if (hid) 115 { 116 StdSize size = 0; 117 is.read (reinterpret_cast<char*>(&size), sizeof(StdSize)); 118 StdString id(size, ' '); 119 is.read (const_cast<char *>(id.data()), size * sizeof(char)); 120 CGroupFactory::CreateGroup(group_ptr, id)->fromBinary(is); 121 } 122 else 123 { 124 CGroupFactory::CreateGroup(group_ptr)->fromBinary(is); 125 } 126 } 127 128 for (StdSize j = 0; j < chdnb; j++) 129 { 130 bool hid = false; 131 is.read (reinterpret_cast<char*>(&renum), sizeof(tree::ENodeType)); 132 is.read (reinterpret_cast<char*>(&hid), sizeof(bool)); 133 134 if (renum != U::GetType()) 135 ERROR("CGroupTemplate<U, V, W>::fromBinary(StdIStream & is)", 136 << "[ renum = " << renum << "] Bad type !"); 137 138 if (hid) 139 { 140 StdSize size = 0; 141 is.read (reinterpret_cast<char*>(&size), sizeof(StdSize)); 142 StdString id(size, ' '); 143 is.read (const_cast<char *>(id.data()), size * sizeof(char)); 144 CGroupFactory::CreateChild(group_ptr, id)->fromBinary(is); 145 } 146 else 147 { 148 CGroupFactory::CreateChild(group_ptr)->fromBinary(is); 149 } 150 } 151 } 152 153 //-------------------------------------------------------------- 27 154 28 155 template <class U, class V, class W> … … 31 158 StdOStringStream oss; 32 159 StdString name = (this->getId().compare(V::GetDefName()) != 0) 33 ? V::GetName() 34 : V::GetDefName(); 160 ? V::GetName() : V::GetDefName(); 35 161 36 162 oss << "< " << name << " "; … … 75 201 } 76 202 203 //--------------------------------------------------------------- 204 77 205 template <class U, class V, class W> 78 206 StdString CGroupTemplate<U, V, W>::GetName(void) … … 86 214 return (U::GetName().append("_definition")); 87 215 } 216 217 //--------------------------------------------------------------- 88 218 89 219 template <class U, class V, class W> … … 94 224 } 95 225 226 //--------------------------------------------------------------- 227 96 228 template <class U, class V, class W> 97 229 const xios_map<StdString, boost::shared_ptr<V> >& … … 101 233 } 102 234 235 //--------------------------------------------------------------- 236 103 237 template <class U, class V, class W> 104 238 bool CGroupTemplate<U, V, W>::hasChild(void) const … … 107 241 } 108 242 243 //--------------------------------------------------------------- 244 109 245 template <class U, class V, class W> 110 246 void CGroupTemplate<U, V, W>::parse(xml::CXMLNode & node) … … 112 248 this->parse(node, true); 113 249 } 250 251 //--------------------------------------------------------------- 114 252 115 253 template <class U, class V, class W> … … 138 276 } 139 277 278 //--------------------------------------------------------------- 279 140 280 template <class U, class V, class W> 141 281 void CGroupTemplate<U, V, W>::getAllChildren(std::vector<boost::shared_ptr<U> > & allc) const … … 152 292 } 153 293 294 //--------------------------------------------------------------- 295 154 296 template <class U, class V, class W> 155 297 std::vector<boost::shared_ptr<U> > CGroupTemplate<U, V, W>::getAllChildren(void) const … … 160 302 } 161 303 304 //--------------------------------------------------------------- 305 162 306 template <class U, class V, class W> 163 307 void CGroupTemplate<U, V, W>::solveRefInheritance(void) 164 308 { /* Ne rien faire de plus */ } 165 309 310 ///-------------------------------------------------------------- 311 166 312 } // namespace xmlioserver 167 313
Note: See TracChangeset
for help on using the changeset viewer.