Changeset 175
- Timestamp:
- 04/14/11 10:46:37 (14 years ago)
- Location:
- XMLIO_V2/dev/dev_rv/src/xmlio
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/xmlio/main_server.cpp
r174 r175 14 14 comm::CMPIManager::Initialise(&argc, &argv); // < seulement en mode connecté 15 15 16 / *CTreeManager::ParseFile ("test/iodef_simple_test.xml");16 //CTreeManager::ParseFile ("test/iodef_simple_test.xml"); 17 17 18 StdOFStream ofs("data/data.bin");18 /*StdOFStream ofs("data/data.bin"); 19 19 CTreeManager::ToBinary(ofs); 20 ofs.close();*/ 20 ofs.close(); 21 22 StdOFStream ofs_("data/data_domain.bin"); 23 CTreeManager::DomainsToBinary(ofs_); 24 ofs_.close();*/ 21 25 22 26 StdIFStream ifs("data/data.bin"); … … 24 28 ifs.close(); 25 29 26 StdIFStream ifss("data/data .bin");27 CTreeManager:: FromBinary(ifss);30 StdIFStream ifss("data/data_domain.bin"); 31 CTreeManager::DomainsFromBinary(ifss); 28 32 ifss.close(); 29 33 -
XMLIO_V2/dev/dev_rv/src/xmlio/manager/tree_manager.cpp
r173 r175 157 157 } 158 158 } 159 160 //-------------------------------------------------------------- 161 162 void CTreeManager::DomainsToBinary (StdOStream & os) 163 { 164 StdString currentContextId = 165 CObjectFactory::GetCurrentContextId(); 166 std::vector<boost::shared_ptr<CContext> > def_vector = 167 CContext::GetContextGroup()->getChildList(); 168 169 const StdSize size = def_vector.size(); 170 const ENodeType cenum = CContext::GetType(); 171 const ENodeType genum = CContextGroup::GetType(); 172 const ENodeType denum = CDomain::GetType(); 173 174 os.write (reinterpret_cast<const char*>(&genum) , sizeof(ENodeType)); 175 os.write (reinterpret_cast<const char*>(&size) , sizeof(StdSize)); 176 177 for (StdSize i = 0; i < size; i++) 178 { 179 boost::shared_ptr<CContext> context = def_vector[i]; 180 CTreeManager::SetCurrentContextId(context->getId()); 181 const bool hid = context->hasId(); // Toujours vrai 182 183 os.write (reinterpret_cast<const char*>(&cenum), sizeof(ENodeType)); 184 os.write (reinterpret_cast<const char*>(&hid), sizeof(bool)); 185 186 if (hid) 187 { 188 const StdString & id = context->getId(); 189 const StdSize size = id.size(); 190 191 os.write (reinterpret_cast<const char*>(&size), sizeof(StdSize)); 192 os.write (id.data(), size * sizeof(char)); 193 } 194 195 std::vector<boost::shared_ptr<CDomain> > & alldomain = 196 CDomain::GetAllVectobject(context->getId()); 197 const StdSize alldomain_size = alldomain.size(); 198 199 os.write (reinterpret_cast<const char*>(&alldomain_size), sizeof(StdSize)); 200 201 for (StdSize j = 0; j < alldomain_size; j++) 202 { 203 boost::shared_ptr<CDomain> domain = alldomain[j]; 204 bool hid = domain->hasId(); 205 206 os.write (reinterpret_cast<const char*>(&denum), sizeof(ENodeType)); 207 os.write (reinterpret_cast<const char*>(&hid), sizeof(bool)); 208 209 if (hid) 210 { 211 const StdString & id = domain->getId(); 212 const StdSize idsize = id.size(); 213 214 os.write (reinterpret_cast<const char*>(&idsize), sizeof(StdSize)); 215 os.write (id.data(), idsize * sizeof(char)); 216 } 217 domain->toBinary(os); 218 219 } 220 } 221 CTreeManager::SetCurrentContextId(currentContextId); 222 223 } 224 225 void CTreeManager::DomainsFromBinary(StdIStream & is) 226 { 227 StdSize ctxtnb = 0; 228 ENodeType renum = Unknown; 229 230 boost::shared_ptr<CContextGroup> group_context = 231 CContext::GetContextGroup(); 232 std::vector<boost::shared_ptr<CContext> > def_vector = 233 CContext::GetContextGroup()->getChildList(); 234 235 const StdSize size = def_vector.size(); 236 237 is.read (reinterpret_cast<char*>(&renum), sizeof(StdSize)); 238 is.read (reinterpret_cast<char*>(&ctxtnb), sizeof(ENodeType)); 239 240 if (renum != CContextGroup::GetType()) 241 ERROR("CTreeManager::DomainsFromBinary(StdIStream & is)", 242 << "[ renum = " << renum << "] Bad type !"); 243 244 if (size != ctxtnb) 245 ERROR("CTreeManager::DomainsFromBinary(StdIStream & is)", 246 << "[ size = " << size << "] Bad context group size !"); 247 248 for (StdSize i = 0; i < ctxtnb; i++) 249 { 250 boost::shared_ptr<CContext> context = def_vector[i]; 251 bool hid = false; 252 is.read (reinterpret_cast<char*>(&renum), sizeof(ENodeType)); 253 is.read (reinterpret_cast<char*>(&hid), sizeof(bool)); 254 255 if (renum != CContext::GetType()) 256 ERROR("CTreeManager::DomainsFromBinary(StdIStream & is)", 257 << "[ renum = " << renum << "] Bad type !"); 258 259 if (hid) 260 { 261 StdSize size = 0; 262 is.read (reinterpret_cast<char*>(&size), sizeof(StdSize)); 263 StdString id(size, ' '); 264 is.read (const_cast<char *>(id.data()), size * sizeof(char)); 265 266 CTreeManager::SetCurrentContextId(id); 267 } 268 269 std::vector<boost::shared_ptr<CDomain> > & alldomain = 270 CDomain::GetAllVectobject(context->getId()); 271 const StdSize alldomain_size = alldomain.size(); 272 StdSize read_alldomain_size = 0; 273 274 is.read (reinterpret_cast<char*>(&read_alldomain_size), sizeof(StdSize)); 275 276 if (alldomain_size != read_alldomain_size) 277 ERROR("CTreeManager::DomainsFromBinary(StdIStream & is)", 278 << "[ read_alldomain_size = " << read_alldomain_size 279 << "] Bad domain group size !"); 280 281 for (StdSize j = 0; j < alldomain_size; j++) 282 { 283 boost::shared_ptr<CDomain> domain = alldomain[j]; 284 bool hid = domain->hasId(); 285 ENodeType rrenum = Unknown; 286 287 is.read (reinterpret_cast<char*>(&rrenum), sizeof(ENodeType)); 288 is.read (reinterpret_cast<char*>(&hid), sizeof(bool)); 289 290 if (rrenum != CDomain::GetType()) 291 ERROR("CTreeManager::DomainsFromBinary(StdIStream & is)", 292 << "[ rrenum = " << rrenum << "] Bad type !"); 293 294 if (hid) 295 { 296 StdSize size = 0; 297 is.read (reinterpret_cast<char*>(&size), sizeof(StdSize)); 298 StdString id(size, ' '); 299 is.read (const_cast<char *>(id.data()), size * sizeof(char)); 300 301 if (domain->getId().compare(id) != 0) 302 ERROR("CTreeManager::DomainsFromBinary(StdIStream & is)", 303 << "[ id = " << id << "] Bad id !"); 304 } 305 domain->fromBinary(is); 306 } 307 } 308 } 159 309 160 310 ///------------------------------------------------------------- -
XMLIO_V2/dev/dev_rv/src/xmlio/manager/tree_manager.hpp
r173 r175 37 37 static void ToBinary (StdOStream & os); 38 38 static void FromBinary(StdIStream & is); 39 40 static void DomainsToBinary (StdOStream & os); 41 static void DomainsFromBinary(StdIStream & is); 39 42 40 43 }; // class CTreeManager
Note: See TracChangeset
for help on using the changeset viewer.