From 498e5870122148567d0fad776545f1b76c9849e7 Mon Sep 17 00:00:00 2001 From: Pierre Kraemer Date: Fri, 28 Jan 2011 10:00:07 +0100 Subject: [PATCH] Suppression du INIT_STATICS + code mort registered attributes.. --- Apps/Examples/SocialAgents/include/viewer.h | 3 - Apps/Examples/miniTest.cpp | 2 - include/Container/attr_register.h | 169 -------------------- include/Container/attrib_container.hpp | 17 -- include/Container/registered.h | 5 +- include/Topology/generic/genericmap.h | 6 - include/Topology/generic/genericmap.hpp | 2 - src/Topology/generic/genericmap.cpp | 3 + 8 files changed, 5 insertions(+), 202 deletions(-) delete mode 100644 include/Container/attr_register.h diff --git a/Apps/Examples/SocialAgents/include/viewer.h b/Apps/Examples/SocialAgents/include/viewer.h index b137918ce..18766f9ca 100644 --- a/Apps/Examples/SocialAgents/include/viewer.h +++ b/Apps/Examples/SocialAgents/include/viewer.h @@ -42,11 +42,8 @@ // #include "Algo/Render/topo_vboRender.h" #include "Algo/Render/topo_render.h" - using namespace CGoGN ; -INIT_STATICS_MAP() ; - typedef PFP::MAP MAP; class MyGlutWin : public Utils::GlutWin_ATB diff --git a/Apps/Examples/miniTest.cpp b/Apps/Examples/miniTest.cpp index 681e8d8f1..f72e05e6b 100644 --- a/Apps/Examples/miniTest.cpp +++ b/Apps/Examples/miniTest.cpp @@ -65,8 +65,6 @@ struct PFP typedef AttributeHandler TRGBFUNCS; }; -INIT_STATICS_MAP() ; - typedef PFP::MAP MAP; MAP myMap ; diff --git a/include/Container/attr_register.h b/include/Container/attr_register.h deleted file mode 100644 index d30c52e94..000000000 --- a/include/Container/attr_register.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * attr_register.h - * - * Created on: May 28, 2010 - * Author: thery - */ - - - -#include -#include - -#include -#include -#include "attrib_container.h" - - -namespace CGoGN -{ - -/** - * Classe d'enregistrement d'attribut a - */ -class RegisteredAttribute -{ -protected: - std::string m_name; - -public: - /** - * affecte un nom de type a l'attribut - */ - void setTypeName(const std::string& nameType) { n_name = nameType;} - - /** - * recupere le nom de type affecté à l'attribut - */ - const std::string& getTypeName() { return m_name;} - - /** - * Ajout de l'attribut au container (A INMPLEMENTER) - */ - virtual AttribContainer::Attr_Id addAttribute(AttribContainer& container, const std::string& attribName, unsigned int id)=0; - - /** - * Lecture en XML d'une donnée et la met dans le container (A INMPLEMENTER) - */ - virtual bool readXml(xmlNode* node, AttribContainer& container, unsigned int att_id, unsigned int index); - - /** - * Ecriture des elements dans un arbre XML (A INMPLEMENTER) - */ - virtual bool writeXml(xmlTextWriterPtr writer, const AttribContainer& container, unsigned int att_id); - - /** - * Lecture binaire (A INMPLEMENTER) - */ - virtual bool readBin(const std::fstream& fs, AttribContainer& container, unsigned int att_id); - - /** - * Ecriture binaire (A INMPLEMENTER) - */ - virtual bool writeBin(std::fstream& fs, const AttribContainer& container, unsigned int att_id); - -}; - -// version template du type qui marche -// -/** - * Version template de la classe d'enregistrement d'attribut - * Fonction avec tout type qui répond aux contraintes suivantes: - * - I/O avec les flux (operator >> et <<) - * - copie mémoire directe utilisable (pas de pointeurs dans la structure) - */ -template -class RegisteredAttributeSimple : RegisteredAttribute -{ - -public: - - AttribContainer::Attr_Id addAttribute(AttribContainer& container, const std::string& attribName, unsigned int id) - { - container.addAttribute(attribName, id); - } - - void readXml(xmlNodePtr node, AttribContainer& container, unsigned int codeAttrib) - { - // recuperer le pseudo-tableau d'attribut - AttribManager& atm = container.getDataVector(codeAttrib); - AttribContainer::iterator i = container.begin(); - - std::stringstream ss; - // lit tous les attributs dans le noeud xml et les inserts dans le container - for (xmlNode* cur = node->children; cur!=NULL; cur = cur->next) - { - //std::string st((char*)(xmlNodeGetContent(cur))); - ss.str( std::string((char*)(xmlNodeGetContent(cur))) ); - ss >> atm[i]; - container.next(i); - } - } - - - void writeXml(xmlTextWriterPtr writer, const AttribContainer& container, unsigned int codeAttrib) - { - // recuperer le pseudo-tableau d'attribut - const AttribManager& atm = container.getDataVector(codeAttrib); - - std::stringstream ss; - // parcours le tableau avec un iterateur du container et ecrit les elements - for (AttribContainer::const_iterator i = container.begin(); i != container.end(); container.next(i)) - { - ss << atm[i]; - rc = xmlTextWriterWriteElement(writer, BAD_CAST "val ", (xmlChar*)(ss.str().c_str())); - ss.str(""); - } - } - - - bool readBin(const std::fstream& fs, AttribContainer& container, unsigned int att_id) - { - // recupere les pointeurs et longueurs des zones contigues dans le container - std::vector vect_adr; - std::vector vect_len; - unsigned int nb = container.getAddresses(att_id, vect_adr, vect_len); - - // lit les zones directement depuis le fichier - for (int i=0;i(vect_adr[i]),vect_len[i]*sizeof(T)); - } - - - bool writeBin(std::fstream& fs, const AttribContainer& container, unsigned int att_id) - { - // recupere les pointeurs et longueurs des zones contigues dans le container - std::vector vect_adr; - std::vector vect_len; - unsigned int nb = container.getAddresses(att_id, vect_adr, vect_len); - - // ecrit les zones directement dans le fichier - for (int i=0;i(vect_adr[i]),vect_len[i]*sizeof(T)); - } -}; - - - - - -template -bool registerAttribute(const std::string &nameType) -{ - R* rc = new RegisteredAttributeSimple; - RegisteredAttribute* ra = dynamic_cast(rc); - - if (ra == NULL) - { - std::err << "Erreur enregistrement attribut"<setTypeName(nametype); - - m_attributes_registry_map.insert(std::pair(nametype),ra); - -} - -} -// registerAttribute< Vec3f >(std::string("Vec3f")); diff --git a/include/Container/attrib_container.hpp b/include/Container/attrib_container.hpp index 71a5fb332..1f2f92b48 100644 --- a/include/Container/attrib_container.hpp +++ b/include/Container/attrib_container.hpp @@ -191,23 +191,6 @@ unsigned int AttribContainer::getAddresses(unsigned int attr, std::vector& v // Enregistrement attributs ////////////////////////////// -//template -//bool AttribContainer::registerAttribute(const std::string &nameType) -//{ -// RegisteredBasedAttribute* ra = new RegisteredAttribute; -// if (ra == NULL) -// { -// std::cerr << "Erreur enregistrement attribut"<setTypeName(nameType); -// -// m_attributes_registry_map->insert(std::pair(nameType,ra)); -// return true; -//} - - //// INLINED FUNCTIONS inline bool AttribContainer::used(unsigned int eltIdx) const { diff --git a/include/Container/registered.h b/include/Container/registered.h index 8ca393d95..d5fd831a6 100644 --- a/include/Container/registered.h +++ b/include/Container/registered.h @@ -23,12 +23,12 @@ public: /** * affecte un nom de type a l'attribut */ - void setTypeName(const std::string& nameType) { m_name = nameType;} + void setTypeName(const std::string& nameType) { m_name = nameType; } /** * recupere le nom de type affecté à l'attribut */ - const std::string& getTypeName() { return m_name;} + const std::string& getTypeName() { return m_name; } /** * Ajout de l'attribut au container (A INMPLEMENTER) @@ -61,4 +61,3 @@ public: } #endif /* REGISTRED_H_ */ - diff --git a/include/Topology/generic/genericmap.h b/include/Topology/generic/genericmap.h index 418e917ad..ade25a0cc 100644 --- a/include/Topology/generic/genericmap.h +++ b/include/Topology/generic/genericmap.h @@ -51,12 +51,6 @@ #include "Topology/generic/functor.h" -// Small macro to init static members -// to be called in main just after the PFP declaration -#define INIT_STATICS_MAP() \ - std::map< std::string, RegisteredBaseAttribute* > GenericMap::m_attributes_registry_map = std::map< std::string, RegisteredBaseAttribute* >(); - - namespace CGoGN { diff --git a/include/Topology/generic/genericmap.hpp b/include/Topology/generic/genericmap.hpp index b91eed8ff..39b73502d 100644 --- a/include/Topology/generic/genericmap.hpp +++ b/include/Topology/generic/genericmap.hpp @@ -22,8 +22,6 @@ * * *******************************************************************************/ -#include "Container/registered.h" - namespace CGoGN { diff --git a/src/Topology/generic/genericmap.cpp b/src/Topology/generic/genericmap.cpp index a64020ca4..0d9d9bc19 100644 --- a/src/Topology/generic/genericmap.cpp +++ b/src/Topology/generic/genericmap.cpp @@ -26,10 +26,13 @@ #include "Topology/generic/dartmarker.h" #include "Geometry/vector_gen.h" #include "Geometry/matrix.h" +#include "Container/registered.h" namespace CGoGN { +std::map< std::string, RegisteredBaseAttribute* > GenericMap::m_attributes_registry_map = std::map< std::string, RegisteredBaseAttribute* >(); + GenericMap::GenericMap() { // register all known types -- GitLab