|
Philote-Cpp
C++ bindings for the Philote MDO standard
|
Definition of the discipline base class. More...
#include <discipline.h>
Public Member Functions | |
| Discipline () | |
| Construct a new Discipline object. | |
| ~Discipline () noexcept | |
| Destroy the Discipline object. | |
| std::map< std::string, std::string > & | options_list () |
| Gets the options list. | |
| std::vector< philote::VariableMetaData > & | var_meta () |
| Accesses the variable meta data. | |
| const std::vector< philote::VariableMetaData > & | var_meta () const noexcept |
| std::vector< philote::PartialsMetaData > & | partials_meta () |
| Accesses the partials meta data. | |
| const std::vector< philote::PartialsMetaData > & | partials_meta () const noexcept |
| philote::DisciplineProperties & | properties () |
| Gets the discipline properties. | |
| philote::StreamOptions & | stream_opts () |
| Gets the stream options. | |
| const philote::StreamOptions & | stream_opts () const noexcept |
| void | AddInput (const std::string &name, const std::vector< int64_t > &shape, const std::string &units) |
| Declares an input. | |
| void | AddOutput (const std::string &name, const std::vector< int64_t > &shape, const std::string &units) |
| Declares an output. | |
| void | DeclarePartials (const std::string &f, const std::string &x) |
| Declare a (set of) partial(s) for the discipline. | |
| void | AddOption (const std::string &name, const std::string &type) |
| Add an option to the discipline. | |
| virtual void | Initialize () |
| Initialize function that sets up available options. | |
| virtual void | Configure () |
| Configure function that is called after options are set. | |
| virtual void | SetOptions (const google::protobuf::Struct &options_struct) |
| Sets up all discipline options based on a protobuf struct that the server received from the client. | |
| virtual void | Setup () |
| Setup function that is called by the server when the client calls the setup RPC. | |
| virtual void | SetupPartials () |
| Setup function that is called by the server when the client calls the setup RPC. | |
| void | SetContext (grpc::ServerContext *context) const noexcept |
| Set the gRPC server context for cancellation detection. | |
| void | ClearContext () const noexcept |
| Clear the gRPC server context. | |
| bool | IsCancelled () const noexcept |
| Check if the current operation has been cancelled. | |
Protected Member Functions | |
| std::vector< int64_t > | ComputePartialShape (const std::string &f, const std::string &x, bool allow_output_as_x) |
| Computes the shape for a partial derivative df/dx. | |
Protected Attributes | |
| std::map< std::string, std::string > | options_list_ |
| List of options that can be set by the client. | |
| std::vector< philote::VariableMetaData > | var_meta_ |
| List of variable meta data. | |
| std::vector< philote::PartialsMetaData > | partials_meta_ |
| List of partials meta data. | |
| philote::DisciplineProperties | properties_ |
| Discipline properties. | |
| philote::StreamOptions | stream_opts_ |
| Stream options. | |
| grpc::ServerContext * | current_context_ = nullptr |
| Current gRPC server context for cancellation detection (mutable for const correctness) | |
Definition of the discipline base class.
This class is used as the base class for the Explicit and Implicit Disciplines. It allows the discipline developers to overload the setup and setup partials functions without code duplication within the explicit and implicit classes.
| philote::Discipline::Discipline | ( | ) |
Construct a new Discipline object.
|
noexcept |
Destroy the Discipline object.
| void philote::Discipline::AddInput | ( | const std::string & | name, |
| const std::vector< int64_t > & | shape, | ||
| const std::string & | units | ||
| ) |
Declares an input.
| var |
| void philote::Discipline::AddOption | ( | const std::string & | name, |
| const std::string & | type | ||
| ) |
Add an option to the discipline.
| name | Option name |
| type | Option type as string (e.g., "bool", "int", "float", "string") |
| void philote::Discipline::AddOutput | ( | const std::string & | name, |
| const std::vector< int64_t > & | shape, | ||
| const std::string & | units | ||
| ) |
Declares an output.
| var |
|
noexcept |
Clear the gRPC server context.
This method is called by the server after user-defined compute methods complete to ensure the context pointer doesn't outlive the RPC call.
|
protected |
Computes the shape for a partial derivative df/dx.
This helper method encapsulates the logic for determining the shape of partial derivative arrays based on the shapes of the output (f) and input (x) variables.
| f | Name of the output variable |
| x | Name of the input (or output for implicit disciplines) variable |
| allow_output_as_x | If true, allows x to be an output variable (for implicit disciplines) |
| std::runtime_error | If variables are not found |
|
virtual |
Configure function that is called after options are set.
This function is called after SetOptions but before Setup. It can be used for any configuration that depends on the option values.
| void philote::Discipline::DeclarePartials | ( | const std::string & | f, |
| const std::string & | x | ||
| ) |
Declare a (set of) partial(s) for the discipline.
| f | |
| x |
|
virtual |
Initialize function that sets up available options.
This function is called during discipline construction. It should be used to define what option names and types are available. The SetOptions function is used to actually set the option values.
|
noexcept |
Check if the current operation has been cancelled.
User disciplines can call this method during long-running computations to detect if the client has cancelled the request. If true is returned, the discipline should stop computation and return/throw as appropriate.
| std::map< std::string, std::string > & philote::Discipline::options_list | ( | ) |
Gets the options list.
|
inline |
Accesses the partials meta data.
|
inlinenoexcept |
| philote::DisciplineProperties & philote::Discipline::properties | ( | ) |
Gets the discipline properties.
|
noexcept |
Set the gRPC server context for cancellation detection.
This method is called by the server before invoking user-defined compute methods. It allows disciplines to check for cancellation during long-running computations.
| context | The gRPC server context, or nullptr to clear |
|
virtual |
Sets up all discipline options based on a protobuf struct that the server received from the client.
| options_struct |
|
virtual |
Setup function that is called by the server when the client calls the setup RPC.
|
virtual |
Setup function that is called by the server when the client calls the setup RPC.
This function is used to setup the partials.
|
inline |
Gets the stream options.
|
inlinenoexcept |
|
inline |
Accesses the variable meta data.
|
inlinenoexcept |
|
mutableprotected |
Current gRPC server context for cancellation detection (mutable for const correctness)
|
protected |
List of options that can be set by the client.
|
protected |
List of partials meta data.
|
protected |
Discipline properties.
|
protected |
Stream options.
|
protected |
List of variable meta data.