mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Move to use a static registry of scriptable classes
This commit is contained in:
@@ -77,8 +77,6 @@ class PdmObjectCapability;
|
||||
#define CAF_PDM_SOURCE_INIT CAF_PDM_XML_SOURCE_INIT
|
||||
#define CAF_PDM_ABSTRACT_SOURCE_INIT CAF_PDM_XML_ABSTRACT_SOURCE_INIT
|
||||
|
||||
#define CAF_PDM_SCRIPTABLE_SOURCE_INIT CAF_PDM_XML_SCRIPTABLE_SOURCE_INIT
|
||||
|
||||
/// InitObject sets up the user interface related information for the object
|
||||
/// Placed in the constructor of your PdmObject
|
||||
/// Note that classKeyword() is not virtual in the constructor of the PdmObject
|
||||
|
||||
@@ -27,30 +27,15 @@
|
||||
|
||||
// To be renamed CAF_PDM_XML_HEADER_INIT
|
||||
#define CAF_PDM_XML_HEADER_INIT \
|
||||
private: \
|
||||
static bool classIsScriptable(); \
|
||||
public: \
|
||||
virtual QString classKeyword() const; \
|
||||
static QString classKeywordStatic(); \
|
||||
static std::vector<QString> classKeywordAliases(); \
|
||||
virtual bool isScriptable() const; \
|
||||
virtual bool matchesClassKeyword(const QString& keyword) const; \
|
||||
\
|
||||
static bool Error_You_forgot_to_add_the_macro_CAF_PDM_XML_HEADER_INIT_and_or_CAF_PDM_XML_SOURCE_INIT_to_your_cpp_file_for_this_class()
|
||||
|
||||
#define CAF_PDM_XML_NON_SCRIPTABLE_INIT(ClassName) \
|
||||
bool ClassName::classIsScriptable() \
|
||||
{ \
|
||||
return false; \
|
||||
} \
|
||||
|
||||
#define CAF_PDM_XML_SCRIPTABLE_INIT(ClassName) \
|
||||
bool ClassName::classIsScriptable() \
|
||||
{ \
|
||||
return true; \
|
||||
} \
|
||||
|
||||
#define CAF_PDM_XML_ABSTRACT_BASE_SOURCE_INIT(ClassName, keyword, ...) \
|
||||
#define CAF_PDM_XML_ABSTRACT_SOURCE_INIT(ClassName, keyword, ...) \
|
||||
bool ClassName::Error_You_forgot_to_add_the_macro_CAF_PDM_XML_HEADER_INIT_and_or_CAF_PDM_XML_SOURCE_INIT_to_your_cpp_file_for_this_class() { return false;} \
|
||||
\
|
||||
QString ClassName::classKeyword() const \
|
||||
@@ -66,10 +51,6 @@ public: \
|
||||
CAF_PDM_VERIFY_XML_KEYWORD(keyword) \
|
||||
return {keyword, ##__VA_ARGS__}; \
|
||||
} \
|
||||
bool ClassName::isScriptable() const \
|
||||
{ \
|
||||
return ClassName::classIsScriptable(); \
|
||||
} \
|
||||
bool ClassName::matchesClassKeyword(const QString& matchKeyword) const\
|
||||
{ \
|
||||
auto aliases = classKeywordAliases(); \
|
||||
@@ -80,18 +61,6 @@ public: \
|
||||
return false; \
|
||||
} \
|
||||
|
||||
/// CAF_PDM_XML_ABSTRACT_SOURCE_INIT associates the file keyword used for storage with the class
|
||||
/// Place this in the cpp file, preferably above the constructor
|
||||
#define CAF_PDM_XML_ABSTRACT_SOURCE_INIT(ClassName, keyword, ...) \
|
||||
CAF_PDM_XML_ABSTRACT_BASE_SOURCE_INIT(ClassName, keyword, ##__VA_ARGS__) \
|
||||
CAF_PDM_XML_NON_SCRIPTABLE_INIT(ClassName) \
|
||||
|
||||
/// CAF_PDM_XML_ABSTRACT_SOURCE_INIT associates the file keyword used for storage with the *scriptable* class
|
||||
/// Place this in the cpp file, preferably above the constructor
|
||||
#define CAF_PDM_XML_ABSTRACT_SCRIPTABLE_SOURCE_INIT(ClassName, keyword, ...) \
|
||||
CAF_PDM_XML_ABSTRACT_BASE_SOURCE_INIT(ClassName, keyword, ##__VA_ARGS__) \
|
||||
CAF_PDM_XML_SCRIPTABLE_INIT(ClassName) \
|
||||
|
||||
/// CAF_PDM_XML_SOURCE_INIT associates the file keyword used for storage with the class and
|
||||
// initializes the factory
|
||||
/// Place this in the cpp file, preferably above the constructor
|
||||
@@ -99,13 +68,6 @@ public: \
|
||||
CAF_PDM_XML_ABSTRACT_SOURCE_INIT(ClassName, keyword, ##__VA_ARGS__) \
|
||||
static bool PDM_OBJECT_STRING_CONCATENATE(my##ClassName, __LINE__) = caf::PdmDefaultObjectFactory::instance()->registerCreator<ClassName>()
|
||||
|
||||
/// CAF_PDM_XML_SCRIPTABLE_SOURCE_INIT associates the file keyword used for storage with the *scriptable* class and
|
||||
// initializes the factory
|
||||
/// Place this in the cpp file, preferably above the constructor
|
||||
#define CAF_PDM_XML_SCRIPTABLE_SOURCE_INIT(ClassName, keyword, ...) \
|
||||
CAF_PDM_XML_ABSTRACT_SCRIPTABLE_SOURCE_INIT(ClassName, keyword, ##__VA_ARGS__) \
|
||||
static bool PDM_OBJECT_STRING_CONCATENATE(my##ClassName, __LINE__) = caf::PdmDefaultObjectFactory::instance()->registerCreator<ClassName>()
|
||||
|
||||
#define CAF_PDM_XML_InitField(field, keyword) \
|
||||
{ \
|
||||
CAF_PDM_VERIFY_XML_KEYWORD(keyword) \
|
||||
|
||||
Reference in New Issue
Block a user