mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 14:40:26 -05:00
Replace the hand-written PropertyDataType wrapper with first-class enum return support in the code generator. Scriptable methods that derive from the new caf::PdmEnumObjectMethod<T> template return a typed enum value across the gRPC boundary; the Python generator emits a StrEnum class with the texts pulled from the underlying caf::AppEnum<T> and wraps the call site so callers receive `EnumClass(value)` directly. caf::PdmDataContainerEnum is the small PdmObject the framework uses to carry the enum text on the wire (single scriptable QString field). RimcEclipseCase_propertyDataType becomes declarative: implement executeEnum() returning the typed RiaDefines::ResultDataType and pick a returnEnumScriptName() — the base handles serialization and reports the four AppEnum members (UNKNOWN, FLOAT, DOUBLE, INTEGER) to the generator. Drop the hand-written PropertyDataType in enums.py — the generated one in resinsight_classes is wire-equivalent and now the single source of truth.
61 lines
2.4 KiB
C++
61 lines
2.4 KiB
C++
//##################################################################################################
|
|
//
|
|
// Custom Visualization Core library
|
|
// Copyright (C) 2026- Equinor ASA
|
|
//
|
|
// This library may be used under the terms of either the GNU General Public License or
|
|
// the GNU Lesser General Public License as follows:
|
|
//
|
|
// GNU General Public License Usage
|
|
// This library is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
//
|
|
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
|
// for more details.
|
|
//
|
|
// GNU Lesser General Public License Usage
|
|
// This library is free software; you can redistribute it and/or modify
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
// the Free Software Foundation; either version 2.1 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
//
|
|
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
|
// for more details.
|
|
//
|
|
//##################################################################################################
|
|
#pragma once
|
|
|
|
#include "cafPdmField.h"
|
|
#include "cafPdmObject.h"
|
|
|
|
#include <QString>
|
|
|
|
namespace caf
|
|
{
|
|
//==================================================================================================
|
|
/// Container returned by scriptable methods that produce a single enum value. The Python code
|
|
/// generator detects methods declaring an enum return type (see PdmEnumObjectMethod) and wraps
|
|
/// the container's `value` field into the corresponding Python StrEnum at the call site.
|
|
//==================================================================================================
|
|
class PdmDataContainerEnum : public PdmObject
|
|
{
|
|
CAF_PDM_HEADER_INIT;
|
|
|
|
public:
|
|
PdmDataContainerEnum();
|
|
|
|
PdmField<QString> m_value;
|
|
};
|
|
|
|
} // namespace caf
|