OEInterface

class OEInterface

This class represents OEInterface.

Constructors

OEInterface() -> OEInterface
OEInterface(arg2: OEInterface) -> OEInterface

Default and copy constructors.

OEInterface(dataptr: str) -> OEInterface

Constructs an OEInterface and configures it with the interface definition passed by dataptr. This is equivalent to the following code:

itf = oechem.OEInterface()

if not oechem.OEConfigure(itf, InterfaceData):
    oechem.OEThrow.Fatal("Problem configuring OEInterface!")

Note

It is possible to configure an OEInterface from multiple interface definitions. Just call OEConfigure once per interface definition on the same OEInterface object.

OEInterface(dataptr: str, argc: int, argv: str) -> OEInterface

Constructs an OEInterface and configures it with the interface definition passed by dataptr. Then parses the command line given by argv. This is equivalent to the following code:

itf = oechem.OEInterface()

if not oechem.OEConfigure(itf, InterfaceData):
    oechem.OEThrow.Fatal("Problem configuring OEInterface!")

if not oechem.OEParseCommandLine(itf, sys.argv):
    oechem.OEThrow.Fatal("Unable to parse command line")

Warning

These convenience constructors may force the program to exit and thus may not be appropriate when writing a library that should instead return errors.

AddDetail

AddDetail(detail: str) -> bool

Adds a line to the detailed description of the OEInterface. Returns true if the add was successful and false otherwise. (The current implementation never fails)

AddInterface

AddInterface() -> OEInterface

Adds a child OEInterface and returns a pointer to the newly created object (which is owned by the current OEInterface object).

AddParameter

AddParameter(classid: str) -> OEParameter

Adds a parameter to the OEInterface instance. The returned pointer points to the newly created OEParameter object. This memory is owned by the OEInterface object. If the add fails NULL will be returned.

The implementation of the returned OEParameter pointer will always be a subclass of

template <TT> OETypedParameter

The specific type depends upon the value of classid as follows :

string

TT is std::string parameter

double

TT is double parameter

float

TT is float parameter

bool

TT is bool parameter

int

TT is int parameter

file

TT is oeisstream parameter

param_file

TT is oeisstream and additionally the parameter is specially recognized by OEParseCommandLine as a text file holding parameter settings.

Clear

Clear() -> bool

Returns the OEInterface object to the default constructed state of an OEInterface.

DeleteInterface

DeleteInterface(itf: OEInterface) -> bool

Deletes a child OEInterface object. ‘itf’ is the child OEInterface to be deleted. The method returns true if the deletion is successful and false otherwise. ‘itf’ must be directly owned by the OEInterface, not one of its child OEInterfaces.

DeleteParameter

DeleteParameter(param: OEParameter) -> bool

Deletes a parameter (‘param’) owned by this OEInterface object. The function returns true if the delete succeeds and false otherwise. The parameter must be owned by the OEInterface object to be deleted (it will not delete parameters that belong to child OEInterface objects of this OEInterface).

Factory

Factory() -> OESimpleFactory< str,OEParameter >

Returns the OEInterface class’s factory used to create new parameters.

Get

template <class TT>
TT Get(std::string name, unsigned int ilist = 0) const

Returns the setting (either the value, or default if the value is not set) of the parameter with the given name and instance. The parameter must be of type TT, and must have either have a value or default set. If the parameter cannot be found (i.e., a call to OEInterface.Has with the same TT and ‘name’ returns false) a warning is issued and a default constructed TT is returned.

GetBrief

GetBrief() -> str

Returns the brief description of the OEInterface object.

GetDetail

GetDetail() -> Iterable[str]

Returns the detailed description of the OEInterface object.

GetInterface

GetInterface(name: str) -> OEInterface

Returns a pointer to a child OEInterface with a given ‘name’ owned by any child OEInterface. The search is recursive searching through all child’s child OEInterfaces, etc. If no such OEInterface exists NULL is returned.

GetInterfaces

GetInterfaces(recursive: bool = False) -> OEInterfaceIter
GetInterfaces(recursive: bool = False) -> Iterable[OEInterface]

Returns and iterator over all child OEInterfaces of this object. If recursive is true, the iterator will include all of the children’s OEInterfaces recursively in arbitrary order. If recursive is false only the immediate child OEInterfaces will be returned, and they will be sorted by OEInterface.GetOrderPriority (lowest values first) and then name.

GetList

template <class TT>
OEIterBase<const TT>* GetList(std::string name) const

See also

GetName

GetName() -> str

Returns the name of the OEInterface object.

GetOrderPriority

GetOrderPriority() -> int

Returns the order priority of the OEInterface object.

GetParameter

GetParameter(name: str) -> OEParameter

Returns a pointer to a OEParameter with a given ‘name’ owned by the OEInterface object or one of its child OEInterfaces (or child’s child OEInterface, etc). If no such parameter exists NULL is returned.

GetParameters

GetParameters(recursive: bool = True) -> OEParameterIter
GetParameters(recursive: bool = True) -> Iterable[OEParameter]

Returns an iterator over all OEParameters of the OEInterface object. If recursive is true the search is recursive including parameters held by all child OEInterfaces and their children in arbitrary order. If recursive is false parameters held by child OEInterfaces will not be included and they will be sorted by the parameters order priority (lowest values first), followed by name.

GetTypedParameter

template<class TT>
OETypedParameter<TT> *GetTypedParameter(std::string name)
template<class TT>
const OETypedParameter<TT> *GetTypedParameter(std::string name) const

Has

template<class TT>
bool Has(std::string name, unsigned int ilist = 0) const

Returns true if all of the following are true:

  1. A parameter with name name is contained by the OEInterface.

  2. The parameter is of type TT

  3. The parameters value of default is set.

In all other cases the function returns false.

Parent

Parent() -> OEInterface

Returns a pointer to the parent OEInterface of this object, or NULL if this OEInterface object does not have a parent.

SetBrief

SetBrief(brief: str) -> bool

Sets the brief description of the OEInterface. Returns true if the brief was successfully set and false otherwise. (The current implementation never fails)

SetName

SetName(name: str) -> bool

Sets the name of the OEInterface. Returns true if the name was successfully set and false otherwise. (The current implementation never fails).

SetOrderPriority

SetOrderPriority(priority: int) -> bool

Sets the order priority of the OEInterface. The order priority overrides the default sorting by name that is used when calling the GetInterfaces(false) member function. Child OEInterfaces with lower priority values will appear first. This function returns true if the priority was successfully set and false otherwise. (The current implementation never fails).