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>
51 #define TYDIRPREFERENCEMANAGER "UserPreferences"
64 #define OPROTODECL(classname) \
66 virtual OPrototype* clone() const \
68 return new classname(); \
70 virtual const char* getClassName() const \
74 static classname* safeDownCast(OPrototype* pObject) \
78 classname* pTypedObject = dynamic_cast<classname*>(pObject); \
79 if (pTypedObject != nullptr) \
81 return pTypedObject; \
261 bool isA(
const char* className)
const;
284 virtual std::unique_ptr<OPrototype>
make() = 0;
300 static_assert(std::is_base_of<OPrototype, T>::value,
"Factory<T> : T must inherit from OPrototype");
306 virtual std::unique_ptr<OPrototype>
make()
329 static std::unordered_map<std::string, IOProtoFactory::ptr_type>
_factory_map;
339 template <
typename T> std::unique_ptr<OPrototype::Factory<T>>
build_factory()
355 #define TY_EXTENSION_DECL(classname) \
356 friend class classname; \
359 virtual TYEditWidget* getEditWidget() \
361 return new classname##Widget(this); \
364 #define TY_EXTENSION_DECL(classname) \
366 virtual TYEditWidget* getEditWidget() \
368 return new classname##Widget(this); \
372 #define TY_EXTENSION_DECL_ONLY(classname) \
374 virtual TYEditWidget* getEditWidget();
376 #define TY_EXTENSION_INST(classname) \
377 TYEditWidget* classname::getEditWidget() \
379 return new classname##Widget(this); \
384 #define TY_EXTENSION_DECL(classname)
385 #define TY_EXTENSION_DECL_ONLY(classname)
386 #define TY_EXTENSION_INST(classname)
395 #define TY_EXT_GRAPHIC_DECL(classname) \
396 friend class classname; \
399 virtual LPTYElementGraphic getGraphicObject() \
401 if (!_pGraphicObject) \
402 _pGraphicObject = new classname##Graphic(this); \
403 return _pGraphicObject; \
406 #define TY_EXT_GRAPHIC_DECL(classname) \
408 virtual LPTYElementGraphic getGraphicObject() \
410 if (!_pGraphicObject) \
411 _pGraphicObject = new classname##Graphic(this); \
412 return _pGraphicObject; \
416 #define TY_EXT_GRAPHIC_DECL_ONLY(classname) \
418 virtual LPTYElementGraphic getGraphicObject();
420 #define TY_EXT_GRAPHIC_INST(classname) \
421 LPTYElementGraphic classname::getGraphicObject() \
423 if (!_pGraphicObject) \
424 _pGraphicObject = new classname##Graphic(this); \
425 return _pGraphicObject; \
429 #define TY_EXT_GRAPHIC_DECL(classname)
430 #define TY_EXT_GRAPHIC_DECL_ONLY(classname)
431 #define TY_EXT_GRAPHIC_INST(classname)
442 return T::safeDownCast(elt);
535 virtual void setInCurrentCalcul(
bool state,
bool recurschild =
true,
bool recursparent =
true);
598 void drawGraphic(
bool draw =
true);
603 virtual void updateGraphic();
608 virtual void updateGraphicTree();
651 void setID(
const QString& str_id);
662 return getID().toString();
667 return _uuid.isNull();
770 virtual bool deepCopy(
const TYElement* pOther,
bool copyId =
true,
bool pUseCopyTag =
false);
1010 return qstr.toLocal8Bit().data();
1016 QTextStream str(&msg);
1027 inline QDebug
_debugXml(
const char* expr,
const QDomNode& node)
1032 #define debugXml(expr) _debugXml(#expr, (expr))
1034 #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
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()
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