Change API for PdmObjectHandle and PdmFieldHandle

* Refactor interface to PdmObjectHandle and PdmFieldHandle
Return objects instead of passing in structures as parameters

* Add nodiscard to several functions
* Remove redundant this->
* Rename to ptrReferencedObjectsByType
This commit is contained in:
Magne Sjaastad
2023-05-12 21:41:34 +02:00
committed by GitHub
parent 37e29a0f68
commit 0c90f67dcc
510 changed files with 1651 additions and 3111 deletions

View File

@@ -775,12 +775,8 @@ public:
if ( &m_ptrField == fieldNeedingOptions )
{
caf::PdmFieldHandle* field;
std::vector<caf::PdmObjectHandle*> objects;
field = this->parentField();
field->children( &objects );
caf::PdmFieldHandle* field = this->parentField();
std::vector<caf::PdmObjectHandle*> objects = field->children();
for ( size_t i = 0; i < objects.size(); ++i )
{
QString userDesc;
@@ -1075,8 +1071,7 @@ public:
if ( changedField == &m_applyAutoOnChildObjectFields )
{
std::vector<SmallDemoPdmObjectA*> objs;
descendantsIncludingThisOfType( objs );
auto objs = descendantsIncludingThisOfType<SmallDemoPdmObjectA>();
for ( auto obj : objs )
{
obj->enableAutoValueForDouble( doubleValue );
@@ -1089,8 +1084,7 @@ public:
if ( changedField == &m_updateAutoValues )
{
std::vector<SmallDemoPdmObjectA*> objs;
descendantsIncludingThisOfType( objs );
auto objs = descendantsIncludingThisOfType<SmallDemoPdmObjectA>();
for ( auto obj : objs )
{
obj->setAutoValueForDouble( doubleValue );
@@ -1355,7 +1349,7 @@ void MainWindow::setPdmRoot( caf::PdmObjectHandle* pdmRoot )
std::vector<caf::PdmFieldHandle*> fields;
if ( pdmRoot )
{
pdmRoot->fields( fields );
fields = pdmRoot->fields();
}
if ( fields.size() )
@@ -1377,7 +1371,7 @@ void MainWindow::setPdmRoot( caf::PdmObjectHandle* pdmRoot )
std::vector<ManyGroups*> obj;
if ( pdmRoot )
{
pdmRoot->descendantsIncludingThisOfType( obj );
obj = pdmRoot->descendantsIncludingThisOfType<ManyGroups>();
}
m_customObjectEditor->removeWidget( m_plotLabel );