Changeset 168 for XMLIO_V2/dev/dev_rv
- Timestamp:
- 04/07/11 15:04:00 (13 years ago)
- Location:
- XMLIO_V2/dev/dev_rv
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/Makefile.wk
r158 r168 15 15 VTK = no 16 16 GUI = no 17 NPROC = 217 NPROC = 1 18 18 CSUITE = gnu 19 19 PFORME = fedora-wk -
XMLIO_V2/dev/dev_rv/src/xmlio/array.hpp
r152 r168 39 39 /// Flux /// 40 40 template <typename U, StdSize V, typename W> 41 friend StdOStream & operator << (StdOStream & os,42 41 friend StdOStream & operator << 42 (StdOStream & os, const CArray<U, V, W> & array); 43 43 44 44 template <typename U, StdSize V, typename W> 45 friend StdIStream & operator >> (StdIStream & is,46 45 friend StdIStream & operator >> 46 (StdIStream & is, CArray<U, V, W> & array); 47 47 48 48 public: -
XMLIO_V2/dev/dev_rv/src/xmlio/declare_group.hpp
r152 r168 12 12 typedef type##Group RelGroup; \ 13 13 typedef type##Attributes RelAttributes; \ 14 \ 14 15 type##Group(void) \ 15 16 : CGroupTemplate<RelChild, RelGroup, RelAttributes> () \ … … 18 19 : CGroupTemplate<RelChild, RelGroup, RelAttributes> (_id) \ 19 20 { /* Ne rien faire de plus */ } \ 21 \ 22 static ENodeType GetType(void) \ 23 { return static_cast<ENodeType>(RelChild::GetType()+1); } \ 24 \ 20 25 virtual ~type##Group(void) \ 21 26 { /* Ne rien faire de plus */ } \ -
XMLIO_V2/dev/dev_rv/src/xmlio/group_template.hpp
r152 r168 41 41 virtual void parse(xml::CXMLNode & node); 42 42 inline void parse(xml::CXMLNode & node, bool withAttr); 43 43 44 44 /// Test /// 45 45 virtual bool hasChild(void) const; -
XMLIO_V2/dev/dev_rv/src/xmlio/group_template_impl.hpp
r152 r168 112 112 this->parse(node, true); 113 113 } 114 114 115 115 template <class U, class V, class W> 116 116 void CGroupTemplate<U, V, W>::solveDescInheritance(const CAttributeMap * const parent) -
XMLIO_V2/dev/dev_rv/src/xmlio/main_server.cpp
r158 r168 1 1 // XmlIOServer 2 //#include <boost/type_traits/is_convertible.hpp>3 //template< typename From, typename To > struct is_convertible : ::boost::integral_constant<bool,(::boost::detail::is_convertible_impl_dispatch<From,To> ::value)>;4 /*5 namespace boost6 {7 template< typename From, typename To > struct is_convertible ;8 }9 */10 2 #include "xmlioserver.hpp" 11 3 4 #include "attribute_template_impl.hpp" 5 #include "group_template_impl.hpp" 6 12 7 #include "fake.hpp" 13 #include "attribute_template_impl.hpp"14 #include "nc4_data_output.hpp"15 8 16 9 // Point d'entrée du programme principal … … 20 13 { 21 14 comm::CMPIManager::Initialise(&argc, &argv); // < seulement en mode connecté 22 CXIOSManager::Initialise(CXIOSManager::CLIENT, &argc, &argv); 15 16 // Création d'un contexte 17 boost::shared_ptr<CContext> contxt = CTreeManager::CreateContext("mon_context"); 18 19 20 boost::shared_ptr<CGridGroup> grid_def = 21 CObjectFactory::GetObject<CGridGroup>(StdString("grid_definition")); 22 boost::shared_ptr<CAxisGroup> axis_def = 23 CObjectFactory::GetObject<CAxisGroup>(StdString("axis_definition")); 24 boost::shared_ptr<CDomainGroup> domain_def = 25 CObjectFactory::GetObject<CDomainGroup>(StdString("domain_definition")); 26 27 // Ajout d'une grille, d'un axe et d'un domaine. 28 boost::shared_ptr<CGrid> grid = 29 CGroupFactory::CreateChild(grid_def , StdString("ma_grille")); 30 boost::shared_ptr<CAxis> axis = 31 CGroupFactory::CreateChild(axis_def , StdString("mon_axe")); 32 boost::shared_ptr<CDomain> domain = 33 CGroupFactory::CreateChild(domain_def, StdString("mon_domaine")); 34 35 // Définition des attributs de la grille. 36 grid->domain_ref.setValue(StdString("mon_domaine")); 37 grid->axis_ref.setValue(StdString("mon_axe")); 38 39 // Définition des attributs de l'axe. 40 ARRAY_CREATE(zvalue, double, 1, [100]); 41 42 axis->size.setValue(zvalue->num_elements()); 43 axis->zvalue.setValue(zvalue); 44 45 // Définition des attributs du domaine l'axe. 46 ARRAY_CREATE(latvalue, double, 1, [200]); 47 ARRAY_CREATE(lonvalue, double, 1, [200]); 48 49 domain->ni_glo.setValue(40); 50 domain->nj_glo.setValue(40); 51 52 domain->ibegin.setValue(1); 53 domain->ni.setValue(20); 54 domain->jbegin.setValue(1); 55 domain->nj.setValue(10); 56 57 domain->data_dim.setValue(2); 58 59 domain->lonvalue.setValue(lonvalue); 60 domain->latvalue.setValue(latvalue); 61 62 // Résolution 63 grid->solveReference(); 64 65 // Sortie de l'arborescence xml sous forme de fichier. 66 CTreeManager::PrintTreeToFile("data/def/test.xml"); 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 /*CXIOSManager::Initialise(CXIOSManager::CLIENT, &argc, &argv); 23 86 CXIOSManager::AddClient("nemo", 24 87 CMPIManager::GetCommSize(CMPIManager::GetCommWorld()), … … 26 89 &nemo_fake_entry); 27 90 CXIOSManager::RunClient(); 28 CXIOSManager::Finalize(); 91 CXIOSManager::Finalize();*/ 29 92 30 93 comm::CMPIManager::Finalize(); // < seulement en mode connecté 31 94 32 95 //CXIOSManager::AddClient("orchidee", 1, 1, &orchidee_fake_entry); 33 96 //CXIOSManager::AddClient("lmdz" , 2, 2, &lmdz_fake_entry); -
XMLIO_V2/dev/dev_rv/src/xmlio/manager/tree_manager.cpp
r152 r168 19 19 boost::shared_ptr<CContext> CTreeManager::CreateContext(const StdString & id) 20 20 { 21 boost::shared_ptr<CContextGroup> group_context = 22 CContext::GetContextGroup(); 21 boost::shared_ptr<CContextGroup> group_context = CContext::GetContextGroup(); 23 22 CTreeManager::SetCurrentContextId(id); 23 24 24 boost::shared_ptr<tree::CContext> context = 25 25 CObjectFactory::CreateObject<tree::CContext>(id); -
XMLIO_V2/dev/dev_rv/src/xmlio/node/axis.cpp
r152 r168 5 5 #include "group_template_impl.hpp" 6 6 7 namespace xmlioserver 8 { 9 namespace tree 7 namespace xmlioserver { 8 namespace tree { 9 10 /// ////////////////////// Définitions ////////////////////// /// 11 12 CAxis::CAxis(void) 13 : CObjectTemplate<CAxis>() 14 , CAxisAttributes(), isChecked(false), relFiles() 15 { /* Ne rien faire de plus */ } 16 17 CAxis::CAxis(const StdString & id) 18 : CObjectTemplate<CAxis>(id) 19 , CAxisAttributes(), isChecked(false), relFiles() 20 { /* Ne rien faire de plus */ } 21 22 CAxis::~CAxis(void) 23 { /* Ne rien faire de plus */ } 24 25 ///--------------------------------------------------------------- 26 27 const std::set<StdString> & CAxis::getRelFiles(void) const 10 28 { 11 /// ////////////////////// Définitions ////////////////////// /// 29 return (this->relFiles); 30 } 12 31 13 CAxis::CAxis(void)14 : CObjectTemplate<CAxis>()15 , CAxisAttributes(), isChecked(false), relFiles()16 { /* Ne rien faire de plus */}32 bool CAxis::IsWritten(const StdString & filename) const 33 { 34 return (this->relFiles.find(filename) != this->relFiles.end()); 35 } 17 36 18 CAxis::CAxis(const StdString & id)19 : CObjectTemplate<CAxis>(id)20 , CAxisAttributes(), isChecked(false), relFiles()21 { /* Ne rien faire de plus */}37 void CAxis::addRelFile(const StdString & filename) 38 { 39 this->relFiles.insert(filename); 40 } 22 41 23 CAxis::~CAxis(void) 24 { /* Ne rien faire de plus */ } 42 //---------------------------------------------------------------- 25 43 26 ///--------------------------------------------------------------- 44 StdString CAxis::GetName(void) { return (StdString("axis")); } 45 StdString CAxis::GetDefName(void){ return (CAxis::GetName()); } 46 ENodeType CAxis::GetType(void) { return (eAxis); } 27 47 28 const std::set<StdString> & CAxis::getRelFiles(void) const 29 { 30 return (this->relFiles); 31 } 48 //---------------------------------------------------------------- 32 49 33 bool CAxis::IsWritten(const StdString & filename) const 34 { 35 return (this->relFiles.find(filename) != this->relFiles.end()); 36 } 50 void CAxis::checkAttributes(void) 51 { 52 if (this->isChecked) return; 53 StdSize size = this->size.getValue(); 54 StdSize true_size = zvalue.getValue()->num_elements(); 55 if (size != true_size) 56 ERROR("CAxis::checkAttributes(void)", 57 << "Le tableau \'zvalue\' a une taille différente de celle indiquée dans l'attribut \'size\'") 37 58 38 void CAxis::addRelFile(const StdString & filename) 39 { 40 this->relFiles.insert(filename); 41 } 59 this->isChecked = true; 60 } 42 61 43 //---------------------------------------------------------------- 44 StdString CAxis::GetName(void) { return (StdString("axis")); } 45 StdString CAxis::GetDefName(void){ return (CAxis::GetName()); } 62 ///--------------------------------------------------------------- 46 63 47 void CAxis::checkAttributes(void) 48 { 49 if (this->isChecked) return; 50 StdSize size = this->size.getValue(); 51 StdSize true_size = zvalue.getValue()->num_elements(); 52 if (size != true_size) 53 ERROR("CAxis::checkAttributes(void)", 54 << "Le tableau \'zvalue\' a une taille différente de celle indiquée dans l'attribut \'size\'") 55 56 this->isChecked = true; 57 } 58 59 ///--------------------------------------------------------------- 60 61 } // namespace tree 64 } // namespace tree 62 65 } // namespace xmlioserver -
XMLIO_V2/dev/dev_rv/src/xmlio/node/axis.hpp
r157 r168 8 8 #include "declare_group.hpp" 9 9 10 namespace xmlioserver 11 { 12 namespace tree 10 namespace xmlioserver { 11 namespace tree { 12 13 /// ////////////////////// Déclarations ////////////////////// /// 14 15 class CAxisGroup; 16 class CAxisAttributes; 17 class CAxis; 18 19 ///-------------------------------------------------------------- 20 21 // Declare/Define CAxisAttribute 22 BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis) 23 #include "axis_attribute.conf" 24 END_DECLARE_ATTRIBUTE_MAP(CAxis) 25 26 ///-------------------------------------------------------------- 27 28 class CAxis 29 : public CObjectTemplate<CAxis> 30 , public CAxisAttributes 13 31 { 14 /// ////////////////////// Déclarations ////////////////////// /// 32 /// typedef /// 33 typedef CObjectTemplate<CAxis> SuperClass; 34 typedef CAxisAttributes SuperClassAttribute; 15 35 16 class CAxisGroup; 17 class CAxisAttributes; 18 class CAxis; 36 public : 19 37 20 ///-------------------------------------------------------------- 38 typedef CAxisAttributes RelAttributes; 39 typedef CAxisGroup RelGroup; 21 40 22 // Declare/Define CAxisAttribute 23 BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis) 24 #include "axis_attribute.conf" 25 END_DECLARE_ATTRIBUTE_MAP(CAxis) 41 /// Constructeurs /// 42 CAxis(void); 43 explicit CAxis(const StdString & id); 44 CAxis(const CAxis & axis); // Not implemented yet. 45 CAxis(const CAxis * const axis); // Not implemented yet. 26 46 27 ///-------------------------------------------------------------- 47 /// Accesseurs /// 48 const std::set<StdString> & getRelFiles(void) const; 28 49 29 class CAxis 30 : public CObjectTemplate<CAxis> 31 , public CAxisAttributes 32 { 33 /// typedef /// 34 typedef CObjectTemplate<CAxis> SuperClass; 35 typedef CAxisAttributes SuperClassAttribute; 50 /// Test /// 51 bool IsWritten(const StdString & filename) const; 36 52 37 public : 53 /// Mutateur /// 54 void addRelFile(const StdString & filename); 38 55 39 typedef CAxisAttributes RelAttributes;40 typedef CAxisGroup RelGroup;56 /// Vérifications /// 57 void checkAttributes(void); 41 58 42 /// Constructeurs /// 43 CAxis(void); 44 explicit CAxis(const StdString & id); 45 CAxis(const CAxis & axis); // Not implemented yet. 46 CAxis(const CAxis * const axis); // Not implemented yet. 59 /// Destructeur /// 60 virtual ~CAxis(void); 47 61 48 /// Accesseurs /// 49 const std::set<StdString> & getRelFiles(void) const; 62 /// Accesseurs statiques /// 63 static StdString GetName(void); 64 static StdString GetDefName(void); 65 66 static ENodeType GetType(void); 50 67 51 /// Test /// 52 bool IsWritten(const StdString & filename) const; 68 private : 53 69 54 /// Mutateur /// 55 void addRelFile(const StdString & filename); 56 57 /// Vérifications /// 58 void checkAttributes(void); 59 60 /// Destructeur /// 61 virtual ~CAxis(void); 62 63 /// Accesseurs statiques /// 64 static StdString GetName(void); 65 static StdString GetDefName(void); 66 67 private : 68 69 bool isChecked; 70 std::set<StdString> relFiles; 70 bool isChecked; 71 std::set<StdString> relFiles; 71 72 72 73 73 74 }; // class CAxis 74 75 75 76 ///-------------------------------------------------------------- 76 77 77 78 78 // Declare/Define CAxisGroup and CAxisDefinition 79 DECLARE_GROUP(CAxis); 79 80 80 } // namespace tree 81 ///-------------------------------------------------------------- 82 83 } // namespace tree 81 84 } // namespace xmlioserver 82 85 -
XMLIO_V2/dev/dev_rv/src/xmlio/node/context.cpp
r157 r168 5 5 #include "group_template_impl.hpp" 6 6 7 namespace xmlioserver 8 { 9 namespace tree 7 namespace xmlioserver { 8 namespace tree { 9 10 /// ////////////////////// Définitions ////////////////////// /// 11 12 CContext::CContext(void) 13 : CObjectTemplate<CContext>(), CContextAttributes() 14 { /* Ne rien faire de plus */ } 15 16 CContext::CContext(const StdString & id) 17 : CObjectTemplate<CContext>(id), CContextAttributes() 18 { /* Ne rien faire de plus */ } 19 20 CContext::~CContext(void) 21 { /* Ne rien faire de plus */ } 22 23 //---------------------------------------------------------------- 24 25 StdString CContext::GetName(void) { return (StdString("context")); } 26 StdString CContext::GetDefName(void){ return (CContext::GetName()); } 27 ENodeType CContext::GetType(void) { return (eContext); } 28 29 //---------------------------------------------------------------- 30 31 boost::shared_ptr<CContextGroup> CContext::GetContextGroup(void) 32 { 33 static boost::shared_ptr<CContextGroup> group_context 34 (new CContextGroup(xml::CXMLNode::GetRootName())); 35 return (group_context); 36 } 37 38 //---------------------------------------------------------------- 39 40 void CContext::parse(xml::CXMLNode & node) 10 41 { 11 /// ////////////////////// Définitions ////////////////////// ///42 CContext::SuperClass::parse(node); 12 43 13 CContext::CContext(void) 14 : CObjectTemplate<CContext>(), CContextAttributes() 15 { /* Ne rien faire de plus */ } 44 // PARSING POUR GESTION DES ENFANTS 45 xml::THashAttributes attributes; 16 46 17 CContext::CContext(const StdString & id) 18 : CObjectTemplate<CContext>(id), CContextAttributes() 19 { /* Ne rien faire de plus */ } 47 if (node.getElementName().compare(CContext::GetName())) 48 DEBUG("Le noeud est mal nommé mais sera traité comme un contexte !"); 20 49 21 CContext::~CContext(void) 22 { /* Ne rien faire de plus */ } 50 if (!(node.goToChildElement())) 51 { 52 DEBUG("Le context ne contient pas d'enfant !"); 53 } 54 else 55 { 56 do { // Parcours des contextes pour traitement. 23 57 24 StdString CContext::GetName(void) { return (StdString("context")); } 25 StdString CContext::GetDefName(void){ return (CContext::GetName()); } 58 StdString name = node.getElementName(); 59 attributes.clear(); 60 attributes = node.getAttributes(); 26 61 27 boost::shared_ptr<CContextGroup> CContext::GetContextGroup(void) 28 { static boost::shared_ptr<CContextGroup> group_context 29 (new CContextGroup(xml::CXMLNode::GetRootName())); 30 return (group_context); } 62 if (attributes.end() != attributes.find("id")) 63 { DEBUG(<< "Le noeud de définition possÚde un identifiant," 64 << " ce dernier ne sera pas pris en compte lors du traitement !"); } 31 65 32 void CContext::parse(xml::CXMLNode & node) 66 #define DECLARE_NODE(Name_, name_) \ 67 if (name.compare(C##Name_##Definition::GetDefName()) == 0) \ 68 { CObjectFactory::CreateObject<C##Name_##Definition>(C##Name_##Definition::GetDefName()) -> parse(node); \ 69 continue; } 70 #define DECLARE_NODE_PAR(Name_, name_) 71 #include "node_type.conf" 72 73 DEBUG(<< "L'élément nommé \'" << name 74 << "\' dans le contexte \'" << CObjectFactory::GetCurrentContextId() 75 << "\' ne représente pas une définition !"); 76 77 } while (node.goToNextElement()); 78 79 node.goToParentElement(); // Retour au parent 80 } 81 } 82 83 //---------------------------------------------------------------- 84 85 void CContext::ShowTree(StdOStream & out) 86 { 87 StdString currentContextId = 88 CObjectFactory::GetCurrentContextId(); 89 std::vector<boost::shared_ptr<CContext> > def_vector = 90 CContext::GetContextGroup()->getChildList(); 91 std::vector<boost::shared_ptr<CContext> >::iterator 92 it = def_vector.begin(), end = def_vector.end(); 93 94 out << "<? xml version=\"1.0\" ?>" << std::endl; 95 out << "< " << xml::CXMLNode::GetRootName() << " >" << std::endl; 96 97 for (; it != end; it++) 33 98 { 34 CContext::SuperClass::parse(node); 99 boost::shared_ptr<CContext> context = *it; 100 CObjectFactory::SetCurrentContextId(context->getId()); 101 CGroupFactory::SetCurrentContextId(context->getId()); 102 out << *context << std::endl; 103 } 104 105 out << "</ " << xml::CXMLNode::GetRootName() << " >" << std::endl; 35 106 36 // PARSING POUR GESTION DES ENFANTS 37 xml::THashAttributes attributes; 107 CObjectFactory::SetCurrentContextId(currentContextId); 108 CGroupFactory::SetCurrentContextId(currentContextId); 109 } 38 110 39 if (node.getElementName().compare(CContext::GetName())) 40 DEBUG("Le noeud est mal nommé mais sera traité comme un contexte !"); 111 //---------------------------------------------------------------- 41 112 42 if (!(node.goToChildElement())) 43 { 44 DEBUG("Le context ne contient pas d'enfant !"); 45 } 46 else 47 { 48 do { // Parcours des contextes pour traitement. 113 StdString CContext::toString(void) const 114 { 115 StdOStringStream oss; 116 oss << "< " << CContext::GetName() 117 << " id=\"" << this->getId() << "\" " 118 << SuperClassAttribute::toString() << ">" << std::endl; 119 if (!this->hasChild()) 120 { 121 //oss << "<!-- No definition -->" << std::endl; // fait planter l'incrémentation 122 } 123 else 124 { 49 125 50 StdString name = node.getElementName(); 51 attributes.clear(); 52 attributes = node.getAttributes(); 126 #define DECLARE_NODE(Name_, name_) \ 127 if (CObjectFactory::HasObject<C##Name_##Definition>(C##Name_##Definition::GetDefName())) \ 128 oss << *CObjectFactory::GetObject<C##Name_##Definition>(C##Name_##Definition::GetDefName()) << std::endl; 129 #define DECLARE_NODE_PAR(Name_, name_) 130 #include "node_type.conf" 53 131 54 if (attributes.end() != attributes.find("id"))55 { DEBUG(<< "Le noeud de définition possÚde un identifiant,"56 << " ce dernier ne sera pas pris en compte lors du traitement !"); }57 58 #define DECLARE_NODE(Name_, name_) \59 if (name.compare(C##Name_##Definition::GetDefName()) == 0) \60 { CObjectFactory::CreateObject<C##Name_##Definition>(C##Name_##Definition::GetDefName()) -> parse(node); \61 continue; }62 #define DECLARE_NODE_PAR(Name_, name_)63 #include "node_type.conf"64 65 DEBUG(<< "L'élément nommé \'" << name66 << "\' dans le contexte \'" << CObjectFactory::GetCurrentContextId()67 << "\' ne représente pas une définition !");68 69 } while (node.goToNextElement());70 71 node.goToParentElement(); // Retour au parent72 }73 132 } 74 133 75 void CContext::ShowTree(StdOStream & out) 134 oss << "</ " << CContext::GetName() << " >"; 135 136 return (oss.str()); 137 } 138 139 //---------------------------------------------------------------- 140 141 void CContext::solveDescInheritance(const CAttributeMap * const UNUSED(parent)) 142 { 143 #define DECLARE_NODE(Name_, name_) \ 144 if (CObjectFactory::HasObject<C##Name_##Definition>(C##Name_##Definition::GetDefName())) \ 145 CObjectFactory::GetObject<C##Name_##Definition>(C##Name_##Definition::GetDefName())->solveDescInheritance(); 146 #define DECLARE_NODE_PAR(Name_, name_) 147 #include "node_type.conf" 148 } 149 150 //---------------------------------------------------------------- 151 152 bool CContext::hasChild(void) const 153 { 154 return (false || 155 #define DECLARE_NODE(Name_, name_) \ 156 CObjectFactory::HasObject<C##Name_##Definition> (C##Name_##Definition::GetDefName()) || 157 #define DECLARE_NODE_PAR(Name_, name_) 158 #include "node_type.conf" 159 false); 160 } 161 162 //---------------------------------------------------------------- 163 164 void CContext::solveFieldRefInheritance(void) 165 { 166 if (!this->hasId()) return; 167 std::vector<boost::shared_ptr<CField> > allField 168 = CObjectTemplate<CField>::GetAllVectobject(this->getId()); 169 std::vector<boost::shared_ptr<CField> >::iterator 170 it = allField.begin(), end = allField.end(); 171 172 for (; it != end; it++) 76 173 { 77 StdString currentContextId = 78 CObjectFactory::GetCurrentContextId(); 79 std::vector<boost::shared_ptr<CContext> > def_vector = 80 CContext::GetContextGroup()->getChildList(); 81 std::vector<boost::shared_ptr<CContext> >::iterator 82 it = def_vector.begin(), end = def_vector.end(); 174 boost::shared_ptr<CField> field = *it; 175 field->solveRefInheritance(); 176 } 177 } 83 178 84 out << "<? xml version=\"1.0\" ?>" << std::endl; 85 out << "< " << xml::CXMLNode::GetRootName() << " >" << std::endl; 86 87 for (; it != end; it++) 88 { 89 boost::shared_ptr<CContext> context = *it; 90 CObjectFactory::SetCurrentContextId(context->getId()); 91 CGroupFactory::SetCurrentContextId(context->getId()); 92 out << *context << std::endl; 93 } 94 95 out << "</ " << xml::CXMLNode::GetRootName() << " >" << std::endl; 179 ///--------------------------------------------------------------- 96 180 97 CObjectFactory::SetCurrentContextId(currentContextId); 98 CGroupFactory::SetCurrentContextId(currentContextId); 99 } 100 101 StdString CContext::toString(void) const 102 { 103 StdOStringStream oss; 104 oss << "< " << CContext::GetName() 105 << " id=\"" << this->getId() << "\" " 106 << SuperClassAttribute::toString() << ">" << std::endl; 107 if (!this->hasChild()) 108 { 109 //oss << "<!-- No definition -->" << std::endl; // fait planter l'incrémentation 110 } 111 else 112 { 113 114 #define DECLARE_NODE(Name_, name_) \ 115 if (CObjectFactory::HasObject<C##Name_##Definition>(C##Name_##Definition::GetDefName())) \ 116 oss << *CObjectFactory::GetObject<C##Name_##Definition>(C##Name_##Definition::GetDefName()) << std::endl; 117 #define DECLARE_NODE_PAR(Name_, name_) 118 #include "node_type.conf" 119 120 } 121 122 oss << "</ " << CContext::GetName() << " >"; 123 124 return (oss.str()); 125 } 126 127 void CContext::solveDescInheritance(const CAttributeMap * const UNUSED(parent)) 128 { 129 #define DECLARE_NODE(Name_, name_) \ 130 if (CObjectFactory::HasObject<C##Name_##Definition>(C##Name_##Definition::GetDefName())) \ 131 CObjectFactory::GetObject<C##Name_##Definition>(C##Name_##Definition::GetDefName())->solveDescInheritance(); 132 #define DECLARE_NODE_PAR(Name_, name_) 133 #include "node_type.conf" 134 } 135 136 bool CContext::hasChild(void) const 137 { 138 return (false || 139 #define DECLARE_NODE(Name_, name_) \ 140 CObjectFactory::HasObject<C##Name_##Definition> (C##Name_##Definition::GetDefName()) || 141 #define DECLARE_NODE_PAR(Name_, name_) 142 #include "node_type.conf" 143 false); 144 } 145 146 void CContext::solveFieldRefInheritance(void) 147 { 148 if (!this->hasId()) return; 149 std::vector<boost::shared_ptr<CField> > allField 150 = CObjectTemplate<CField>::GetAllVectobject(this->getId()); 151 std::vector<boost::shared_ptr<CField> >::iterator 152 it = allField.begin(), end = allField.end(); 153 154 for (; it != end; it++) 155 { 156 boost::shared_ptr<CField> field = *it; 157 field->solveRefInheritance(); 158 } 159 } 160 161 } // namespace tree 181 } // namespace tree 162 182 } // namespace xmlioserver -
XMLIO_V2/dev/dev_rv/src/xmlio/node/context.hpp
r157 r168 8 8 #include "declare_group.hpp" 9 9 10 namespace xmlioserver 11 { 12 namespace tree 10 namespace xmlioserver { 11 namespace tree { 12 13 /// ////////////////////// Déclarations ////////////////////// /// 14 class CContextGroup; 15 class CContextAttributes; 16 class CContext; 17 18 ///-------------------------------------------------------------- 19 20 // Declare/Define CFileAttribute 21 BEGIN_DECLARE_ATTRIBUTE_MAP(CContext) 22 #include "context_attribute.conf" 23 END_DECLARE_ATTRIBUTE_MAP(CContext) 24 25 ///-------------------------------------------------------------- 26 27 class CContext 28 : public CObjectTemplate<CContext> 29 , public CContextAttributes 13 30 { 14 /// ////////////////////// Déclarations ////////////////////// /// 15 class CContextGroup; 16 class CContextAttributes; 17 class CContext; 31 /// typedef /// 32 typedef CObjectTemplate<CContext> SuperClass; 33 typedef CContextAttributes SuperClassAttribute; 18 34 19 ///--------------------------------------------------------------35 public : 20 36 21 // Declare/Define CFileAttribute 22 BEGIN_DECLARE_ATTRIBUTE_MAP(CContext) 23 #include "context_attribute.conf" 24 END_DECLARE_ATTRIBUTE_MAP(CContext) 37 typedef CContextAttributes RelAttributes; 38 typedef CContext RelGroup; 25 39 26 ///--------------------------------------------------------------40 //--------------------------------------------------------- 27 41 28 class CContext 29 : public CObjectTemplate<CContext> 30 , public CContextAttributes 31 { 32 /// typedef /// 33 typedef CObjectTemplate<CContext> SuperClass; 34 typedef CContextAttributes SuperClassAttribute; 42 /// Constructeurs /// 43 CContext(void); 44 explicit CContext(const StdString & id); 45 CContext(const CContext & context); // Not implemented yet. 46 CContext(const CContext * const context); // Not implemented yet. 35 47 36 public : 48 /// Destructeur /// 49 virtual ~CContext(void); 37 50 38 typedef CContextAttributes RelAttributes; 39 typedef CContext RelGroup; 51 //--------------------------------------------------------- 40 52 41 //--------------------------------------------------------- 53 /// Accesseurs statiques /// 54 static StdString GetName(void); 55 static StdString GetDefName(void); 56 57 static ENodeType GetType(void); 42 58 43 /// Constructeurs /// 44 CContext(void); 45 explicit CContext(const StdString & id); 46 CContext(const CContext & context); // Not implemented yet. 47 CContext(const CContext * const context); // Not implemented yet. 59 static boost::shared_ptr<CContextGroup> GetContextGroup(void); 48 60 49 /// Destructeur /// 50 virtual ~CContext(void); 61 /// Traitements /// 62 virtual void solveDescInheritance(const CAttributeMap * const parent = 0); 63 void solveFieldRefInheritance(void); 51 64 52 //--------------------------------------------------------- 65 /// Autres méthodes statiques /// 66 static void ShowTree(StdOStream & out = std::clog); 53 67 54 /// Accesseurs statiques /// 55 static StdString GetName(void); 56 static StdString GetDefName(void); 68 /// Test /// 69 virtual bool hasChild(void) const; 57 70 58 static boost::shared_ptr<CContextGroup> GetContextGroup(void); 71 /// Autres /// 72 virtual void parse(xml::CXMLNode & node); 59 73 60 /// Traitements /// 61 virtual void solveDescInheritance(const CAttributeMap * const parent = 0); 62 void solveFieldRefInheritance(void); 74 virtual StdString toString(void) const; 63 75 64 /// Autres méthodes statiques /// 65 static void ShowTree(StdOStream & out = std::clog); 76 }; // class CContext 66 77 67 /// Test /// 68 virtual bool hasChild(void) const; 78 ///-------------------------------------------------------------- 69 79 70 /// Autres ///71 virtual void parse(xml::CXMLNode & node);80 // Declare/Define CContextGroup and CContextDefinition 81 DECLARE_GROUP(CContext); 72 82 73 virtual StdString toString(void) const;83 ///-------------------------------------------------------------- 74 84 75 }; // class CContext 76 77 ///-------------------------------------------------------------- 78 79 // Declare/Define CContextGroup and CContextDefinition 80 DECLARE_GROUP(CContext); 81 82 } // namespace tree 85 } // namespace tree 83 86 } // namespace xmlioserver 84 87 -
XMLIO_V2/dev/dev_rv/src/xmlio/node/domain.cpp
r152 r168 5 5 #include "group_template_impl.hpp" 6 6 7 namespace xmlioserver 8 { 9 namespace tree 10 { 11 /// ////////////////////// Définitions ////////////////////// /// 12 13 CDomain::CDomain(void) 14 : CObjectTemplate<CDomain>(), CDomainAttributes() 15 , isChecked(false), local_mask(new CMask()), relFiles() 16 { /* Ne rien faire de plus */ } 17 18 CDomain::CDomain(const StdString & id) 19 : CObjectTemplate<CDomain>(id), CDomainAttributes() 20 , isChecked(false), local_mask(new CMask()), relFiles() 21 { /* Ne rien faire de plus */ } 22 23 CDomain::~CDomain(void) 24 { /* Ne rien faire de plus */ } 25 26 ///--------------------------------------------------------------- 27 28 const std::set<StdString> & CDomain::getRelFiles(void) const 29 { 30 return (this->relFiles); 31 } 32 33 bool CDomain::IsWritten(const StdString & filename) const 34 { 35 return (this->relFiles.find(filename) != this->relFiles.end()); 36 } 37 38 void CDomain::addRelFile(const StdString & filename) 39 { 40 this->relFiles.insert(filename); 41 } 42 43 //---------------------------------------------------------------- 44 45 StdString CDomain::GetName(void) { return (StdString("domain")); } 46 StdString CDomain::GetDefName(void){ return (CDomain::GetName()); } 47 48 //---------------------------------------------------------------- 49 50 void CDomain::checkGlobalDomain(void) 51 { 52 if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || 53 (ni_glo.isEmpty() || nj_glo.getValue() <= 0 )) 7 namespace xmlioserver { 8 namespace tree { 9 10 /// ////////////////////// Définitions ////////////////////// /// 11 12 CDomain::CDomain(void) 13 : CObjectTemplate<CDomain>(), CDomainAttributes() 14 , isChecked(false), local_mask(new CMask()), relFiles() 15 { /* Ne rien faire de plus */ } 16 17 CDomain::CDomain(const StdString & id) 18 : CObjectTemplate<CDomain>(id), CDomainAttributes() 19 , isChecked(false), local_mask(new CMask()), relFiles() 20 { /* Ne rien faire de plus */ } 21 22 CDomain::~CDomain(void) 23 { /* Ne rien faire de plus */ } 24 25 ///--------------------------------------------------------------- 26 27 const std::set<StdString> & CDomain::getRelFiles(void) const 28 { 29 return (this->relFiles); 30 } 31 32 bool CDomain::IsWritten(const StdString & filename) const 33 { 34 return (this->relFiles.find(filename) != this->relFiles.end()); 35 } 36 37 void CDomain::addRelFile(const StdString & filename) 38 { 39 this->relFiles.insert(filename); 40 } 41 42 //---------------------------------------------------------------- 43 44 StdString CDomain::GetName(void) { return (StdString("domain")); } 45 StdString CDomain::GetDefName(void){ return (CDomain::GetName()); } 46 ENodeType CDomain::GetType(void) { return (eDomain); } 47 48 //---------------------------------------------------------------- 49 50 void CDomain::checkGlobalDomain(void) 51 { 52 if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || 53 (ni_glo.isEmpty() || nj_glo.getValue() <= 0 )) 54 ERROR("CDomain::checkAttributes(void)", 55 << "Le domaine global est mal défini," 56 << " vérifiez les valeurs de \'ni_glo\' et \'nj_glo\' !") ; 57 } 58 59 60 //---------------------------------------------------------------- 61 62 void CDomain::checkLocalIDomain(void) 63 { 64 if (!ni.isEmpty() && !ibegin.isEmpty() && iend.isEmpty()) 65 iend.setValue(ibegin.getValue() + ni.getValue() - 1) ; 66 67 else if (!ni.isEmpty() && !iend.isEmpty() && ibegin.isEmpty()) 68 ibegin.setValue( - ni.getValue() + iend.getValue() + 1) ; 69 70 else if (!ibegin.isEmpty() && !iend.isEmpty() && ni.isEmpty()) 71 ni.setValue(iend.getValue() - ibegin.getValue() + 1) ; 72 73 else if (!ibegin.isEmpty() && !iend.isEmpty() && 74 !ni.isEmpty() && (iend.getValue() != ibegin.getValue() + ni.getValue() - 1)) 75 { 76 ERROR("CDomain::checkAttributes(void)", 77 << "Le domaine est mal défini," 78 << " iend est différent de (ibegin + ni - 1) !") ; 79 } 80 else 81 { 82 ERROR("CDomain::checkAttributes(void)", 83 << "Le domaine est mal défini," 84 << " deux valeurs au moins parmis iend, ibegin, ni doivent être définies !") ; 85 } 86 87 88 if (ni.getValue() < 0 || ibegin.getValue() > iend.getValue() || 89 ibegin.getValue() < 1 || iend.getValue() > ni_glo.getValue()) 90 ERROR("CDomain::checkAttributes(void)", 91 << "Domaine local mal défini," 92 << " vérifiez les valeurs ni, ni_glo, ibegin, iend") ; 93 94 } 95 96 //---------------------------------------------------------------- 97 98 void CDomain::checkLocalJDomain(void) 99 { 100 if (!nj.isEmpty() && !jbegin.isEmpty() && jend.isEmpty()) 101 jend.setValue(jbegin.getValue() + nj.getValue() - 1) ; 102 103 else if (!nj.isEmpty() && !jend.isEmpty() && jbegin.isEmpty()) 104 jbegin.setValue( - nj.getValue() + jend.getValue() + 1) ; 105 106 else if (!jbegin.isEmpty() && !jend.isEmpty() && nj.isEmpty()) 107 nj.setValue(jend.getValue() - jbegin.getValue() + 1) ; 108 109 else if (!jbegin.isEmpty() && !jend.isEmpty() && 110 !nj.isEmpty() && (jend.getValue() != jbegin.getValue() + nj.getValue() - 1)) 111 { 112 ERROR("CDomain::checkAttributes(void)", 113 << "Le domaine est mal défini," 114 << " iend est différent de (jbegin + nj - 1) !") ; 115 } 116 else 117 { 118 ERROR("CDomain::checkAttributes(void)", 119 << "Le domaine est mal défini," 120 << " deux valeurs au moins parmis jend, jbegin, nj doivent être définies !") ; 121 } 122 123 if (nj.getValue() < 0 || jbegin.getValue() > jend.getValue() || 124 jbegin.getValue() < 1 || jend.getValue() > nj_glo.getValue()) 125 ERROR("CDomain::checkAttributes(void)", 126 << "Domaine local mal défini," 127 << " vérifiez les valeurs nj, nj_glo, jbegin, jend") ; 128 } 129 130 131 //---------------------------------------------------------------- 132 133 void CDomain::checkMask(void) 134 { 135 if (!mask.isEmpty()) 136 { 137 unsigned int niu = ni.getValue(), nju = nj.getValue(); 138 if ((mask.getValue()->shape()[0] != niu) || 139 (mask.getValue()->shape()[1] != nju)) 54 140 ERROR("CDomain::checkAttributes(void)", 55 << "Le domaine global est mal défini," 56 << " vérifiez les valeurs de \'ni_glo\' et \'nj_glo\' !") ; 57 } 58 59 60 //---------------------------------------------------------------- 61 62 void CDomain::checkLocalIDomain(void) 63 { 64 if (!ni.isEmpty() && !ibegin.isEmpty() && iend.isEmpty()) 65 iend.setValue(ibegin.getValue() + ni.getValue() - 1) ; 66 67 else if (!ni.isEmpty() && !iend.isEmpty() && ibegin.isEmpty()) 68 ibegin.setValue( - ni.getValue() + iend.getValue() + 1) ; 69 70 else if (!ibegin.isEmpty() && !iend.isEmpty() && ni.isEmpty()) 71 ni.setValue(iend.getValue() - ibegin.getValue() + 1) ; 72 73 else if (!ibegin.isEmpty() && !iend.isEmpty() && 74 !ni.isEmpty() && (iend.getValue() != ibegin.getValue() + ni.getValue() - 1)) 141 <<"Le masque n'a pas la même taille que le domaine local") ; 142 } 143 else // (!mask.hasValue()) 144 { // Si aucun masque n'est défini, 145 // on en crée un nouveau qui valide l'intégralité du domaine. 146 ARRAY_CREATE(__arr, bool, 2, [ni.getValue()][nj.getValue()]); 147 for (int i = 0; i < ni.getValue(); i++) 148 for (int j = 0; j < nj.getValue(); j++) 149 (*__arr)[i][j] = true; 150 mask.setValue(__arr); 151 } 152 153 } 154 155 156 //---------------------------------------------------------------- 157 158 void CDomain::checkDomainData(void) 159 { 160 if (!data_dim.isEmpty() && 161 !(data_dim.getValue() == 1 || data_dim.getValue() == 2)) 162 { 163 ERROR("CDomain::checkAttributes(void)", 164 << "Dimension des données non comptatible (doit être 1 ou 2) !") ; 165 } 166 else if (data_dim.isEmpty()) 167 { 168 ERROR("CDomain::checkAttributes(void)", 169 << "Dimension des données non définie !") ; 170 } 171 172 if (data_ibegin.isEmpty()) 173 data_ibegin.setValue(0) ; 174 if (data_jbegin.isEmpty() && (data_dim.getValue() == 2)) 175 data_jbegin.setValue(0) ; 176 177 if (!data_ni.isEmpty() && (data_ni.getValue() <= 0)) 178 { 179 ERROR("CDomain::checkAttributes(void)", 180 << "Dimension des données négative (data_ni).") ; 181 } 182 else if (data_ni.isEmpty()) 183 { 184 data_ni.setValue((data_dim.getValue() == 1) 185 ? (ni.getValue() * nj.getValue()) 186 : ni.getValue()); 187 } 188 189 if (data_dim.getValue() == 2) 190 { 191 if (!data_nj.isEmpty() && (data_nj.getValue() <= 0) ) 75 192 { 76 193 ERROR("CDomain::checkAttributes(void)", 77 << "Le domaine est mal défini," 78 << " iend est différent de (ibegin + ni - 1) !") ; 79 } 80 else 194 << "Dimension des données négative (data_nj).") ; 195 } 196 else if (data_nj.isEmpty()) 197 data_nj.setValue(nj.getValue()) ; 198 } 199 200 } 201 202 //---------------------------------------------------------------- 203 204 void CDomain::checkCompression(void) 205 { 206 if (!data_i_index.isEmpty()) 207 { 208 int ssize = data_i_index.getValue()->size(); 209 if (!data_n_index.isEmpty() && 210 (data_n_index.getValue() != ssize)) 81 211 { 82 212 ERROR("CDomain::checkAttributes(void)", 83 << "Le domaine est mal défini," 84 << " deux valeurs au moins parmis iend, ibegin, ni doivent être définies !") ; 85 } 86 87 88 if (ni.getValue() < 0 || ibegin.getValue() > iend.getValue() || 89 ibegin.getValue() < 1 || iend.getValue() > ni_glo.getValue()) 90 ERROR("CDomain::checkAttributes(void)", 91 << "Domaine local mal défini," 92 << " vérifiez les valeurs ni, ni_glo, ibegin, iend") ; 93 94 } 95 96 //---------------------------------------------------------------- 97 98 void CDomain::checkLocalJDomain(void) 99 { 100 if (!nj.isEmpty() && !jbegin.isEmpty() && jend.isEmpty()) 101 jend.setValue(jbegin.getValue() + nj.getValue() - 1) ; 102 103 else if (!nj.isEmpty() && !jend.isEmpty() && jbegin.isEmpty()) 104 jbegin.setValue( - nj.getValue() + jend.getValue() + 1) ; 105 106 else if (!jbegin.isEmpty() && !jend.isEmpty() && nj.isEmpty()) 107 nj.setValue(jend.getValue() - jbegin.getValue() + 1) ; 108 109 else if (!jbegin.isEmpty() && !jend.isEmpty() && 110 !nj.isEmpty() && (jend.getValue() != jbegin.getValue() + nj.getValue() - 1)) 111 { 112 ERROR("CDomain::checkAttributes(void)", 113 << "Le domaine est mal défini," 114 << " iend est différent de (jbegin + nj - 1) !") ; 115 } 116 else 117 { 118 ERROR("CDomain::checkAttributes(void)", 119 << "Le domaine est mal défini," 120 << " deux valeurs au moins parmis jend, jbegin, nj doivent être définies !") ; 121 } 122 123 if (nj.getValue() < 0 || jbegin.getValue() > jend.getValue() || 124 jbegin.getValue() < 1 || jend.getValue() > nj_glo.getValue()) 125 ERROR("CDomain::checkAttributes(void)", 126 << "Domaine local mal défini," 127 << " vérifiez les valeurs nj, nj_glo, jbegin, jend") ; 128 } 129 130 131 //---------------------------------------------------------------- 132 133 void CDomain::checkMask(void) 134 { 135 if (!mask.isEmpty()) 136 { 137 unsigned int niu = ni.getValue(), nju = nj.getValue(); 138 if ((mask.getValue()->shape()[0] != niu) || 139 (mask.getValue()->shape()[1] != nju)) 140 ERROR("CDomain::checkAttributes(void)", 141 <<"Le masque n'a pas la même taille que le domaine local") ; 142 } 143 else // (!mask.hasValue()) 144 { // Si aucun masque n'est défini, 145 // on en crée un nouveau qui valide l'intégralité du domaine. 146 ARRAY_CREATE(__arr, bool, 2, [ni.getValue()][nj.getValue()]); 147 for (int i = 0; i < ni.getValue(); i++) 148 for (int j = 0; j < nj.getValue(); j++) 149 (*__arr)[i][j] = true; 150 mask.setValue(__arr); 151 } 152 153 } 154 155 156 //---------------------------------------------------------------- 157 158 void CDomain::checkDomainData(void) 159 { 160 if (!data_dim.isEmpty() && 161 !(data_dim.getValue() == 1 || data_dim.getValue() == 2)) 162 { 163 ERROR("CDomain::checkAttributes(void)", 164 << "Dimension des données non comptatible (doit être 1 ou 2) !") ; 165 } 166 else if (data_dim.isEmpty()) 167 { 168 ERROR("CDomain::checkAttributes(void)", 169 << "Dimension des données non définie !") ; 170 } 171 172 if (data_ibegin.isEmpty()) 173 data_ibegin.setValue(0) ; 174 if (data_jbegin.isEmpty() && (data_dim.getValue() == 2)) 175 data_jbegin.setValue(0) ; 176 177 if (!data_ni.isEmpty() && (data_ni.getValue() <= 0)) 178 { 179 ERROR("CDomain::checkAttributes(void)", 180 << "Dimension des données négative (data_ni).") ; 181 } 182 else if (data_ni.isEmpty()) 183 { 184 data_ni.setValue((data_dim.getValue() == 1) 185 ? (ni.getValue() * nj.getValue()) 186 : ni.getValue()); 187 } 213 <<"Dimension data_i_index incompatible avec data_n_index.") ; 214 } 215 else if (data_n_index.isEmpty()) 216 data_n_index.setValue(ssize) ; 188 217 189 218 if (data_dim.getValue() == 2) 190 219 { 191 if (!data_nj.isEmpty() && (data_nj.getValue() <= 0) ) 220 if (!data_j_index.isEmpty() && 221 (data_j_index.getValue()->size() != data_i_index.getValue()->size())) 192 222 { 193 223 ERROR("CDomain::checkAttributes(void)", 194 << "Dimension des données négative (data_nj).") ;224 <<"Dimension data_j_index incompatible avec data_i_index.") ; 195 225 } 196 else if (data_nj.isEmpty()) 197 data_nj.setValue(nj.getValue()) ; 198 } 199 200 } 201 202 //---------------------------------------------------------------- 203 204 void CDomain::checkCompression(void) 205 { 206 if (!data_i_index.isEmpty()) 207 { 208 int ssize = data_i_index.getValue()->size(); 209 if (!data_n_index.isEmpty() && 210 (data_n_index.getValue() != ssize)) 226 else if (data_j_index.isEmpty()) 211 227 { 212 228 ERROR("CDomain::checkAttributes(void)", 213 <<" Dimension data_i_index incompatible avec data_n_index.") ;229 <<"La donnée data_j_index doit être renseignée !") ; 214 230 } 215 else if (data_n_index.isEmpty()) 216 data_n_index.setValue(ssize) ; 217 218 if (data_dim.getValue() == 2) 219 { 220 if (!data_j_index.isEmpty() && 221 (data_j_index.getValue()->size() != data_i_index.getValue()->size())) 222 { 223 ERROR("CDomain::checkAttributes(void)", 224 <<"Dimension data_j_index incompatible avec data_i_index.") ; 231 } 232 } 233 else 234 { 235 if (!data_n_index.isEmpty() || 236 ((data_dim.getValue() == 2) && (!data_j_index.isEmpty()))) 237 ERROR("CDomain::checkAttributes(void)", << "data_i_index non défini") ; 238 } 239 240 if (data_n_index.isEmpty()) 241 { // -> bloc re-vérifié OK 242 if (data_dim.getValue() == 1) 243 { 244 const int dni = data_ni.getValue(); 245 ARRAY_CREATE(__arri, int, 1, [dni]); 246 data_n_index.setValue(dni); 247 for (int i = 0; i < dni; i++) 248 (*__arri)[i] = i+1 ; 249 data_i_index.setValue(__arri) ; 250 } 251 else // (data_dim == 2) 252 { 253 const int dni = data_ni.getValue() * data_nj.getValue(); 254 ARRAY_CREATE(__arri, int, 1, [dni]); 255 ARRAY_CREATE(__arrj, int, 1, [dni]); 256 data_n_index.setValue(dni); 257 258 for(int count = 0, i = 0; i < data_ni.getValue(); i++) 259 for(int j = 0; j < data_nj.getValue(); j++, count++) 260 { 261 (*__arri)[count] = i+1 ; 262 (*__arrj)[count] = j+1 ; 225 263 } 226 else if (data_j_index.isEmpty()) 227 { 228 ERROR("CDomain::checkAttributes(void)", 229 <<"La donnée data_j_index doit être renseignée !") ; 230 } 231 } 232 } 233 else 234 { 235 if (!data_n_index.isEmpty() || 236 ((data_dim.getValue() == 2) && (!data_j_index.isEmpty()))) 237 ERROR("CDomain::checkAttributes(void)", << "data_i_index non défini") ; 238 } 239 240 if (data_n_index.isEmpty()) 241 { // -> bloc re-vérifié OK 242 if (data_dim.getValue() == 1) 243 { 244 const int dni = data_ni.getValue(); 245 ARRAY_CREATE(__arri, int, 1, [dni]); 246 data_n_index.setValue(dni); 247 for (int i = 0; i < dni; i++) 248 (*__arri)[i] = i+1 ; 249 data_i_index.setValue(__arri) ; 250 } 251 else // (data_dim == 2) 252 { 253 const int dni = data_ni.getValue() * data_nj.getValue(); 254 ARRAY_CREATE(__arri, int, 1, [dni]); 255 ARRAY_CREATE(__arrj, int, 1, [dni]); 256 data_n_index.setValue(dni); 257 for(int count = 0, i = 0; i < data_ni.getValue(); i++) 258 for(int j = 0; j < data_nj.getValue(); j++, count++) 259 { (*__arri)[count] = i+1 ; (*__arrj)[count] = j+1 ; } 260 data_i_index.setValue(__arri) ; 261 data_j_index.setValue(__arrj) ; 262 } 263 } 264 } 265 266 //---------------------------------------------------------------- 267 268 void CDomain::checkAttributes(void) 269 { 270 if (this->isChecked) return; 271 272 this->checkGlobalDomain(); 273 this->checkLocalIDomain(); 274 this->checkLocalJDomain(); 275 276 this->checkMask(); 277 this->checkDomainData(); 278 this->checkCompression(); 279 this->completeMask(); 280 281 this->isChecked = true; 282 } 283 284 void CDomain::completeMask(void) 285 { 286 this->local_mask->resize(data_ni.getValue(), data_nj.getValue()); 287 /*this->local_mask->setDataPosition 288 (data_dim.getValue(), data_ni.getValue(), data_nj.getValue(), 289 data_ibegin.getValue(), data_jbegin.getValue(), data_n_index.getValue(), 290 data_i_index.getValue(), data_j_index.getValue());*/ 291 } 292 293 boost::shared_ptr<CMask> CDomain::getLocalMask(void) const 294 { 295 return (this->local_mask); 296 } 297 ///--------------------------------------------------------------- 298 299 } // namespace tree 264 265 data_i_index.setValue(__arri) ; 266 data_j_index.setValue(__arrj) ; 267 } 268 } 269 } 270 271 //---------------------------------------------------------------- 272 273 void CDomain::checkAttributes(void) 274 { 275 if (this->isChecked) return; 276 277 this->checkGlobalDomain(); 278 this->checkLocalIDomain(); 279 this->checkLocalJDomain(); 280 281 this->checkMask(); 282 this->checkDomainData(); 283 this->checkCompression(); 284 this->completeMask(); 285 286 this->isChecked = true; 287 } 288 289 void CDomain::completeMask(void) 290 { 291 this->local_mask->resize(data_ni.getValue(), data_nj.getValue()); 292 /*this->local_mask->setDataPosition 293 (data_dim.getValue(), data_ni.getValue(), data_nj.getValue(), 294 data_ibegin.getValue(), data_jbegin.getValue(), data_n_index.getValue(), 295 data_i_index.getValue(), data_j_index.getValue());*/ 296 } 297 298 boost::shared_ptr<CMask> CDomain::getLocalMask(void) const 299 { 300 return (this->local_mask); 301 } 302 ///--------------------------------------------------------------- 303 304 } // namespace tree 300 305 } // namespace xmlioserver -
XMLIO_V2/dev/dev_rv/src/xmlio/node/domain.hpp
r157 r168 9 9 #include "declare_group.hpp" 10 10 11 namespace xmlioserver 12 { 13 namespace tree 11 namespace xmlioserver { 12 namespace tree { 13 14 /// ////////////////////// Déclarations ////////////////////// /// 15 16 class CDomainGroup; 17 class CDomainAttributes; 18 class CDomain; 19 20 ///-------------------------------------------------------------- 21 22 // Declare/Define CDomainAttribute 23 BEGIN_DECLARE_ATTRIBUTE_MAP(CDomain) 24 #include "domain_attribute.conf" 25 END_DECLARE_ATTRIBUTE_MAP(CDomain) 26 27 ///-------------------------------------------------------------- 28 29 class CDomain 30 : public CObjectTemplate<CDomain> 31 , public CDomainAttributes 14 32 { 15 /// ////////////////////// Déclarations ////////////////////// /// 33 /// typedef /// 34 typedef CObjectTemplate<CDomain> SuperClass; 35 typedef CDomainAttributes SuperClassAttribute; 16 36 17 class CDomainGroup; 18 class CDomainAttributes; 19 class CDomain; 37 public : 20 38 21 ///-------------------------------------------------------------- 39 typedef CDomainAttributes RelAttributes; 40 typedef CDomainGroup RelGroup; 22 41 23 // Declare/Define CDomainAttribute 24 BEGIN_DECLARE_ATTRIBUTE_MAP(CDomain) 25 #include "domain_attribute.conf" 26 END_DECLARE_ATTRIBUTE_MAP(CDomain) 42 /// Constructeurs /// 43 CDomain(void); 44 explicit CDomain(const StdString & id); 45 CDomain(const CDomain & domain); // Not implemented yet. 46 CDomain(const CDomain * const domain); // Not implemented yet. 27 47 28 ///-------------------------------------------------------------- 48 /// Vérifications /// 49 void checkAttributes(void); 29 50 30 class CDomain 31 : public CObjectTemplate<CDomain> 32 , public CDomainAttributes 33 { 34 /// typedef /// 35 typedef CObjectTemplate<CDomain> SuperClass; 36 typedef CDomainAttributes SuperClassAttribute; 51 private : 37 52 38 public :53 virtual void checkGlobalDomain(void); 39 54 40 typedef CDomainAttributes RelAttributes;41 typedef CDomainGroup RelGroup;55 virtual void checkLocalIDomain(void); 56 virtual void checkLocalJDomain(void); 42 57 43 /// Constructeurs /// 44 CDomain(void); 45 explicit CDomain(const StdString & id); 46 CDomain(const CDomain & domain); // Not implemented yet. 47 CDomain(const CDomain * const domain); // Not implemented yet. 58 virtual void checkMask(void); 59 virtual void checkDomainData(void); 60 virtual void checkCompression(void); 48 61 49 /// Vérifications /// 50 void checkAttributes(void); 62 virtual void completeMask(void); 51 63 52 private:64 public : 53 65 54 virtual void checkGlobalDomain(void); 66 /// Accesseurs /// 67 boost::shared_ptr<CMask> getLocalMask(void) const; 68 const std::set<StdString> & getRelFiles(void) const; 55 69 56 virtual void checkLocalIDomain(void);57 virtual void checkLocalJDomain(void);70 /// Test /// 71 bool IsWritten(const StdString & filename) const; 58 72 59 virtual void checkMask(void); 60 virtual void checkDomainData(void); 61 virtual void checkCompression(void); 73 /// Mutateur /// 74 void addRelFile(const StdString & filename); 62 75 63 virtual void completeMask(void); 76 /// Destructeur /// 77 virtual ~CDomain(void); 64 78 65 public : 79 /// Accesseurs statiques /// 80 static StdString GetName(void); 81 static StdString GetDefName(void); 82 83 static ENodeType GetType(void); 66 84 67 /// Accesseurs /// 68 boost::shared_ptr<CMask> getLocalMask(void) const; 69 const std::set<StdString> & getRelFiles(void) const; 85 private : 70 86 71 /// Test /// 72 bool IsWritten(const StdString & filename) const; 87 /// Proriétés protégées /// 88 bool isChecked; 89 boost::shared_ptr<CMask> local_mask; 90 std::set<StdString> relFiles; 73 91 74 /// Mutateur /// 75 void addRelFile(const StdString & filename); 92 }; // class CDomain 76 93 77 /// Destructeur /// 78 virtual ~CDomain(void); 94 ///-------------------------------------------------------------- 79 95 80 /// Accesseurs statiques /// 81 static StdString GetName(void); 82 static StdString GetDefName(void); 96 // Declare/Define CDomainGroup and CDomainDefinition 97 DECLARE_GROUP(CDomain); 83 98 84 private :99 ///-------------------------------------------------------------- 85 100 86 /// Proriétés protégées /// 87 bool isChecked; 88 boost::shared_ptr<CMask> local_mask; 89 std::set<StdString> relFiles; 90 91 }; // class CDomain 92 93 ///-------------------------------------------------------------- 94 95 // Declare/Define CDomainGroup and CDomainDefinition 96 DECLARE_GROUP(CDomain); 97 98 } // namespace tree 101 } // namespace tree 99 102 } // namespace xmlioserver 100 103 -
XMLIO_V2/dev/dev_rv/src/xmlio/node/field.cpp
r152 r168 7 7 #include "node_type.hpp" 8 8 9 namespace xmlioserver 10 { 11 namespace tree 12 { 13 /// ////////////////////// Définitions ////////////////////// /// 14 15 CField::CField(void) 16 : CObjectTemplate<CField>(), CFieldAttributes() 17 , baseRefObject(), refObject(), grid(), file(), foperation(NULL) 18 { /* Ne rien faire de plus */ } 19 20 CField::CField(const StdString & id) 21 : CObjectTemplate<CField>(id), CFieldAttributes() 22 , baseRefObject(), refObject(), foperation(NULL) 23 { /* Ne rien faire de plus */ } 24 25 CField::~CField(void) 26 { 27 if (this->foperation == NULL) 28 delete this->foperation; 29 } 30 31 void CField::setRelFile(const boost::shared_ptr<CFile> _file) 32 { this->file = _file; } 33 34 //---------------------------------------------------------------- 35 36 StdString CField::GetName(void) { return (StdString("field")); } 37 StdString CField::GetDefName(void){ return (CField::GetName()); } 38 39 boost::shared_ptr<CGrid> CField::getRelGrid(void) const 40 { return (this->grid); } 41 42 boost::shared_ptr<CFile> CField::getRelFile(void) const 43 { return (this->file); } 44 45 boost::shared_ptr<CField> CField::getDirectFieldReference(void) const 46 { 47 if (this->field_ref.isEmpty()) 48 return (this->getBaseFieldReference()); 49 50 if (! CObjectFactory::HasObject<CField>(this->field_ref.getValue())) 51 ERROR("CField::getDirectFieldReference(void)", 52 << "[ ref_name = " << this->field_ref.getValue() << "]" 53 << " invalid field name !"); 54 55 return (CObjectFactory::GetObject<CField>(this->field_ref.getValue())); 56 } 57 58 const boost::shared_ptr<CField> 59 CField::getBaseFieldReference(void) const { return (baseRefObject); } 60 61 const std::vector<boost::shared_ptr<CField> > & 62 CField::getAllReference(void) const { return (refObject); } 63 64 const StdString & CField::getBaseFieldId(void) const 65 { return (this->getBaseFieldReference()->getId()); } 66 67 bool CField::hasDirectFieldReference(void) const 68 { return (!this->field_ref.isEmpty()); } 69 70 //---------------------------------------------------------------- 71 72 void CField::solveRefInheritance(void) 73 { 74 std::set<CField *> sset; 75 boost::shared_ptr<CField> refer_sptr; 76 CField * refer_ptr = this; 77 this->baseRefObject = CObjectFactory::GetObject<CField>(this); 78 while (refer_ptr->hasDirectFieldReference()) 9 namespace xmlioserver{ 10 namespace tree { 11 12 /// ////////////////////// Définitions ////////////////////// /// 13 14 CField::CField(void) 15 : CObjectTemplate<CField>(), CFieldAttributes() 16 , baseRefObject(), refObject(), grid(), file(), foperation(NULL) 17 { /* Ne rien faire de plus */ } 18 19 CField::CField(const StdString & id) 20 : CObjectTemplate<CField>(id), CFieldAttributes() 21 , baseRefObject(), refObject(), foperation(NULL) 22 { /* Ne rien faire de plus */ } 23 24 CField::~CField(void) 25 { 26 if (this->foperation == NULL) 27 delete this->foperation; 28 } 29 30 //---------------------------------------------------------------- 31 32 void CField::setRelFile(const boost::shared_ptr<CFile> _file) 33 { 34 this->file = _file; 35 } 36 37 //---------------------------------------------------------------- 38 39 StdString CField::GetName(void) { return (StdString("field")); } 40 StdString CField::GetDefName(void){ return (CField::GetName()); } 41 ENodeType CField::GetType(void) { return (eField); } 42 43 //---------------------------------------------------------------- 44 45 boost::shared_ptr<CGrid> CField::getRelGrid(void) const 46 { 47 return (this->grid); 48 } 49 50 //---------------------------------------------------------------- 51 52 boost::shared_ptr<CFile> CField::getRelFile(void) const 53 { 54 return (this->file); 55 } 56 57 //---------------------------------------------------------------- 58 59 boost::shared_ptr<CField> CField::getDirectFieldReference(void) const 60 { 61 if (this->field_ref.isEmpty()) 62 return (this->getBaseFieldReference()); 63 64 if (! CObjectFactory::HasObject<CField>(this->field_ref.getValue())) 65 ERROR("CField::getDirectFieldReference(void)", 66 << "[ ref_name = " << this->field_ref.getValue() << "]" 67 << " invalid field name !"); 68 69 return (CObjectFactory::GetObject<CField>(this->field_ref.getValue())); 70 } 71 72 //---------------------------------------------------------------- 73 74 const boost::shared_ptr<CField> CField::getBaseFieldReference(void) const 75 { 76 return (baseRefObject); 77 } 78 79 //---------------------------------------------------------------- 80 81 const std::vector<boost::shared_ptr<CField> > & CField::getAllReference(void) const 82 { 83 return (refObject); 84 } 85 86 //---------------------------------------------------------------- 87 88 const StdString & CField::getBaseFieldId(void) const 89 { 90 return (this->getBaseFieldReference()->getId()); 91 } 92 93 //---------------------------------------------------------------- 94 95 bool CField::hasDirectFieldReference(void) const 96 { 97 return (!this->field_ref.isEmpty()); 98 } 99 100 //---------------------------------------------------------------- 101 102 void CField::solveRefInheritance(void) 103 { 104 std::set<CField *> sset; 105 boost::shared_ptr<CField> refer_sptr; 106 CField * refer_ptr = this; 107 this->baseRefObject = CObjectFactory::GetObject<CField>(this); 108 while (refer_ptr->hasDirectFieldReference()) 109 { 110 refer_sptr = refer_ptr->getDirectFieldReference(); 111 refer_ptr = refer_sptr.get(); 112 113 if(sset.end() != sset.find(refer_ptr)) 79 114 { 80 refer_sptr = refer_ptr->getDirectFieldReference(); 81 refer_ptr = refer_sptr.get(); 82 83 if(sset.end() != sset.find(refer_ptr)) 84 { 85 DEBUG (<< "Dépendance circulaire stoppée pour l'objet de type CField sur " 86 << "\"" + refer_ptr->getId() + "\" !"); 87 break; 88 } 89 90 SuperClassAttribute::setAttributes(refer_ptr); 91 sset.insert(refer_ptr); 92 baseRefObject = refer_sptr; 93 refObject.push_back(refer_sptr); 115 DEBUG (<< "Dépendance circulaire stoppée pour l'objet de type CField sur " 116 << "\"" + refer_ptr->getId() + "\" !"); 117 break; 94 118 } 95 } 96 97 //---------------------------------------------------------------- 98 99 void CField::solveOperation(void) 100 { 101 // TODO : à compléter; 102 } 103 104 //---------------------------------------------------------------- 105 106 void CField::solveGridReference(void) 107 { 108 boost::shared_ptr<CDomain> domain; 109 boost::shared_ptr<CAxis> axis; 110 119 120 SuperClassAttribute::setAttributes(refer_ptr); 121 sset.insert(refer_ptr); 122 baseRefObject = refer_sptr; 123 refObject.push_back(refer_sptr); 124 } 125 } 126 127 //---------------------------------------------------------------- 128 129 void CField::solveOperation(void) 130 { 131 // TODO : à compléter; 132 } 133 134 //---------------------------------------------------------------- 135 136 void CField::solveGridReference(void) 137 { 138 boost::shared_ptr<CDomain> domain; 139 boost::shared_ptr<CAxis> axis; 140 141 if (!domain_ref.isEmpty()) 142 { 143 if (CObjectFactory::HasObject<CDomain>(domain_ref.getValue())) 144 domain = CObjectFactory::GetObject<CDomain>(domain_ref.getValue()) ; 145 else 146 ERROR("CField::solveGridReference(void)", 147 << "Référence au domaine nommé \'" 148 << domain_ref.getValue() << "\' incorrecte") ; 149 } 150 151 if (!axis_ref.isEmpty()) 152 { 153 if (CObjectFactory::HasObject<CAxis>(axis_ref.getValue())) 154 axis = CObjectFactory::GetObject<CAxis>(axis_ref.getValue()) ; 155 else 156 ERROR("CField::solveGridReference(void)", 157 << "Référence à l'axe nommé \'" 158 << axis_ref.getValue() <<"\' incorrecte") ; 159 } 160 161 if (!grid_ref.isEmpty()) 162 { 163 if (CObjectFactory::HasObject<CGrid>(grid_ref.getValue())) 164 this->grid = CObjectFactory::GetObject<CGrid>(grid_ref.getValue()) ; 165 else 166 ERROR("CField::solveGridReference(void)", 167 << "Référence à la grille nommée \'" 168 << grid_ref.getValue() << "\' incorrecte"); 169 if (!domain_ref.isEmpty()) 170 DEBUG(<< "Définition conjointe de la grille " 171 << "et du domaine, la grille prévaut..." ); 172 if (!axis_ref.isEmpty()) 173 DEBUG(<< "Définition conjointe de la grille " 174 << "et de l'axe vertical, la grille prévaut...") ; 175 } 176 else 177 { 111 178 if (!domain_ref.isEmpty()) 112 179 { 113 if (CObjectFactory::HasObject<CDomain>(domain_ref.getValue()))114 domain = CObjectFactory::GetObject<CDomain>(domain_ref.getValue()) ;115 else116 ERROR("CField::solveGridReference(void)",117 << "Référence au domaine nommé \'"118 << domain_ref.getValue() << "\' incorrecte") ;119 }120 121 if (!axis_ref.isEmpty())122 {123 if (CObjectFactory::HasObject<CAxis>(axis_ref.getValue()))124 axis = CObjectFactory::GetObject<CAxis>(axis_ref.getValue()) ;125 else126 ERROR("CField::solveGridReference(void)",127 << "Référence à l'axe nommé \'"128 << axis_ref.getValue() <<"\' incorrecte") ;129 }130 131 if (!grid_ref.isEmpty())132 {133 if (CObjectFactory::HasObject<CGrid>(grid_ref.getValue()))134 this->grid = CObjectFactory::GetObject<CGrid>(grid_ref.getValue()) ;135 else136 ERROR("CField::solveGridReference(void)",137 << "Référence à la grille nommée \'"138 << grid_ref.getValue() << "\' incorrecte");139 if (!domain_ref.isEmpty())140 DEBUG(<< "Définition conjointe de la grille "141 << "et du domaine, la grille prévaut..." );142 180 if (!axis_ref.isEmpty()) 143 DEBUG(<< "Définition conjointe de la grille "144 << "et de l'axe vertical, la grille prévaut...") ;145 }146 else147 {148 if (!domain_ref.isEmpty())149 181 { 150 if (!axis_ref.isEmpty()) 151 { 152 this->grid = CGrid::CreateGrid(domain, axis) ; 153 this->grid_ref.setValue(this->grid->getId()); 154 } 155 else 156 { 157 this->grid = CGrid::CreateGrid(domain) ; 158 this->grid_ref.setValue(this->grid->getId()); 159 } 182 this->grid = CGrid::CreateGrid(domain, axis) ; 183 this->grid_ref.setValue(this->grid->getId()); 160 184 } 161 185 else 162 186 { 163 ERROR("CField::solveGridReference(void)",164 << "Le domaine horizontal pour le champ X n'est pas défini");187 this->grid = CGrid::CreateGrid(domain) ; 188 this->grid_ref.setValue(this->grid->getId()); 165 189 } 166 190 } 167 grid->solveReference() ; 168 } 191 else 192 { 193 ERROR("CField::solveGridReference(void)", 194 << "Le domaine horizontal pour le champ X n'est pas défini"); 195 } 196 } 197 grid->solveReference() ; 198 } 199 169 200 } // namespace tree 170 201 -
XMLIO_V2/dev/dev_rv/src/xmlio/node/field.hpp
r157 r168 11 11 #include "declare_group.hpp" 12 12 13 namespace xmlioserver 14 { 15 namespace tree 13 namespace xmlioserver { 14 namespace tree { 15 16 /// ////////////////////// Déclarations ////////////////////// /// 17 18 class CFieldGroup; 19 class CFieldAttributes; 20 class CField; 21 22 class CFile; 23 class CGrid; 24 25 ///-------------------------------------------------------------- 26 27 // Declare/Define CFieldAttribute 28 BEGIN_DECLARE_ATTRIBUTE_MAP(CField) 29 #include "field_attribute.conf" 30 END_DECLARE_ATTRIBUTE_MAP(CField) 31 32 ///-------------------------------------------------------------- 33 class CField 34 : public CObjectTemplate<CField> 35 , public CFieldAttributes 16 36 { 17 /// ////////////////////// Déclarations ////////////////////// /// 37 /// friend /// 38 friend class CFile; 18 39 19 class CFieldGroup;20 class CFieldAttributes;21 class CField;40 /// typedef /// 41 typedef CObjectTemplate<CField> SuperClass; 42 typedef CFieldAttributes SuperClassAttribute; 22 43 23 class CFile; 24 class CGrid; 44 public : 25 45 26 ///-------------------------------------------------------------- 46 typedef CFieldAttributes RelAttributes; 47 typedef CFieldGroup RelGroup; 27 48 28 // Declare/Define CFieldAttribute 29 BEGIN_DECLARE_ATTRIBUTE_MAP(CField) 30 #include "field_attribute.conf" 31 END_DECLARE_ATTRIBUTE_MAP(CField) 49 /// Constructeurs /// 50 CField(void); 51 explicit CField(const StdString & id); 52 CField(const CField & field); // Not implemented yet. 53 CField(const CField * const field); // Not implemented yet. 32 54 33 ///-------------------------------------------------------------- 34 class CField 35 : public CObjectTemplate<CField> 36 , public CFieldAttributes 37 { 38 /// friend /// 39 friend class CFile; 55 /// Accesseurs /// 56 boost::shared_ptr<CField> getDirectFieldReference(void) const; 57 const boost::shared_ptr<CField> getBaseFieldReference(void) const; 58 const std::vector<boost::shared_ptr<CField> > & getAllReference(void) const; 40 59 41 /// typedef /// 42 typedef CObjectTemplate<CField> SuperClass; 43 typedef CFieldAttributes SuperClassAttribute; 60 boost::shared_ptr<CGrid> getRelGrid(void) const ; 61 boost::shared_ptr<CFile> getRelFile(void) const ; 44 62 45 public :63 const StdString & getBaseFieldId(void) const; 46 64 47 typedef CFieldAttributes RelAttributes;48 typedef CFieldGroup RelGroup;65 /// Mutateur /// 66 void setRelFile(const boost::shared_ptr<CFile> _file); 49 67 50 /// Constructeurs /// 51 CField(void); 52 explicit CField(const StdString & id); 53 CField(const CField & field); // Not implemented yet. 54 CField(const CField * const field); // Not implemented yet. 68 public : 55 69 56 /// Accesseurs /// 57 boost::shared_ptr<CField> getDirectFieldReference(void) const; 58 const boost::shared_ptr<CField> getBaseFieldReference(void) const; 59 const std::vector<boost::shared_ptr<CField> > & getAllReference(void) const; 70 /// Test /// 71 bool hasDirectFieldReference(void) const; 60 72 61 boost::shared_ptr<CGrid> getRelGrid(void) const ; 62 boost::shared_ptr<CFile> getRelFile(void) const ; 73 /// Traitements /// 74 void solveRefInheritance(void); 75 void solveGridReference(void); 76 void solveOperation(void); 63 77 64 const StdString & getBaseFieldId(void) const; 78 /// Destructeur /// 79 virtual ~CField(void); 65 80 66 /// Mutateur /// 67 void setRelFile(const boost::shared_ptr<CFile> _file); 81 /// Accesseurs statiques /// 82 static StdString GetName(void); 83 static StdString GetDefName(void); 84 85 static ENodeType GetType(void); 68 86 69 public:87 private : 70 88 71 /// Test /// 72 bool hasDirectFieldReference(void) const; 89 /// Propriétés privées /// 90 boost::shared_ptr<CField> baseRefObject; 91 std::vector<boost::shared_ptr<CField> > refObject; 73 92 74 /// Traitements /// 75 void solveRefInheritance(void); 76 void solveGridReference(void); 77 void solveOperation(void); 93 boost::shared_ptr<CGrid> grid ; 94 boost::shared_ptr<CFile> file; 78 95 79 /// Destructeur /// 80 virtual ~CField(void); 96 func::CFunctor * foperation; 81 97 82 /// Accesseurs statiques /// 83 static StdString GetName(void); 84 static StdString GetDefName(void); 98 }; // class CField 85 99 86 private :100 ///-------------------------------------------------------------- 87 101 88 /// Propriétés privées /// 89 boost::shared_ptr<CField> baseRefObject; 90 std::vector<boost::shared_ptr<CField> > refObject; 91 92 boost::shared_ptr<CGrid> grid ; 93 boost::shared_ptr<CFile> file; 94 95 func::CFunctor * foperation; 96 97 }; // class CField 98 99 ///-------------------------------------------------------------- 100 101 // Declare/Define CFieldGroup and CFieldDefinition 102 DECLARE_GROUP(CField); 102 // Declare/Define CFieldGroup and CFieldDefinition 103 DECLARE_GROUP(CField); 103 104 104 105 } // namespace tree -
XMLIO_V2/dev/dev_rv/src/xmlio/node/file.cpp
r152 r168 8 8 #include "object_factory_impl.hpp" 9 9 10 namespace xmlioserver 11 { 12 namespace tree 10 namespace xmlioserver { 11 namespace tree { 12 13 /// ////////////////////// Définitions ////////////////////// /// 14 15 CFile::CFile(void) 16 : CObjectTemplate<CFile>(), CFileAttributes() 17 , vFieldGroup(), data_out(), enabledFields() 18 { /* Ne rien faire de plus */ } 19 20 CFile::CFile(const StdString & id) 21 : CObjectTemplate<CFile>(id), CFileAttributes() 22 , vFieldGroup(), data_out(), enabledFields() 23 { /* Ne rien faire de plus */ } 24 25 CFile::~CFile(void) 26 { /* Ne rien faire de plus */ } 27 28 ///--------------------------------------------------------------- 29 30 StdString CFile::GetName(void) { return (StdString("file")); } 31 StdString CFile::GetDefName(void){ return (CFile::GetName()); } 32 ENodeType CFile::GetType(void) { return (eFile); } 33 34 //---------------------------------------------------------------- 35 36 boost::shared_ptr<CFieldGroup> CFile::getVirtualFieldGroup(void) const 13 37 { 14 /// ////////////////////// Définitions ////////////////////// /// 38 return (this->vFieldGroup); 39 } 15 40 16 CFile::CFile(void)17 : CObjectTemplate<CFile>(), CFileAttributes()18 , vFieldGroup(), data_out(), enabledFields()19 { /* Ne rien faire de plus */}41 std::vector<boost::shared_ptr<CField> > CFile::getAllFields(void) const 42 { 43 return (this->vFieldGroup->getAllChildren()); 44 } 20 45 21 CFile::CFile(const StdString & id) 22 : CObjectTemplate<CFile>(id), CFileAttributes() 23 , vFieldGroup(), data_out(), enabledFields() 24 { /* Ne rien faire de plus */ } 46 //---------------------------------------------------------------- 25 47 26 CFile::~CFile(void) 27 { /* Ne rien faire de plus */ } 48 std::vector<boost::shared_ptr<CField> > CFile::getEnabledFields 49 (int default_outputlevel, int default_level, bool default_enabled) 50 { 51 if (!this->enabledFields.empty()) 52 return (this->enabledFields); 28 53 29 ///--------------------------------------------------------------- 54 const int _outputlevel = 55 (!output_level.isEmpty()) ? output_level.getValue() : default_outputlevel; 56 std::vector<boost::shared_ptr<CField> >::iterator it; 57 this->enabledFields = this->getAllFields(); 30 58 31 StdString CFile::GetName(void) { return (StdString("file")); } 32 StdString CFile::GetDefName(void){ return (CFile::GetName()); } 59 for ( it = this->enabledFields.begin() ; it != this->enabledFields.end(); it++ ) 60 { 61 if (!(*it)->enabled.isEmpty()) // Si l'attribut 'enabled' est défini ... 62 { 63 if (! (*it)->enabled.getValue()) 64 { it--; this->enabledFields.erase(it+1); continue; } 65 } 66 else // Si l'attribut 'enabled' n'est pas défini ... 67 { 68 if (!default_enabled) 69 { it--; this->enabledFields.erase(it+1); continue; } 70 } 33 71 34 boost::shared_ptr<CFieldGroup> CFile::getVirtualFieldGroup(void) const 35 { 36 return (this->vFieldGroup); 72 if (!(*it)->level.isEmpty()) // Si l'attribut 'level' est défini ... 73 { 74 if ((*it)->level.getValue() > _outputlevel) 75 { it--; this->enabledFields.erase(it+1); continue; } 76 } 77 else // Si l'attribut 'level' n'est pas défini ... 78 { 79 if (default_level > _outputlevel) 80 { it--; this->enabledFields.erase(it+1); continue; } 81 } 82 83 // Le champ est finalement actif, on ajoute la référence au champ de base. 84 (*it)->setRelFile(CObjectFactory::GetObject(this)); 85 (*it)->baseRefObject->refObject.push_back(*it); 37 86 } 38 87 39 std::vector<boost::shared_ptr<CField> > CFile::getAllFields(void) const 88 return (this->enabledFields); 89 } 90 91 //---------------------------------------------------------------- 92 93 void CFile::setVirtualFieldGroup(boost::shared_ptr<CFieldGroup> newVFieldGroup) 94 { this->vFieldGroup = newVFieldGroup; } 95 96 void CFile::setVirtualFieldGroup(const StdString & newVFieldGroupId) 97 { 98 this->setVirtualFieldGroup 99 (CObjectFactory::CreateObject<CFieldGroup>(newVFieldGroupId)); 100 } 101 102 void CFile::initializeDataOutput(boost::shared_ptr<io::CDataOutput> dout) 103 { 104 this->data_out = dout; 105 this->data_out->writeFile(CObjectFactory::GetObject<CFile>(this)); 106 107 std::vector<boost::shared_ptr<CField> >::iterator it, end = this->enabledFields.end(); 108 109 for (it = this->enabledFields.begin() ;it != end; it++) 40 110 { 41 return (this->vFieldGroup->getAllChildren()); 111 boost::shared_ptr<CField> field = *it; 112 this->data_out->writeFieldGrid(field); 42 113 } 114 115 for (it = this->enabledFields.begin() ;it != end; it++) 116 { 117 boost::shared_ptr<CField> field = *it; 118 this->data_out->writeField(field); 119 } 120 121 this->data_out->definition_end(); 122 } 43 123 44 //---------------------------------------------------------------- 124 void CFile::parse(xml::CXMLNode & node) 125 { 126 SuperClass::parse(node); 127 if (node.goToChildElement() & this->hasId()) 128 { // Si la définition du fichier intégre des champs et si le fichier est identifié. 129 node.goToParentElement(); 130 this->setVirtualFieldGroup(this->getId()); 131 this->getVirtualFieldGroup()->parse(node, false); 132 } 133 } 134 //---------------------------------------------------------------- 45 135 46 std::vector<boost::shared_ptr<CField> > CFile::getEnabledFields 47 (int default_outputlevel, int default_level, bool default_enabled) 48 { 49 if (!this->enabledFields.empty()) 50 return (this->enabledFields); 136 StdString CFile::toString(void) const 137 { 138 StdOStringStream oss; 51 139 52 const int _outputlevel = 53 (!output_level.isEmpty()) ? output_level.getValue() : default_outputlevel; 54 std::vector<boost::shared_ptr<CField> >::iterator it; 55 this->enabledFields = this->getAllFields(); 56 57 for ( it = this->enabledFields.begin() ; it != this->enabledFields.end(); it++ ) 58 { 59 if (!(*it)->enabled.isEmpty()) // Si l'attribut 'enabled' est défini ... 60 { 61 if (! (*it)->enabled.getValue()) 62 { it--; this->enabledFields.erase(it+1); continue; } 63 } 64 else // Si l'attribut 'enabled' n'est pas défini ... 65 { 66 if (!default_enabled) 67 { it--; this->enabledFields.erase(it+1); continue; } 68 } 69 70 if (!(*it)->level.isEmpty()) // Si l'attribut 'level' est défini ... 71 { 72 if ((*it)->level.getValue() > _outputlevel) 73 { it--; this->enabledFields.erase(it+1); continue; } 74 } 75 else // Si l'attribut 'level' n'est pas défini ... 76 { 77 if (default_level > _outputlevel) 78 { it--; this->enabledFields.erase(it+1); continue; } 79 } 80 81 // Le champ est finalement actif, on ajoute la référence au champ de base. 82 (*it)->setRelFile(CObjectFactory::GetObject(this)); 83 (*it)->baseRefObject->refObject.push_back(*it); 84 } 85 86 return (this->enabledFields); 87 } 88 89 //---------------------------------------------------------------- 90 91 void CFile::setVirtualFieldGroup(boost::shared_ptr<CFieldGroup> newVFieldGroup) 92 { this->vFieldGroup = newVFieldGroup; } 93 94 void CFile::setVirtualFieldGroup(const StdString & newVFieldGroupId) 95 { 96 this->setVirtualFieldGroup 97 (CObjectFactory::CreateObject<CFieldGroup>(newVFieldGroupId)); 98 } 99 100 void CFile::initializeDataOutput(boost::shared_ptr<io::CDataOutput> dout) 101 { 102 this->data_out = dout; 103 this->data_out->writeFile(CObjectFactory::GetObject<CFile>(this)); 104 105 std::vector<boost::shared_ptr<CField> >::iterator it, end = this->enabledFields.end(); 106 107 for (it = this->enabledFields.begin() ;it != end; it++) 108 { 109 boost::shared_ptr<CField> field = *it; 110 this->data_out->writeFieldGrid(field); 111 } 112 113 for (it = this->enabledFields.begin() ;it != end; it++) 114 { 115 boost::shared_ptr<CField> field = *it; 116 this->data_out->writeField(field); 117 } 118 119 this->data_out->definition_end(); 120 } 121 122 void CFile::parse(xml::CXMLNode & node) 123 { 124 SuperClass::parse(node); 125 if (node.goToChildElement() & this->hasId()) 126 { // Si la définition du fichier intégre des champs et si le fichier est identifié. 127 node.goToParentElement(); 128 this->setVirtualFieldGroup(this->getId()); 129 this->getVirtualFieldGroup()->parse(node, false); 130 } 131 } 132 //---------------------------------------------------------------- 133 134 StdString CFile::toString(void) const 135 { 136 StdOStringStream oss; 137 138 oss << "< " << CFile::GetName() << " "; 139 if (this->hasId()) 140 oss << " id=\"" << this->getId() << "\" "; 141 oss << SuperClassAttribute::toString() << ">" << std::endl; 142 if (this->getVirtualFieldGroup().get() != NULL) 143 oss << *this->getVirtualFieldGroup() << std::endl; 144 oss << "</ " << CFile::GetName() << " >"; 145 return (oss.str()); 146 } 140 oss << "< " << CFile::GetName() << " "; 141 if (this->hasId()) 142 oss << " id=\"" << this->getId() << "\" "; 143 oss << SuperClassAttribute::toString() << ">" << std::endl; 144 if (this->getVirtualFieldGroup().get() != NULL) 145 oss << *this->getVirtualFieldGroup() << std::endl; 146 oss << "</ " << CFile::GetName() << " >"; 147 return (oss.str()); 148 } 147 149 148 150 149 150 151 152 153 151 void CFile::solveDescInheritance(const CAttributeMap * const parent) 152 { 153 SuperClassAttribute::setAttributes(parent); 154 this->getVirtualFieldGroup()->solveDescInheritance(NULL); 155 } 154 156 155 156 157 158 159 160 161 157 void CFile::solveFieldRefInheritance(void) 158 { 159 // Résolution des héritages par référence de chacun des champs contenus dans le fichier. 160 std::vector<boost::shared_ptr<CField> > allF = this->getAllFields(); 161 for (unsigned int i = 0; i < allF.size(); i++) 162 allF[i]->solveRefInheritance(); 163 } 162 164 163 164 165 166 167 165 void CFile::solveEFGridRef(void) 166 { 167 for (unsigned int i = 0; i < this->enabledFields.size(); i++) 168 this->enabledFields[i]->solveGridReference(); 169 } 168 170 169 170 171 172 173 171 void CFile::solveEFOperation(void) 172 { 173 for (unsigned int i = 0; i < this->enabledFields.size(); i++) 174 this->enabledFields[i]->solveOperation(); 175 } 174 176 175 ///--------------------------------------------------------------- 176 } // namespace tree 177 ///--------------------------------------------------------------- 178 179 } // namespace tree 177 180 } // namespace xmlioserver -
XMLIO_V2/dev/dev_rv/src/xmlio/node/file.hpp
r157 r168 9 9 #include "data_output.hpp" 10 10 11 namespace xmlioserver 12 { 13 namespace tree 11 namespace xmlioserver { 12 namespace tree { 13 14 /// ////////////////////// Déclarations ////////////////////// /// 15 16 class CFileGroup; 17 class CFileAttributes; 18 class CFile; 19 20 ///-------------------------------------------------------------- 21 22 // Declare/Define CFileAttribute 23 BEGIN_DECLARE_ATTRIBUTE_MAP(CFile) 24 #include "file_attribute.conf" 25 END_DECLARE_ATTRIBUTE_MAP(CFile) 26 27 ///-------------------------------------------------------------- 28 29 class CFile 30 : public CObjectTemplate<CFile> 31 , public CFileAttributes 14 32 { 15 /// ////////////////////// Déclarations ////////////////////// /// 33 /// typedef /// 34 typedef CObjectTemplate<CFile> SuperClass; 35 typedef CFileAttributes SuperClassAttribute; 16 36 17 class CFileGroup; 18 class CFileAttributes; 19 class CFile; 37 public : 20 38 21 ///-------------------------------------------------------------- 39 typedef CFileAttributes RelAttributes; 40 typedef CFileGroup RelGroup; 22 41 23 // Declare/Define CFileAttribute 24 BEGIN_DECLARE_ATTRIBUTE_MAP(CFile) 25 #include "file_attribute.conf" 26 END_DECLARE_ATTRIBUTE_MAP(CFile) 42 /// Constructeurs /// 43 CFile(void); 44 explicit CFile(const StdString & id); 45 CFile(const CFile & file); // Not implemented yet. 46 CFile(const CFile * const file); // Not implemented yet. 27 47 28 ///-------------------------------------------------------------- 48 /// Accesseurs /// 49 boost::shared_ptr<CFieldGroup> getVirtualFieldGroup(void) const; 50 std::vector<boost::shared_ptr<CField> > getAllFields(void) const; 29 51 30 class CFile 31 : public CObjectTemplate<CFile> 32 , public CFileAttributes 33 { 34 /// typedef /// 35 typedef CObjectTemplate<CFile> SuperClass; 36 typedef CFileAttributes SuperClassAttribute; 52 std::vector<boost::shared_ptr<CField> > 53 getEnabledFields(int default_outputlevel = 5, 54 int default_level = 1, 55 bool default_enabled = true); 37 56 38 public : 57 /// Mutateurs /// 58 void setVirtualFieldGroup(boost::shared_ptr<CFieldGroup> newVFieldGroup); 59 void setVirtualFieldGroup(const StdString & newVFieldGroupId); 39 60 40 typedef CFileAttributes RelAttributes; 41 typedef CFileGroup RelGroup; 61 void initializeDataOutput(boost::shared_ptr<io::CDataOutput> dout); 42 62 43 /// Constructeurs ///44 CFile(void);45 explicit CFile(const StdString &id);46 CFile(const CFile & file); // Not implemented yet.47 CFile(const CFile * const file); // Not implemented yet.63 /// Traitements /// 64 virtual void solveDescInheritance(const CAttributeMap * const parent = 0); 65 void solveFieldRefInheritance(void); 66 void solveEFGridRef(void); 67 void solveEFOperation(void); 48 68 49 /// Accesseurs /// 50 boost::shared_ptr<CFieldGroup> getVirtualFieldGroup(void) const; 51 std::vector<boost::shared_ptr<CField> > getAllFields(void) const; 69 /// Destructeur /// 70 virtual ~CFile(void); 52 71 53 std::vector<boost::shared_ptr<CField> > 54 getEnabledFields(int default_outputlevel = 5, 55 int default_level = 1, 56 bool default_enabled = true); 72 /// Autres /// 73 virtual void parse(xml::CXMLNode & node); 74 virtual StdString toString(void) const; 57 75 58 /// Mutateurs /// 59 void setVirtualFieldGroup(boost::shared_ptr<CFieldGroup> newVFieldGroup); 60 void setVirtualFieldGroup(const StdString & newVFieldGroupId); 76 /// Accesseurs statiques /// 77 static StdString GetName(void); 78 static StdString GetDefName(void); 79 80 static ENodeType GetType(void); 61 81 62 void initializeDataOutput(boost::shared_ptr<io::CDataOutput> dout);82 private : 63 83 64 /// Traitements /// 65 virtual void solveDescInheritance(const CAttributeMap * const parent = 0); 66 void solveFieldRefInheritance(void); 67 void solveEFGridRef(void); 68 void solveEFOperation(void); 84 /// Propriétés privées /// 85 boost::shared_ptr<CFieldGroup> vFieldGroup; 86 boost::shared_ptr<io::CDataOutput> data_out; 87 std::vector<boost::shared_ptr<CField> > enabledFields; 69 88 70 /// Destructeur /// 71 virtual ~CFile(void); 89 }; // class CFile 72 90 73 /// Autres /// 74 virtual void parse(xml::CXMLNode & node); 75 virtual StdString toString(void) const; 91 ///-------------------------------------------------------------- 76 92 77 /// Accesseurs statiques /// 78 static StdString GetName(void); 79 static StdString GetDefName(void); 93 // Declare/Define CFileGroup and CFileDefinition 94 DECLARE_GROUP(CFile); 80 95 81 private :96 ///-------------------------------------------------------------- 82 97 83 /// Propriétés privées /// 84 boost::shared_ptr<CFieldGroup> vFieldGroup; 85 boost::shared_ptr<io::CDataOutput> data_out; 86 std::vector<boost::shared_ptr<CField> > enabledFields; 87 88 }; // class CFile 89 90 ///-------------------------------------------------------------- 91 92 // Declare/Define CFileGroup and CFileDefinition 93 DECLARE_GROUP(CFile); 94 95 } // namespace tree 98 } // namespace tree 96 99 } // namespace xmlioserver 97 100 -
XMLIO_V2/dev/dev_rv/src/xmlio/node/grid.cpp
r152 r168 5 5 #include "group_template_impl.hpp" 6 6 7 namespace xmlioserver 8 { 9 namespace tree 10 { 11 12 /// ////////////////////// Définitions ////////////////////// /// 13 14 CGrid::CGrid(void) 15 : CObjectTemplate<CGrid>(), CGridAttributes() 16 , withAxis(false), isChecked(false), axis(), domain() 17 , storeIndex(), out_i_index(), out_j_index(), out_l_index() 18 { /* Ne rien faire de plus */ } 19 20 CGrid::CGrid(const StdString & id) 21 : CObjectTemplate<CGrid>(id), CGridAttributes() 22 , withAxis(false), isChecked(false), axis(), domain() 23 , storeIndex(), out_i_index(), out_j_index(), out_l_index() 24 { /* Ne rien faire de plus */ } 25 26 CGrid::~CGrid(void) 27 { /* Ne rien faire de plus */ } 28 29 ///--------------------------------------------------------------- 30 31 StdString CGrid::GetName(void) { return (StdString("grid")); } 32 StdString CGrid::GetDefName(void){ return (CGrid::GetName()); } 33 34 const ARRAY(int, 1) & CGrid::getStoreIndex(void) const 35 { return (this->storeIndex ); } 36 const ARRAY(int, 1) & CGrid::getOutIIndex(void) const 37 { return (this->out_i_index ); } 38 const ARRAY(int, 1) & CGrid::getOutJIndex(void) const 39 { return (this->out_j_index ); } 40 const ARRAY(int, 1) & CGrid::getOutLIndex(void) const 41 { return (this->out_l_index ); } 42 43 const boost::shared_ptr<CAxis> CGrid::getRelAxis (void) const 44 { return (this->axis ); } 45 const boost::shared_ptr<CDomain> CGrid::getRelDomain(void) const 46 { return (this->domain ); } 47 48 bool CGrid::hasAxis(void) const { return (this->withAxis); } 49 50 //--------------------------------------------------------------- 51 52 void CGrid::solveReference(void) 53 { 54 if (this->isChecked) return; 55 this->solveDomainRef() ; 56 this->solveAxisRef() ; 57 this->computeIndex() ; 58 this->isChecked = true; 59 } 60 61 void CGrid::solveDomainRef(void) 62 { 63 if (!domain_ref.isEmpty()) 64 { 65 if (CObjectFactory::HasObject<CDomain>(domain_ref.getValue())) 7 namespace xmlioserver { 8 namespace tree { 9 10 /// ////////////////////// Définitions ////////////////////// /// 11 12 CGrid::CGrid(void) 13 : CObjectTemplate<CGrid>(), CGridAttributes() 14 , withAxis(false), isChecked(false), axis(), domain() 15 , storeIndex(), out_i_index(), out_j_index(), out_l_index() 16 { /* Ne rien faire de plus */ } 17 18 CGrid::CGrid(const StdString & id) 19 : CObjectTemplate<CGrid>(id), CGridAttributes() 20 , withAxis(false), isChecked(false), axis(), domain() 21 , storeIndex(), out_i_index(), out_j_index(), out_l_index() 22 { /* Ne rien faire de plus */ } 23 24 CGrid::~CGrid(void) 25 { /* Ne rien faire de plus */ } 26 27 ///--------------------------------------------------------------- 28 29 StdString CGrid::GetName(void) { return (StdString("grid")); } 30 StdString CGrid::GetDefName(void) { return (CGrid::GetName()); } 31 ENodeType CGrid::GetType(void) { return (eGrid); } 32 33 //---------------------------------------------------------------- 34 35 const ARRAY(int, 1) & CGrid::getStoreIndex(void) const 36 { return (this->storeIndex ); } 37 const ARRAY(int, 1) & CGrid::getOutIIndex(void) const 38 { return (this->out_i_index ); } 39 const ARRAY(int, 1) & CGrid::getOutJIndex(void) const 40 { return (this->out_j_index ); } 41 const ARRAY(int, 1) & CGrid::getOutLIndex(void) const 42 { return (this->out_l_index ); } 43 44 const boost::shared_ptr<CAxis> CGrid::getRelAxis (void) const 45 { return (this->axis ); } 46 const boost::shared_ptr<CDomain> CGrid::getRelDomain(void) const 47 { return (this->domain ); } 48 49 bool CGrid::hasAxis(void) const { return (this->withAxis); } 50 51 //--------------------------------------------------------------- 52 53 void CGrid::solveReference(void) 54 { 55 if (this->isChecked) return; 56 this->solveDomainRef() ; 57 this->solveAxisRef() ; 58 this->computeIndex() ; 59 this->isChecked = true; 60 } 61 62 void CGrid::solveDomainRef(void) 63 { 64 if (!domain_ref.isEmpty()) 65 { 66 if (CObjectFactory::HasObject<CDomain>(domain_ref.getValue())) 67 { 68 this->domain = CObjectFactory::GetObject<CDomain>(domain_ref.getValue()) ; 69 domain->checkAttributes() ; 70 } 71 else ERROR("CGrid::solveDomainRef(void)", 72 << "Référence au domaine incorrecte") ; 73 } 74 else ERROR("CGrid::solveDomainRef(void)", 75 << "Domaine non défini") ; 76 } 77 78 void CGrid::solveAxisRef(void) 79 { 80 if (!axis_ref.isEmpty()) 81 { 82 this->withAxis = true ; 83 if (CObjectFactory::GetObject<CAxis>(axis_ref.getValue())) 84 { 85 this->axis = CObjectFactory::GetObject<CAxis>(axis_ref.getValue()) ; 86 axis->checkAttributes() ; 87 } 88 else ERROR("CGrid::solveAxisRef(void)", 89 << "Référence a l'axe incorrecte") ; 90 } 91 else withAxis = false ; 92 } 93 94 //--------------------------------------------------------------- 95 96 void CGrid::computeIndex(void) 97 { 98 const int ni = domain->ni.getValue() , 99 nj = domain->nj.getValue() , 100 size = (this->hasAxis()) ? axis->size.getValue() : 1 ; 101 102 /*std::cout << ni << " : " 103 << nj << " : " 104 << size << std::endl;*/ 105 106 const int data_dim = domain->data_dim.getValue() , 107 data_n_index = domain->data_n_index.getValue() , 108 data_ibegin = domain->data_ibegin.getValue() , 109 data_jbegin = (data_dim == 2) 110 ? domain->data_jbegin.getValue() : -1; 111 112 ARRAY(int, 1) data_i_index = domain->data_i_index.getValue() , 113 data_j_index = domain->data_j_index.getValue() ; 114 115 /*std::cout << data_n_index << " : " 116 << data_i_index.size() << " : " 117 << data_j_index.size() << std::endl;*/ 118 119 ARRAY(bool, 2) mask = domain->mask.getValue() ; 120 121 int indexCount = 0; 122 123 for(int l = 0; l < size ; l++) 124 { 125 for(int n = 0, i = 0, j = 0; n < data_n_index; n++) 126 { 127 int temp_i = (*data_i_index)[n] + data_ibegin, 128 temp_j = (data_dim == 1) ? -1 129 : (*data_j_index)[n] + data_jbegin; 130 i = (data_dim == 1) ? (temp_i - 2) % ni 131 : (temp_i - 1) ; 132 j = (data_dim == 1) ? (temp_i - 2) / ni 133 : (temp_j - 1) ; 134 135 if ((i >= 0 && i < ni) && 136 (j >= 0 && j < nj) && (*mask)[i][j]) 137 indexCount++ ; 138 } 139 } 140 141 //std::cout << indexCount << std::endl; 142 ARRAY_ASSIGN(this->storeIndex , int, 1, [indexCount]); 143 ARRAY_ASSIGN(this->out_l_index, int, 1, [indexCount]); 144 ARRAY_ASSIGN(this->out_i_index, int, 1, [indexCount]); 145 ARRAY_ASSIGN(this->out_j_index, int, 1, [indexCount]); 146 147 for(int count = 0, indexCount = 0, l = 0; l < size; l++) 148 { 149 for(int n = 0, i = 0, j = 0; n < data_n_index; n++, count++) 150 { 151 int temp_i = (*data_i_index)[n] + data_ibegin, 152 temp_j = (data_dim == 1) ? -1 153 : (*data_j_index)[n] + data_jbegin; 154 i = (data_dim == 1) ? (temp_i - 2) % ni 155 : (temp_i - 1) ; 156 j = (data_dim == 1) ? (temp_i - 2) / ni 157 : (temp_j - 1) ; 158 159 if ((i >= 0 && i < ni) && 160 (j >= 0 && j < nj) && (*mask)[i][j]) 66 161 { 67 this->domain = CObjectFactory::GetObject<CDomain>(domain_ref.getValue()) ; 68 domain->checkAttributes() ; 162 (*this->storeIndex) [indexCount] = count ; 163 (*this->out_l_index)[indexCount] = l ; 164 (*this->out_i_index)[indexCount] = i ; 165 (*this->out_j_index)[indexCount] = j ; 166 indexCount++ ; 69 167 } 70 else ERROR("CGrid::solveDomainRef(void)", 71 << "Référence au domaine incorrecte") ; 72 } 73 else ERROR("CGrid::solveDomainRef(void)", 74 << "Domaine non défini") ; 75 } 76 77 void CGrid::solveAxisRef(void) 78 { 79 if (!axis_ref.isEmpty()) 80 { 81 this->withAxis = true ; 82 if (CObjectFactory::GetObject<CAxis>(axis_ref.getValue())) 83 { 84 this->axis = CObjectFactory::GetObject<CAxis>(axis_ref.getValue()) ; 85 axis->checkAttributes() ; 86 } 87 else ERROR("CGrid::solveAxisRef(void)", 88 << "Référence a l'axe incorrecte") ; 89 } 90 else withAxis = false ; 91 } 92 93 94 void CGrid::computeIndex(void) 95 { 96 const int ni = domain->ni.getValue() , 97 nj = domain->nj.getValue() , 98 size = (this->hasAxis()) ? axis->size.getValue() : 1 ; 99 100 /*std::cout << ni << " : " 101 << nj << " : " 102 << size << std::endl;*/ 103 104 const int data_dim = domain->data_dim.getValue() , 105 data_n_index = domain->data_n_index.getValue() , 106 data_ibegin = domain->data_ibegin.getValue() , 107 data_jbegin = (data_dim == 2) 108 ? domain->data_jbegin.getValue() : -1; 109 110 ARRAY(int, 1) data_i_index = domain->data_i_index.getValue() , 111 data_j_index = domain->data_j_index.getValue() ; 112 113 /*std::cout << data_n_index << " : " 114 << data_i_index.size() << " : " 115 << data_j_index.size() << std::endl;*/ 116 117 ARRAY(bool, 2) mask = domain->mask.getValue() ; 118 119 int indexCount = 0; 120 121 for(int l = 0; l < size ; l++) 122 { 123 for(int n = 0, i = 0, j = 0; n < data_n_index; n++) 124 { 125 int temp_i = (*data_i_index)[n] + data_ibegin, 126 temp_j = (data_dim == 1) ? -1 127 : (*data_j_index)[n] + data_jbegin; 128 i = (data_dim == 1) ? (temp_i - 2) % ni 129 : (temp_i - 1) ; 130 j = (data_dim == 1) ? (temp_i - 2) / ni 131 : (temp_j - 1) ; 132 133 if ((i >= 0 && i < ni) && 134 (j >= 0 && j < nj) && (*mask)[i][j]) 135 indexCount++ ; 136 } 137 } 138 //std::cout << indexCount << std::endl; 139 ARRAY_ASSIGN(this->storeIndex , int, 1, [indexCount]); 140 ARRAY_ASSIGN(this->out_l_index, int, 1, [indexCount]); 141 ARRAY_ASSIGN(this->out_i_index, int, 1, [indexCount]); 142 ARRAY_ASSIGN(this->out_j_index, int, 1, [indexCount]); 143 144 for(int count = 0, indexCount = 0, l = 0; l < size; l++) 145 { 146 for(int n = 0, i = 0, j = 0; n < data_n_index; n++, count++) 147 { 148 int temp_i = (*data_i_index)[n] + data_ibegin, 149 temp_j = (data_dim == 1) ? -1 150 : (*data_j_index)[n] + data_jbegin; 151 i = (data_dim == 1) ? (temp_i - 2) % ni 152 : (temp_i - 1) ; 153 j = (data_dim == 1) ? (temp_i - 2) / ni 154 : (temp_j - 1) ; 155 156 if ((i >= 0 && i < ni) && 157 (j >= 0 && j < nj) && (*mask)[i][j]) 158 { 159 (*this->storeIndex)[indexCount] = count ; 160 (*this->out_l_index)[indexCount] = l ; 161 (*this->out_i_index)[indexCount] = i ; 162 (*this->out_j_index)[indexCount] = j ; 163 indexCount++ ; 164 } 165 } 166 } 167 } 168 169 //---------------------------------------------------------------- 170 boost::shared_ptr<CGrid> 171 CGrid::CreateGrid(boost::shared_ptr<CDomain> domain) 172 { 173 StdString new_id = StdString("__") + domain->getId() + StdString("__") ; 174 boost::shared_ptr<CGrid> grid = 175 CGroupFactory::CreateChild(CObjectFactory::GetObject<CGridGroup> ("grid_definition"), new_id); 176 grid->domain_ref.setValue(domain->getId()); 177 return (grid); 178 } 179 180 boost::shared_ptr<CGrid> 181 CGrid::CreateGrid(boost::shared_ptr<CDomain> domain, boost::shared_ptr<CAxis> axis) 182 { 183 StdString new_id = StdString("__") + domain->getId() + 184 StdString("_") + axis->getId() + StdString("__") ; 185 boost::shared_ptr<CGrid> grid = 186 CGroupFactory::CreateChild(CObjectFactory::GetObject<CGridGroup> ("grid_definition"), new_id); 187 grid->domain_ref.setValue(domain->getId()); 188 grid->axis_ref.setValue(axis->getId()); 189 return (grid); 190 } 191 192 //---------------------------------------------------------------- 193 194 template <> 195 void CGrid::outputField 196 (const ARRAY(double, 1) stored, ARRAY(double, 3) field) const 197 { 198 for(StdSize n = 0; n < storeIndex->num_elements(); n++) 199 (*field)[(*out_i_index)[n]][(*out_j_index)[n]][(*out_l_index)[n]] = (*stored)[n] ; 200 } 201 202 template <> 203 void CGrid::outputField 204 (const ARRAY(double, 1) stored, ARRAY(double, 2) field) const 205 { 206 for(StdSize n = 0; n < storeIndex->num_elements(); n++) 207 (*field)[(*out_i_index)[n]][(*out_j_index)[n]] = (*stored)[n] ; 208 } 209 210 template <> 211 void CGrid::outputField 212 (const ARRAY(double, 1) stored, ARRAY(double, 1) field) const 213 { 214 for(StdSize n = 0; n < storeIndex->num_elements(); n++) 215 (*field)[(*out_i_index)[n]] = (*stored)[n] ; 216 } 217 218 void CGrid::storeField_arr 219 (const double * const data, ARRAY(double, 1) stored) const 220 { 221 const StdSize size = storeIndex->num_elements() ; 222 stored->resize(boost::extents[size]) ; 223 for(StdSize i = 0; i < size; i++) 224 (*stored)[i] = data[(*storeIndex)[i]] ; 225 } 226 227 ///--------------------------------------------------------------- 228 229 } // namespace tree 168 } 169 } 170 } 171 172 //---------------------------------------------------------------- 173 174 boost::shared_ptr<CGrid> 175 CGrid::CreateGrid(boost::shared_ptr<CDomain> domain) 176 { 177 StdString new_id = StdString("__") + domain->getId() + StdString("__") ; 178 boost::shared_ptr<CGrid> grid = 179 CGroupFactory::CreateChild(CObjectFactory::GetObject<CGridGroup> ("grid_definition"), new_id); 180 grid->domain_ref.setValue(domain->getId()); 181 return (grid); 182 } 183 184 boost::shared_ptr<CGrid> 185 CGrid::CreateGrid(boost::shared_ptr<CDomain> domain, boost::shared_ptr<CAxis> axis) 186 { 187 StdString new_id = StdString("__") + domain->getId() + 188 StdString("_") + axis->getId() + StdString("__") ; 189 boost::shared_ptr<CGrid> grid = 190 CGroupFactory::CreateChild(CObjectFactory::GetObject<CGridGroup> ("grid_definition"), new_id); 191 grid->domain_ref.setValue(domain->getId()); 192 grid->axis_ref.setValue(axis->getId()); 193 return (grid); 194 } 195 196 //---------------------------------------------------------------- 197 198 template <> 199 void CGrid::outputField 200 (const ARRAY(double, 1) stored, ARRAY(double, 3) field) const 201 { 202 for(StdSize n = 0; n < storeIndex->num_elements(); n++) 203 (*field)[(*out_i_index)[n]][(*out_j_index)[n]][(*out_l_index)[n]] = (*stored)[n] ; 204 } 205 206 template <> 207 void CGrid::outputField 208 (const ARRAY(double, 1) stored, ARRAY(double, 2) field) const 209 { 210 for(StdSize n = 0; n < storeIndex->num_elements(); n++) 211 (*field)[(*out_i_index)[n]][(*out_j_index)[n]] = (*stored)[n] ; 212 } 213 214 template <> 215 void CGrid::outputField 216 (const ARRAY(double, 1) stored, ARRAY(double, 1) field) const 217 { 218 for(StdSize n = 0; n < storeIndex->num_elements(); n++) 219 (*field)[(*out_i_index)[n]] = (*stored)[n] ; 220 } 221 222 //---------------------------------------------------------------- 223 224 void CGrid::storeField_arr 225 (const double * const data, ARRAY(double, 1) stored) const 226 { 227 const StdSize size = storeIndex->num_elements() ; 228 stored->resize(boost::extents[size]) ; 229 for(StdSize i = 0; i < size; i++) 230 (*stored)[i] = data[(*storeIndex)[i]] ; 231 } 232 233 ///--------------------------------------------------------------- 234 235 } // namespace tree 230 236 } // namespace xmlioserver -
XMLIO_V2/dev/dev_rv/src/xmlio/node/grid.hpp
r157 r168 10 10 #include "axis.hpp" 11 11 12 namespace xmlioserver 13 { 14 namespace tree 12 namespace xmlioserver { 13 namespace tree { 14 15 /// ////////////////////// Déclarations ////////////////////// /// 16 17 class CGridGroup; 18 class CGridAttributes; 19 class CGrid; 20 21 ///-------------------------------------------------------------- 22 23 // Declare/Define CGridAttribute 24 BEGIN_DECLARE_ATTRIBUTE_MAP(CGrid) 25 #include "grid_attribute.conf" 26 END_DECLARE_ATTRIBUTE_MAP(CGrid) 27 28 ///-------------------------------------------------------------- 29 30 class CGrid 31 : public CObjectTemplate<CGrid> 32 , public CGridAttributes 15 33 { 16 /// ////////////////////// Déclarations ////////////////////// /// 34 /// typedef /// 35 typedef CObjectTemplate<CGrid> SuperClass; 36 typedef CGridAttributes SuperClassAttribute; 17 37 18 class CGridGroup; 19 class CGridAttributes; 20 class CGrid; 38 public : 21 39 22 ///-------------------------------------------------------------- 40 typedef CGridAttributes RelAttributes; 41 typedef CGridGroup RelGroup; 23 42 24 // Declare/Define CGridAttribute 25 BEGIN_DECLARE_ATTRIBUTE_MAP(CGrid) 26 #include "grid_attribute.conf" 27 END_DECLARE_ATTRIBUTE_MAP(CGrid) 43 /// Constructeurs /// 44 CGrid(void); 45 explicit CGrid(const StdString & id); 46 CGrid(const CGrid & grid); // Not implemented yet. 47 CGrid(const CGrid * const grid); // Not implemented yet. 28 48 29 ///-------------------------------------------------------------- 49 /// Traitements /// 50 void solveReference(void); 30 51 31 class CGrid 32 : public CObjectTemplate<CGrid> 33 , public CGridAttributes 34 { 35 /// typedef /// 36 typedef CObjectTemplate<CGrid> SuperClass; 37 typedef CGridAttributes SuperClassAttribute; 52 /// Tests /// 53 bool hasAxis(void) const; 38 54 39 55 public : 40 56 41 typedef CGridAttributes RelAttributes; 42 typedef CGridGroup RelGroup; 57 /// Accesseurs /// 58 const ARRAY(int, 1) & getStoreIndex(void) const; 59 const ARRAY(int, 1) & getOutIIndex(void) const; 60 const ARRAY(int, 1) & getOutJIndex(void) const; 61 const ARRAY(int, 1) & getOutLIndex(void) const; 43 62 44 /// Constructeurs /// 45 CGrid(void); 46 explicit CGrid(const StdString & id); 47 CGrid(const CGrid & grid); // Not implemented yet. 48 CGrid(const CGrid * const grid); // Not implemented yet. 63 const boost::shared_ptr<CAxis> getRelAxis (void) const; 64 const boost::shared_ptr<CDomain> getRelDomain(void) const; 49 65 50 /// Traitements /// 51 void solveReference(void); 66 /// Entrées-sorties de champs /// 67 template <StdSize n> 68 void inputField(const ARRAY(double, n) field, ARRAY(double, 1) stored) const; 52 69 53 /// Tests ///54 bool hasAxis(void) const;70 template <StdSize n> 71 void outputField(const ARRAY(double, 1) stored, ARRAY(double, n) field) const; 55 72 56 public : 73 /// Destructeur /// 74 virtual ~CGrid(void); 57 75 58 /// Accesseurs /// 59 const ARRAY(int, 1) & getStoreIndex(void) const; 60 const ARRAY(int, 1) & getOutIIndex(void) const; 61 const ARRAY(int, 1) & getOutJIndex(void) const; 62 const ARRAY(int, 1) & getOutLIndex(void) const; 76 public : 63 77 64 const boost::shared_ptr<CAxis> getRelAxis (void) const; 65 const boost::shared_ptr<CDomain> getRelDomain(void) const; 78 /// Accesseurs statiques /// 79 static StdString GetName(void); 80 static StdString GetDefName(void); 81 82 static ENodeType GetType(void); 66 83 67 /// Entrées-sorties de champs /// 68 template <StdSize n> 69 void inputField(const ARRAY(double, n) field, ARRAY(double, 1) stored) const; 84 /// Instanciateurs Statiques /// 85 static boost::shared_ptr<CGrid> 86 CreateGrid(boost::shared_ptr<CDomain> domain); 87 static boost::shared_ptr<CGrid> 88 CreateGrid(boost::shared_ptr<CDomain> domain, boost::shared_ptr<CAxis> axis); 70 89 71 template <StdSize n> 72 void outputField(const ARRAY(double, 1) stored, ARRAY(double, n) field) const; 90 protected : 73 91 74 /// Destructeur///75 virtual ~CGrid(void);92 /// Entrées-sorties de champs (interne) /// 93 void storeField_arr(const double * const data, ARRAY(double, 1) stored) const; 76 94 77 public : 95 /// Traitements protégés /// 96 void computeIndex(void); 97 void solveDomainRef(void); 98 void solveAxisRef(void); 78 99 79 /// Accesseurs statiques /// 80 static StdString GetName(void); 81 static StdString GetDefName(void); 100 private: 82 101 83 /// Instanciateurs Statiques /// 84 static boost::shared_ptr<CGrid> 85 CreateGrid(boost::shared_ptr<CDomain> domain); 86 static boost::shared_ptr<CGrid> 87 CreateGrid(boost::shared_ptr<CDomain> domain, boost::shared_ptr<CAxis> axis); 102 /// Propriétés privées /// 103 bool withAxis ; 104 bool isChecked; 88 105 89 protected : 106 boost::shared_ptr<CAxis> axis ; 107 boost::shared_ptr<CDomain> domain ; 90 108 91 /// Entrées-sorties de champs (interne) /// 92 void storeField_arr(const double * const data, ARRAY(double, 1) stored) const; 109 ARRAY(int, 1) storeIndex ; 110 ARRAY(int, 1) out_i_index ; 111 ARRAY(int, 1) out_j_index ; 112 ARRAY(int, 1) out_l_index ; 93 113 94 /// Traitements protégés /// 95 void computeIndex(void); 96 void solveDomainRef(void); 97 void solveAxisRef(void); 114 }; // class CGrid 98 115 99 private:116 ///-------------------------------------------------------------- 100 117 101 /// Propriétés privées ///102 bool withAxis ;103 bool isChecked;118 template <StdSize n> 119 void CGrid::inputField(const ARRAY(double, n) field, ARRAY(double, 1) stored) const 120 { this->storeField_arr(field.data(), stored) ; } 104 121 105 boost::shared_ptr<CAxis> axis ; 106 boost::shared_ptr<CDomain> domain ; 122 ///-------------------------------------------------------------- 107 123 108 ARRAY(int, 1) storeIndex ; 109 ARRAY(int, 1) out_i_index ; 110 ARRAY(int, 1) out_j_index ; 111 ARRAY(int, 1) out_l_index ; 124 // Declare/Define CGridGroup and CGridDefinition 125 DECLARE_GROUP(CGrid); 112 126 113 }; // class CGrid127 ///-------------------------------------------------------------- 114 128 115 ///-------------------------------------------------------------- 116 117 template <StdSize n> 118 void CGrid::inputField(const ARRAY(double, n) field, ARRAY(double, 1) stored) const 119 { this->storeField_arr(field.data(), stored) ; } 120 121 // Declare/Define CGridGroup and CGridDefinition 122 DECLARE_GROUP(CGrid); 123 124 } // namespace tree 129 } // namespace tree 125 130 } // namespace xmlioserver 126 131 -
XMLIO_V2/dev/dev_rv/src/xmlio/object_template.hpp
r157 r168 31 31 32 32 virtual void parse(xml::CXMLNode & node); 33 34 /// Accesseurs /// 35 tree::ENodeType getType(void) const; 33 36 34 37 /// Test /// … … 39 42 40 43 /// Accesseur statique /// 41 static std::vector<boost::shared_ptr<DerivedType> > & GetAllVectobject(const StdString & contextId); 44 static std::vector<boost::shared_ptr<DerivedType> > & 45 GetAllVectobject(const StdString & contextId); 42 46 43 47 /// Destructeur /// -
XMLIO_V2/dev/dev_rv/src/xmlio/object_template_impl.hpp
r152 r168 68 68 CAttributeMap::setAttributes(attributes); 69 69 } 70 71 template <class T> 72 tree::ENodeType CObjectTemplate<T>::getType(void) const 73 { 74 return (T::GetType()); 75 } 70 76 71 77 template <class T>
Note: See TracChangeset
for help on using the changeset viewer.