Changeset 173 for XMLIO_V2/dev/dev_rv/src/xmlio/node/context.cpp
- Timestamp:
- 04/13/11 15:15:12 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/src/xmlio/node/context.cpp
r168 r173 1 1 #include "context.hpp" 2 3 #include "tree_manager.hpp" 2 4 3 5 #include "attribute_template_impl.hpp" … … 64 66 << " ce dernier ne sera pas pris en compte lors du traitement !"); } 65 67 66 67 68 68 #define DECLARE_NODE(Name_, name_) \ 69 if (name.compare(C##Name_##Definition::GetDefName()) == 0) \ 70 { CObjectFactory::CreateObject<C##Name_##Definition>(C##Name_##Definition::GetDefName()) -> parse(node); \ 69 71 continue; } 70 71 72 #define DECLARE_NODE_PAR(Name_, name_) 73 #include "node_type.conf" 72 74 73 75 DEBUG(<< "L'élément nommé \'" << name … … 93 95 94 96 out << "<? xml version=\"1.0\" ?>" << std::endl; 95 out << "< 97 out << "<" << xml::CXMLNode::GetRootName() << " >" << std::endl; 96 98 97 99 for (; it != end; it++) 98 100 { 99 boost::shared_ptr<CContext> context = *it; 100 CObjectFactory::SetCurrentContextId(context->getId()); 101 CGroupFactory::SetCurrentContextId(context->getId()); 101 boost::shared_ptr<CContext> context = *it; 102 CTreeManager::SetCurrentContextId(context->getId()); 102 103 out << *context << std::endl; 103 104 } 104 105 105 out << "</ " << xml::CXMLNode::GetRootName() << " >" << std::endl; 106 107 CObjectFactory::SetCurrentContextId(currentContextId); 108 CGroupFactory::SetCurrentContextId(currentContextId); 109 } 110 106 out << "</" << xml::CXMLNode::GetRootName() << " >" << std::endl; 107 CTreeManager::SetCurrentContextId(currentContextId); 108 } 109 110 //---------------------------------------------------------------- 111 112 void CContext::toBinary(StdOStream & os) const 113 { 114 SuperClass::toBinary(os); 115 116 #define DECLARE_NODE(Name_, name_) \ 117 { \ 118 ENodeType renum = C##Name_##Definition::GetType(); \ 119 bool val = CObjectFactory::HasObject<C##Name_##Definition> \ 120 (C##Name_##Definition::GetDefName()); \ 121 os.write (reinterpret_cast<const char*>(&renum), sizeof(ENodeType)); \ 122 os.write (reinterpret_cast<const char*>(&val), sizeof(bool)); \ 123 if (val) CObjectFactory::GetObject<C##Name_##Definition> \ 124 (C##Name_##Definition::GetDefName())->toBinary(os); \ 125 } 126 #define DECLARE_NODE_PAR(Name_, name_) 127 #include "node_type.conf" 128 } 129 130 //---------------------------------------------------------------- 131 132 void CContext::fromBinary(StdIStream & is) 133 { 134 SuperClass::fromBinary(is); 135 #define DECLARE_NODE(Name_, name_) \ 136 { \ 137 bool val = false; \ 138 ENodeType renum = Unknown; \ 139 is.read (reinterpret_cast<char*>(&renum), sizeof(ENodeType)); \ 140 is.read (reinterpret_cast<char*>(&val), sizeof(bool)); \ 141 if (renum != C##Name_##Definition::GetType()) \ 142 ERROR("CContext::fromBinary(StdIStream & is)", \ 143 << "[ renum = " << renum << "] Bad type !"); \ 144 if (val) CObjectFactory::CreateObject<C##Name_##Definition> \ 145 (C##Name_##Definition::GetDefName()) -> fromBinary(is); \ 146 } 147 #define DECLARE_NODE_PAR(Name_, name_) 148 #include "node_type.conf" 149 150 } 151 152 111 153 //---------------------------------------------------------------- 112 154 … … 114 156 { 115 157 StdOStringStream oss; 116 oss << "< 158 oss << "<" << CContext::GetName() 117 159 << " id=\"" << this->getId() << "\" " 118 160 << SuperClassAttribute::toString() << ">" << std::endl; … … 124 166 { 125 167 126 127 168 #define DECLARE_NODE(Name_, name_) \ 169 if (CObjectFactory::HasObject<C##Name_##Definition>(C##Name_##Definition::GetDefName())) \ 128 170 oss << *CObjectFactory::GetObject<C##Name_##Definition>(C##Name_##Definition::GetDefName()) << std::endl; 129 130 131 132 } 133 134 oss << "</ 171 #define DECLARE_NODE_PAR(Name_, name_) 172 #include "node_type.conf" 173 174 } 175 176 oss << "</" << CContext::GetName() << " >"; 135 177 136 178 return (oss.str()); … … 141 183 void CContext::solveDescInheritance(const CAttributeMap * const UNUSED(parent)) 142 184 { 143 144 185 #define DECLARE_NODE(Name_, name_) \ 186 if (CObjectFactory::HasObject<C##Name_##Definition>(C##Name_##Definition::GetDefName())) \ 145 187 CObjectFactory::GetObject<C##Name_##Definition>(C##Name_##Definition::GetDefName())->solveDescInheritance(); 146 147 188 #define DECLARE_NODE_PAR(Name_, name_) 189 #include "node_type.conf" 148 190 } 149 191 … … 152 194 bool CContext::hasChild(void) const 153 195 { 154 return ( false ||155 156 157 158 196 return ( 197 #define DECLARE_NODE(Name_, name_) \ 198 CObjectFactory::HasObject<C##Name_##Definition> (C##Name_##Definition::GetDefName()) || 199 #define DECLARE_NODE_PAR(Name_, name_) 200 #include "node_type.conf" 159 201 false); 160 202 } 161 203 162 204 //----------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.