16 #ifndef __TY_ELEMENT__
17 #define __TY_ELEMENT__
27 #pragma warning(disable : 4275 4800 4355 4273 4786 4018 4503 4081)
31 #include <unordered_map>
34 #include <boost/exception/error_info.hpp>
52 #define TYDIRPREFERENCEMANAGER "UserPreferences"
65 #define OPROTODECL(classname) \
67 virtual OPrototype* clone() const \
69 return new classname(); \
71 virtual const char* getClassName() const \
75 static classname* safeDownCast(OPrototype* pObject) \
79 classname* pTypedObject = dynamic_cast<classname*>(pObject); \
80 if (pTypedObject != nullptr) \
82 return pTypedObject; \
262 bool isA(
const char* className)
const;
285 virtual std::unique_ptr<OPrototype>
make() = 0;
301 static_assert(std::is_base_of<OPrototype, T>::value,
"Factory<T> : T must inherit from OPrototype");
307 virtual std::unique_ptr<OPrototype>
make()
330 static std::unordered_map<std::string, IOProtoFactory::ptr_type>
_factory_map;
340 template <
typename T> std::unique_ptr<OPrototype::Factory<T>>
build_factory()
356 #define TY_EXTENSION_DECL(classname) \
357 friend class classname; \
360 virtual TYEditWidget* getEditWidget() \
362 return new classname##Widget(this); \
365 #define TY_EXTENSION_DECL(classname) \
367 virtual TYEditWidget* getEditWidget() \
369 return new classname##Widget(this); \
373 #define TY_EXTENSION_DECL_ONLY(classname) \
375 virtual TYEditWidget* getEditWidget();
377 #define TY_EXTENSION_INST(classname) \
378 TYEditWidget* classname::getEditWidget() \
380 return new classname##Widget(this); \
385 #define TY_EXTENSION_DECL(classname)
386 #define TY_EXTENSION_DECL_ONLY(classname)
387 #define TY_EXTENSION_INST(classname)
396 #define TY_EXT_GRAPHIC_DECL(classname) \
397 friend class classname; \
400 virtual LPTYElementGraphic getGraphicObject() \
402 if (!_pGraphicObject) \
403 _pGraphicObject = new classname##Graphic(this); \
404 return _pGraphicObject; \
407 #define TY_EXT_GRAPHIC_DECL(classname) \
409 virtual LPTYElementGraphic getGraphicObject() \
411 if (!_pGraphicObject) \
412 _pGraphicObject = new classname##Graphic(this); \
413 return _pGraphicObject; \
417 #define TY_EXT_GRAPHIC_DECL_ONLY(classname) \
419 virtual LPTYElementGraphic getGraphicObject();
421 #define TY_EXT_GRAPHIC_INST(classname) \
422 LPTYElementGraphic classname::getGraphicObject() \
424 if (!_pGraphicObject) \
425 _pGraphicObject = new classname##Graphic(this); \
426 return _pGraphicObject; \
431 #define TY_EXT_GRAPHIC_DECL(classname)
432 #define TY_EXT_GRAPHIC_DECL_ONLY(classname)
433 #define TY_EXT_GRAPHIC_INST(classname)
444 return T::safeDownCast(elt);
537 virtual void setInCurrentCalcul(
bool state,
bool recurschild =
true,
bool recursparent =
true);
591 void drawGraphic(
bool draw =
true);
596 virtual void updateGraphic();
601 virtual void updateGraphicTree();
644 void setID(
const QString& str_id);
655 return getID().toString();
660 return _uuid.isNull();
771 virtual bool deepCopy(
const TYElement* pOther,
bool copyId =
true,
bool pUseCopyTag =
false);
1014 return qstr.toLocal8Bit().data();
1020 QTextStream str(&msg);
1031 inline QDebug
_debugXml(
const char* expr,
const QDomNode& node)
1036 #define debugXml(expr) _debugXml(#expr, (expr))
1038 #define debugXml(expr) ((void)0)
void TYEditWidget
Declarations de types pour l'API IHM et l'Impression.
std::list< TYUUID > TYListID
Collection d'identifiants.
Representation graphique d'un element de base (fichier header)
QDebug _debugXml(const char *expr, const QDomNode &node)
std::unique_ptr< OPrototype::Factory< T > > build_factory()
const char * str_qt2c(const QString &qstr)
std::vector< LPTYElement > LPTYElementArray
T * downcast(TYElement *elt)
void * LPTYElementGraphic
#define OPROTODECL(classname)
std::map< TYUUID, TYElement * > TYElementContainer
const char * xml2cstring(const QDomNode &node)
QString xml2qstring(const QDomNode &node)
virtual std::unique_ptr< OPrototype > make()
std::unique_ptr< T > ptr_type
virtual std::unique_ptr< OPrototype > make()=0
std::unique_ptr< IOProtoFactory > ptr_type
static std::unordered_map< std::string, IOProtoFactory::ptr_type > _factory_map
static void add_factory(const char *, IOProtoFactory::ptr_type factory)
virtual OPrototype * clone() const =0
static int findPrototype(const char *className)
virtual const char * getClassName() const
static OPrototype * safeDownCast(OPrototype *pObject)
static OPrototype * findAndClone(const char *className)
bool isA(const char *className) const
bool getIsGeometryModified()
static uint64 ty_regen_id_counter
static TYElementContainer & getInstances()
TYElement * getParent() const
void setName(QString name)
virtual bool isInCurrentCalcul()
static bool _logInstances
Indique si on souhaite registrer toutes les instances de type TYElement et derivees.
static void setLogInstances(bool log)
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
TYUUID _uuid
Identifiant unique de l'element.
static void setIsSavedOk(const bool &toSave)
virtual DOM_Element toXML(DOM_Element &domElement)
void setCopyCount(const unsigned int copyCount)
Modifie la vaeur du compteur.
std::string getMetierName()
bool _isGeometryModified
Indicateur de modification de la geometrie.
QString _name
Nom courant de l'element.
bool operator==(const TYElement &other) const
static void purgeInstances()
static bool getRegenerateID()
TYElement & operator=(const TYElement &other)
static TYUUID fromString(QString id)
void OnChildInCalculStatusChange()
static uint64 getConstructorCount()
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
static bool testId(const TYUUID &id, const TYElement *pElem)
static bool getLogInstances()
static uint64 getIdGenerationCount()
bool _isAcousticModified
Indicateur de modification acoustique.
static uint64 getDestructorCount()
void addCopy()
Increment le compteur de nombre de copies.
const TYUUID & getID() const
bool operator!=(const TYElement &other) const
void * _allUses
Multi purpose void pointer (use for compatibility actually)
virtual std::string toString() const
virtual QString getName() const
TYElement * _pParent
Reference sur l'element parent.
virtual void updateCurrentCalcul(TYListID &listID, bool recursif=true)
bool getIsAcousticModified()
LPTYElementGraphic _pGraphicObject
L'object graphique metier associe a cet element.
virtual void setInCurrentCalcul(bool state, bool recurschild=true, bool recursparent=true)
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
static void setRegenerateID(const bool &bRegenerate)
void setName(std::string name)
static TYElementContainer * _instances
Collection de toutes les instances de type TYElement et derivees.
bool _inCurrentCalcul
Indique si cet element est actif dans le Calcul courant.
void setParent(TYElement *pParent)
static LPTYElementArray findTypeCollectionAndCallFromXML(DOM_Element parentElem, const char *type)
virtual int fromXML(DOM_Element domElement)
void setAllUses(void *allUses)
QString getStringID() const
virtual void setIsAcousticModified(bool isModified)
static uint64 ty_destroyed_counter
static bool getIsSavedOk()
static uint64 ty_created_counter
static TYElement * getInstance(TYUUID uuid)
static bool _bRegenerateID
Indicateur de regeneration d'ID true si regeneration d'ID a la lecture d'un fichier XML.
virtual void setIsGeometryModified(bool isModified)
This file provides class for solver configuration.
unsigned long long uint64
boost::error_info< struct tag_classname, std::string > oproto_classname_errinfo