mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-08 07:03:25 -06:00
#8250 AppFwk : Introduce variadic macros
Use variadic macros to to support optional parameters in initialization macros
This commit is contained in:
parent
6a7e729886
commit
ff0b09d1c2
@ -59,9 +59,9 @@ public:
|
||||
"CmdSelectionChangeExecData tooltip",
|
||||
"CmdSelectionChangeExecData whatsthis" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_selectionLevel, "selectionLevel", "selectionLevel", "", "", "" );
|
||||
CAF_PDM_InitField( &m_previousSelection, "previousSelection", std::vector<QString>(), "previousSelection", "", "", "" );
|
||||
CAF_PDM_InitField( &m_newSelection, "newSelection", std::vector<QString>(), "newSelection", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_selectionLevel, "selectionLevel", "selectionLevel" );
|
||||
CAF_PDM_InitField( &m_previousSelection, "previousSelection", std::vector<QString>(), "previousSelection" );
|
||||
CAF_PDM_InitField( &m_newSelection, "newSelection", std::vector<QString>(), "newSelection" );
|
||||
}
|
||||
|
||||
PdmField<int> m_selectionLevel;
|
||||
|
@ -50,56 +50,83 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#define CAF_PDM_InitScriptableField( field, keyword, default, uiName, iconResourceName, toolTip, whatsThis ) \
|
||||
CAF_PDM_InitField( field, \
|
||||
keyword, \
|
||||
default, \
|
||||
uiName, \
|
||||
iconResourceName, \
|
||||
caf::PdmAbstractFieldScriptingCapability::helpString( toolTip, keyword ), \
|
||||
whatsThis ); \
|
||||
caf::AddScriptingCapabilityToField( field, keyword )
|
||||
#define CAF_PDM_InitScriptableField( field, keyword, default, uiName, ... ) \
|
||||
{ \
|
||||
std::vector<QString> arguments = { __VA_ARGS__ }; \
|
||||
QString iconResourceName; \
|
||||
QString toolTip; \
|
||||
QString whatsThis; \
|
||||
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
|
||||
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
|
||||
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
|
||||
\
|
||||
CAF_PDM_InitField( field, \
|
||||
keyword, \
|
||||
default, \
|
||||
uiName, \
|
||||
iconResourceName, \
|
||||
caf::PdmAbstractFieldScriptingCapability::helpString( toolTip, keyword ), \
|
||||
whatsThis ); \
|
||||
caf::AddScriptingCapabilityToField( field, keyword ); \
|
||||
}
|
||||
|
||||
#define CAF_PDM_InitScriptableFieldNoDefault( field, keyword, uiName, iconResourceName, toolTip, whatsThis ) \
|
||||
CAF_PDM_InitFieldNoDefault( field, \
|
||||
keyword, \
|
||||
uiName, \
|
||||
iconResourceName, \
|
||||
caf::PdmAbstractFieldScriptingCapability::helpString( toolTip, keyword ), \
|
||||
whatsThis ); \
|
||||
caf::AddScriptingCapabilityToField( field, keyword )
|
||||
#define CAF_PDM_InitScriptableFieldNoDefault( field, keyword, uiName, ... ) \
|
||||
{ \
|
||||
std::vector<QString> arguments = { __VA_ARGS__ }; \
|
||||
QString iconResourceName; \
|
||||
QString toolTip; \
|
||||
QString whatsThis; \
|
||||
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
|
||||
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
|
||||
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
|
||||
\
|
||||
CAF_PDM_InitFieldNoDefault( field, \
|
||||
keyword, \
|
||||
uiName, \
|
||||
iconResourceName, \
|
||||
caf::PdmAbstractFieldScriptingCapability::helpString( toolTip, keyword ), \
|
||||
whatsThis ); \
|
||||
caf::AddScriptingCapabilityToField( field, keyword ); \
|
||||
}
|
||||
|
||||
#define CAF_PDM_InitScriptableFieldWithScriptKeyword( field, \
|
||||
keyword, \
|
||||
scriptKeyword, \
|
||||
default, \
|
||||
uiName, \
|
||||
iconResourceName, \
|
||||
toolTip, \
|
||||
whatsThis ) \
|
||||
CAF_PDM_InitField( field, \
|
||||
keyword, \
|
||||
default, \
|
||||
uiName, \
|
||||
iconResourceName, \
|
||||
caf::PdmAbstractFieldScriptingCapability::helpString( toolTip, scriptKeyword ), \
|
||||
whatsThis ); \
|
||||
caf::AddScriptingCapabilityToField( field, scriptKeyword )
|
||||
#define CAF_PDM_InitScriptableFieldWithScriptKeyword( field, keyword, scriptKeyword, default, uiName, ... ) \
|
||||
{ \
|
||||
std::vector<QString> arguments = { __VA_ARGS__ }; \
|
||||
QString iconResourceName; \
|
||||
QString toolTip; \
|
||||
QString whatsThis; \
|
||||
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
|
||||
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
|
||||
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
|
||||
\
|
||||
CAF_PDM_InitField( field, \
|
||||
keyword, \
|
||||
default, \
|
||||
uiName, \
|
||||
iconResourceName, \
|
||||
caf::PdmAbstractFieldScriptingCapability::helpString( toolTip, scriptKeyword ), \
|
||||
whatsThis ); \
|
||||
caf::AddScriptingCapabilityToField( field, scriptKeyword ); \
|
||||
}
|
||||
|
||||
#define CAF_PDM_InitScriptableFieldWithScriptKeywordNoDefault( field, \
|
||||
keyword, \
|
||||
scriptKeyword, \
|
||||
uiName, \
|
||||
iconResourceName, \
|
||||
toolTip, \
|
||||
whatsThis ) \
|
||||
CAF_PDM_InitFieldNoDefault( field, \
|
||||
keyword, \
|
||||
uiName, \
|
||||
iconResourceName, \
|
||||
caf::PdmAbstractFieldScriptingCapability::helpString( toolTip, scriptKeyword ), \
|
||||
whatsThis ); \
|
||||
caf::AddScriptingCapabilityToField( field, scriptKeyword )
|
||||
#define CAF_PDM_InitScriptableFieldWithScriptKeywordNoDefault( field, keyword, scriptKeyword, uiName, ... ) \
|
||||
{ \
|
||||
std::vector<QString> arguments = { __VA_ARGS__ }; \
|
||||
QString iconResourceName; \
|
||||
QString toolTip; \
|
||||
QString whatsThis; \
|
||||
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
|
||||
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
|
||||
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
|
||||
\
|
||||
CAF_PDM_InitFieldNoDefault( field, \
|
||||
keyword, \
|
||||
uiName, \
|
||||
iconResourceName, \
|
||||
caf::PdmAbstractFieldScriptingCapability::helpString( toolTip, scriptKeyword ), \
|
||||
whatsThis ); \
|
||||
caf::AddScriptingCapabilityToField( field, scriptKeyword ); \
|
||||
}
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
@ -48,7 +48,15 @@
|
||||
|
||||
class QTextStream;
|
||||
|
||||
#define CAF_PDM_InitScriptableObject( uiName, iconResourceName, toolTip, whatsThis ) \
|
||||
#define CAF_PDM_InitScriptableObject( uiName, ... ) \
|
||||
std::vector<QString> arguments = { __VA_ARGS__ }; \
|
||||
QString iconResourceName; \
|
||||
QString toolTip; \
|
||||
QString whatsThis; \
|
||||
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
|
||||
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
|
||||
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
|
||||
\
|
||||
CAF_PDM_InitObject( uiName, iconResourceName, toolTip, whatsThis ); \
|
||||
caf::PdmObjectScriptingCapabilityRegister::registerScriptClassNameAndComment( classKeyword(), \
|
||||
classKeyword(), \
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
m_proxyDouble.registerGetMethod( this, &SimpleObj::doubleMember );
|
||||
AddUiCapabilityToField( &m_proxyDouble );
|
||||
AddXmlCapabilityToField( &m_proxyDouble );
|
||||
CAF_PDM_InitFieldNoDefault( &m_proxyDouble, "ProxyDouble", "ProxyDouble", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_proxyDouble, "ProxyDouble", "ProxyDouble" );
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -190,9 +190,9 @@ public:
|
||||
"ScriptClassName_InheritedDemoObj",
|
||||
"Script comment test" );
|
||||
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_texts, "Texts", "Some words", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_numbers, "Numbers", "Some words", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_testEnumField, "TestEnumValue", "An Enum", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_texts, "Texts", "Some words" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_numbers, "Numbers", "Some words" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_testEnumField, "TestEnumValue", "An Enum" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_simpleObjectsField,
|
||||
"SimpleObjects",
|
||||
"SimpleObjectsField",
|
||||
@ -218,7 +218,7 @@ class MyPdmDocument : public caf::PdmDocument
|
||||
public:
|
||||
MyPdmDocument()
|
||||
{
|
||||
CAF_PDM_InitObject( "PdmObjectCollection", "", "", "" );
|
||||
CAF_PDM_InitObject( "PdmObjectCollection" );
|
||||
CAF_PDM_InitFieldNoDefault( &objects, "PdmObjects", "", "", "", "" )
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ CAF_PDM_SOURCE_INIT( PdmDocument, "PdmDocument" );
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmDocument::PdmDocument()
|
||||
{
|
||||
CAF_PDM_InitFieldNoDefault( &fileName, "DocumentFileName", "File Name", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &fileName, "DocumentFileName", "File Name" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -77,8 +77,16 @@ class PdmObjectCapability;
|
||||
/// Note that classKeyword() is not virtual in the constructor of the PdmObject
|
||||
/// This is expected and fine.
|
||||
|
||||
#define CAF_PDM_InitObject( uiName, iconResourceName, toolTip, whatsThis ) \
|
||||
#define CAF_PDM_InitObject( uiName, ... ) \
|
||||
{ \
|
||||
std::vector<QString> arguments = { __VA_ARGS__ }; \
|
||||
QString iconResourceName; \
|
||||
QString toolTip; \
|
||||
QString whatsThis; \
|
||||
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
|
||||
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
|
||||
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
|
||||
\
|
||||
this->isInheritedFromPdmUiObject(); \
|
||||
this->isInheritedFromPdmXmlSerializable(); \
|
||||
this->registerClassKeyword( classKeyword() ); \
|
||||
@ -94,8 +102,15 @@ class PdmObjectCapability;
|
||||
/// Note that classKeyword() is not virtual in the constructor of the PdmObject
|
||||
/// This is expected and fine.
|
||||
|
||||
#define CAF_PDM_InitField( field, keyword, default, uiName, iconResourceName, toolTip, whatsThis ) \
|
||||
#define CAF_PDM_InitField( field, keyword, default, uiName, ... ) \
|
||||
{ \
|
||||
std::vector<QString> arguments = { __VA_ARGS__ }; \
|
||||
QString iconResourceName; \
|
||||
QString toolTip; \
|
||||
QString whatsThis; \
|
||||
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
|
||||
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
|
||||
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
|
||||
CAF_PDM_VERIFY_XML_KEYWORD( keyword ) \
|
||||
\
|
||||
static bool chekingThePresenceOfHeaderAndSourceInitMacros = \
|
||||
@ -116,8 +131,15 @@ class PdmObjectCapability;
|
||||
/// Note that classKeyword() is not virtual in the constructor of the PdmObject
|
||||
/// This is expected and fine.
|
||||
|
||||
#define CAF_PDM_InitFieldNoDefault( field, keyword, uiName, iconResourceName, toolTip, whatsThis ) \
|
||||
#define CAF_PDM_InitFieldNoDefault( field, keyword, uiName, ... ) \
|
||||
{ \
|
||||
std::vector<QString> arguments = { __VA_ARGS__ }; \
|
||||
QString iconResourceName; \
|
||||
QString toolTip; \
|
||||
QString whatsThis; \
|
||||
if ( arguments.size() > 0 ) iconResourceName = arguments[0]; \
|
||||
if ( arguments.size() > 1 ) toolTip = arguments[1]; \
|
||||
if ( arguments.size() > 2 ) whatsThis = arguments[2]; \
|
||||
CAF_PDM_VERIFY_XML_KEYWORD( keyword ) \
|
||||
\
|
||||
static bool chekingThePresenceOfHeaderAndSourceInitMacros = \
|
||||
|
@ -14,7 +14,7 @@ CAF_PDM_SOURCE_INIT( PdmObjectGroup, "PdmObjectGroup" );
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmObjectGroup::PdmObjectGroup()
|
||||
{
|
||||
CAF_PDM_InitObject( "Object Group", "", "", "" );
|
||||
CAF_PDM_InitObject( "Object Group" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -51,7 +51,7 @@ CAF_PDM_SOURCE_INIT( PdmObjectCollection, "PdmObjectCollection" );
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmObjectCollection::PdmObjectCollection()
|
||||
{
|
||||
CAF_PDM_InitObject( "PdmObjectCollection", "", "", "" );
|
||||
CAF_PDM_InitObject( "PdmObjectCollection" );
|
||||
CAF_PDM_InitFieldNoDefault( &objects, "PdmObjects", "", "", "", "" )
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ CAF_PDM_SOURCE_INIT( Child, "Child" );
|
||||
|
||||
Child::Child()
|
||||
{
|
||||
CAF_PDM_InitFieldNoDefault( &m_testObj, "Numbers", "Important Numbers", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_testObj, "Numbers", "Important Numbers" );
|
||||
}
|
||||
|
||||
Child::~Child()
|
||||
|
@ -7,9 +7,9 @@ CAF_PDM_SOURCE_INIT( Parent, "Parent" );
|
||||
|
||||
Parent::Parent()
|
||||
{
|
||||
CAF_PDM_InitObject( "Parent", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_simpleObjectsField, "SimpleObjects", "A child object", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_simpleObjectF, "SimpleObject", "A child object", "", "", "" );
|
||||
CAF_PDM_InitObject( "Parent" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_simpleObjectsField, "SimpleObjects", "A child object" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_simpleObjectF, "SimpleObject", "A child object" );
|
||||
}
|
||||
|
||||
Parent::~Parent()
|
||||
|
@ -4,8 +4,8 @@ CAF_PDM_SOURCE_INIT( TestObj, "TestObj" );
|
||||
|
||||
TestObj::TestObj()
|
||||
{
|
||||
CAF_PDM_InitObject( "TestObj", "", "", "" );
|
||||
CAF_PDM_InitField( &m_position, "Position", 8765.2, "Position", "", "", "" );
|
||||
CAF_PDM_InitObject( "TestObj" );
|
||||
CAF_PDM_InitField( &m_position, "Position", 8765.2, "Position" );
|
||||
}
|
||||
|
||||
TestObj::~TestObj()
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
m_proxyDouble.registerGetMethod( this, &SimpleObj::doubleMember );
|
||||
AddUiCapabilityToField( &m_proxyDouble );
|
||||
AddXmlCapabilityToField( &m_proxyDouble );
|
||||
CAF_PDM_InitFieldNoDefault( &m_proxyDouble, "ProxyDouble", "ProxyDouble", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_proxyDouble, "ProxyDouble", "ProxyDouble" );
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -183,8 +183,8 @@ public:
|
||||
{
|
||||
CAF_PDM_InitObject( "InheritedDemoObj", "", "ToolTip InheritedDemoObj", "Whatsthis InheritedDemoObj" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_texts, "Texts", "Some words", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_testEnumField, "TestEnumValue", "An Enum", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_texts, "Texts", "Some words" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_testEnumField, "TestEnumValue", "An Enum" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_simpleObjectsField,
|
||||
"SimpleObjects",
|
||||
"SimpleObjectsField",
|
||||
@ -208,7 +208,7 @@ class MyPdmDocument : public caf::PdmDocument
|
||||
public:
|
||||
MyPdmDocument()
|
||||
{
|
||||
CAF_PDM_InitObject( "PdmObjectCollection", "", "", "" );
|
||||
CAF_PDM_InitObject( "PdmObjectCollection" );
|
||||
CAF_PDM_InitFieldNoDefault( &objects, "PdmObjects", "", "", "", "" )
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ public:
|
||||
|
||||
m_proxyDoubleField.registerSetMethod(this, &SmallDemoPdmObject::setDoubleMember);
|
||||
m_proxyDoubleField.registerGetMethod(this, &SmallDemoPdmObject::doubleMember);
|
||||
CAF_PDM_InitFieldNoDefault(&m_proxyDoubleField, "ProxyDouble", "Proxy Double", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_proxyDoubleField, "ProxyDouble", "Proxy Double");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_colorTriplets, "colorTriplets", "color Triplets", "", "", "");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user