mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
AppFwk : Add support for output of object and field keywords
This commit is contained in:
parent
d5b12a8b23
commit
d15808efe6
@ -34,6 +34,7 @@ ${CEE_CURRENT_LIST_DIR}RicExpressionParser-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuSummaryVectorDescriptionMap-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}FixedWidthDataParser-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigTimeCurveHistoryMerger-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}ListKeywordsForObjectsAndFields-Test.cpp
|
||||
)
|
||||
|
||||
if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES)
|
||||
|
@ -0,0 +1,75 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "cafPdmDefaultObjectFactory.h"
|
||||
#include "cafPdmObjectHandle.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void writeTextToFile(const QString& filePath, const QString& text)
|
||||
{
|
||||
QFile exportFile(filePath);
|
||||
if (exportFile.open(QIODevice::WriteOnly))
|
||||
{
|
||||
QTextStream stream(&exportFile);
|
||||
|
||||
stream << text;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(ListKeywords, ListAllObjectKeywords)
|
||||
{
|
||||
auto instance = caf::PdmDefaultObjectFactory::instance();
|
||||
|
||||
QString textString;
|
||||
QTextStream stream(&textString);
|
||||
|
||||
std::vector<QString> classKeywords = instance->classKeywords();
|
||||
for (auto keyword : classKeywords)
|
||||
{
|
||||
stream << keyword << "\n";
|
||||
}
|
||||
|
||||
QString filePath = "c:/temp/ri-objectKeywords.txt";
|
||||
// writeTextToFile(filePath, textString);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(ListKeywords, ListAllObjectKeywordsAndFieldKeywords)
|
||||
{
|
||||
auto instance = caf::PdmDefaultObjectFactory::instance();
|
||||
|
||||
QString textString;
|
||||
QTextStream stream(&textString);
|
||||
|
||||
std::vector<QString> classKeywords = instance->classKeywords();
|
||||
for (auto keyword : classKeywords)
|
||||
{
|
||||
stream << keyword << "\n";
|
||||
|
||||
caf::PdmObjectHandle* myClass = instance->create(keyword);
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> fields;
|
||||
myClass->fields(fields);
|
||||
|
||||
for (auto f : fields)
|
||||
{
|
||||
stream << " " << f->keyword() << "\n";
|
||||
}
|
||||
|
||||
stream << "\n";
|
||||
|
||||
delete myClass;
|
||||
}
|
||||
|
||||
QString filePath = "c:/temp/ri-fieldKeywords.txt";
|
||||
// writeTextToFile(filePath, textString);
|
||||
}
|
@ -24,6 +24,21 @@ PdmObjectHandle * PdmDefaultObjectFactory::create(const QString& classNameKeywor
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> PdmDefaultObjectFactory::classKeywords() const
|
||||
{
|
||||
std::vector<QString> names;
|
||||
|
||||
for (const auto& entry : m_factoryMap)
|
||||
{
|
||||
names.push_back(entry.first);
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <QString>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@ -84,6 +85,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<QString> classKeywords() const;
|
||||
|
||||
private:
|
||||
PdmDefaultObjectFactory() {}
|
||||
~PdmDefaultObjectFactory() { /* Could clean up, but ... */ }
|
||||
|
Loading…
Reference in New Issue
Block a user