mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
* General PdmObjectMethods for scripting.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "RifcCommandFileReader.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmFieldIOScriptability.h"
|
||||
#include "cafPdmScriptIOMessages.h"
|
||||
|
||||
class TestCommand1 : public RicfCommandObject
|
||||
@@ -14,18 +15,18 @@ class TestCommand1 : public RicfCommandObject
|
||||
public:
|
||||
TestCommand1()
|
||||
{
|
||||
RICF_InitField( &m_textArgument, "TextArgument", QString(), "TextArgument", "", "", "" );
|
||||
RICF_InitField( &m_doubleArgument, "DoubleArgument", 0.0, "DoubleArgument", "", "", "" );
|
||||
RICF_InitField( &m_intArgument, "IntArgument", 0, "IntArgument", "", "", "" );
|
||||
RICF_InitField( &m_boolArgument, "BoolArgument", false, "BoolArgument", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldWithIO( &m_textArgument, "TextArgument", QString(), "TextArgument", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldWithIO( &m_doubleArgument, "DoubleArgument", 0.0, "DoubleArgument", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldWithIO( &m_intArgument, "IntArgument", 0, "IntArgument", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldWithIO( &m_boolArgument, "BoolArgument", false, "BoolArgument", "", "", "" );
|
||||
}
|
||||
|
||||
RicfCommandResponse execute() override
|
||||
caf::PdmScriptResponse execute() override
|
||||
{
|
||||
std::cout << "TestCommand1::execute("
|
||||
<< "\"" << m_textArgument().toStdString() << "\", " << m_doubleArgument() << ", " << m_intArgument
|
||||
<< ", " << m_boolArgument << ");" << std::endl;
|
||||
return RicfCommandResponse();
|
||||
return caf::PdmScriptResponse();
|
||||
}
|
||||
|
||||
caf::PdmField<QString> m_textArgument;
|
||||
@@ -43,18 +44,18 @@ class TC2 : public RicfCommandObject
|
||||
public:
|
||||
TC2()
|
||||
{
|
||||
RICF_InitField( &m_textArgument, "ta", QString(), "TextArgument", "", "", "" );
|
||||
RICF_InitField( &m_doubleArgument, "da", 0.0, "DoubleArgument", "", "", "" );
|
||||
RICF_InitField( &m_intArgument, "ia", 0, "IntArgument", "", "", "" );
|
||||
RICF_InitField( &m_boolArgument, "ba", false, "BoolArgument", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldWithIO( &m_textArgument, "ta", QString(), "TextArgument", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldWithIO( &m_doubleArgument, "da", 0.0, "DoubleArgument", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldWithIO( &m_intArgument, "ia", 0, "IntArgument", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldWithIO( &m_boolArgument, "ba", false, "BoolArgument", "", "", "" );
|
||||
}
|
||||
|
||||
RicfCommandResponse execute() override
|
||||
caf::PdmScriptResponse execute() override
|
||||
{
|
||||
std::cout << "TC2::execute("
|
||||
<< "\"" << m_textArgument().toStdString() << "\", " << m_doubleArgument() << ", " << m_intArgument()
|
||||
<< ", " << m_boolArgument() << ");" << std::endl;
|
||||
return RicfCommandResponse();
|
||||
return caf::PdmScriptResponse();
|
||||
}
|
||||
|
||||
caf::PdmField<QString> m_textArgument;
|
||||
@@ -80,7 +81,7 @@ TEST( RicfCommands, Test1 )
|
||||
|
||||
// std::cout << commandString.toStdString() << std::endl;
|
||||
|
||||
QTextStream inputStream( &commandString );
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects = RicfCommandFileReader::readCommands( inputStream, caf::PdmDefaultObjectFactory::instance(), &errors );
|
||||
@@ -138,7 +139,7 @@ TEST( RicfCommands, ErrorMessages )
|
||||
|
||||
std::cout << commandString.toStdString() << std::endl;
|
||||
|
||||
QTextStream inputStream( &commandString );
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects = RicfCommandFileReader::readCommands( inputStream, caf::PdmDefaultObjectFactory::instance(), &errors );
|
||||
@@ -180,7 +181,7 @@ TEST( RicfCommands, EmptyArgumentList )
|
||||
// Ensure no error messages when command with no arguments is read
|
||||
QString commandString( "TestCommand1()" );
|
||||
|
||||
QTextStream inputStream( &commandString );
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects = RicfCommandFileReader::readCommands( inputStream, caf::PdmDefaultObjectFactory::instance(), &errors );
|
||||
@@ -215,7 +216,7 @@ TEST( RicfCommands, TransformFileCommandObjectsToExecutableCommandObjects )
|
||||
|
||||
)";
|
||||
|
||||
QTextStream inputStream( &commandString );
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects = RicfCommandFileReader::readCommands( inputStream, caf::PdmDefaultObjectFactory::instance(), &errors );
|
||||
@@ -252,7 +253,7 @@ TEST( RicfCommands, IgnoreCommentLines )
|
||||
|
||||
)";
|
||||
|
||||
QTextStream inputStream( &commandString );
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects = RicfCommandFileReader::readCommands( inputStream, caf::PdmDefaultObjectFactory::instance(), &errors );
|
||||
@@ -283,7 +284,7 @@ TEST( RicfCommands, IgnoreCommentLinesShowErrorLine )
|
||||
|
||||
)";
|
||||
|
||||
QTextStream inputStream( &commandString );
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects = RicfCommandFileReader::readCommands( inputStream, caf::PdmDefaultObjectFactory::instance(), &errors );
|
||||
@@ -315,7 +316,7 @@ TEST( RicfCommands, WriteCommand )
|
||||
}
|
||||
|
||||
{
|
||||
QTextStream inputStream( &commandString );
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects =
|
||||
|
||||
Reference in New Issue
Block a user