Bifrost SDK
Bifrost SDK documentation
BifrostGraph::Executor::TypeTranslation Class Referenceabstract

BifrostGraph Executor TypeTranslation. More...

#include <TypeTranslation.h>

Classes

class  PluginHostData
 The host data for registering TypeTranslation to host plugin. More...
 
class  PortData
 The host data for creating host ports. More...
 
class  ValueData
 The host data for translating values from/to host/Amino. More...
 

Public Types

using String = Amino::String
 
using StringArray = Amino::Array< String >
 
using CreateFunc = TypeTranslation *(*)()
 The signature of the function used to create the TypeTranslation. More...
 

Public Member Functions

 TypeTranslation (String name) noexcept
 Constructor. More...
 
virtual ~TypeTranslation () noexcept
 Destructor. More...
 
String getName () const noexcept
 Get the name of this TypeTranslation for logging purposes. More...
 
virtual void deleteThis () noexcept=0
 Instruct the TypeTranslation to delete itself. More...
 
virtual void getSupportedTypes (const Amino::Library &amLibrary, Amino::TypeConstIndexedList &types) const noexcept
 Get the list of the types handled by this TypeTranslation. More...
 
virtual void getSupportedTypeNames (StringArray &names) const noexcept
 Get the fully qualified names of the types handled by the TypeTranslation. More...
 
virtual bool convertValueFromHost (const Amino::Type &type, Amino::Any &any, const ValueData *valueData) const noexcept
 Convert a host value to an Amino::Any. More...
 
virtual bool convertValueToHost (const Amino::Any &any, ValueData *valueData) const noexcept
 Convert an Amino::Any to a host value. More...
 
virtual bool portAdded (const String &name, PortDirection direction, const Amino::Type &type, const Amino::Metadata &metadata, PortClass portClass, PortData *portData) const noexcept
 Notification method called when a port is created/added. More...
 
virtual bool portRemoved (const String &name, const String &graphName) const noexcept
 Notification method called when a port is removed. More...
 
virtual bool portRenamed (const String &prevName, const String &name, const String &graphName) const noexcept
 Notification method called when a port is renamed. More...
 
virtual bool registerHostPlugins (const PluginHostData *pluginData) const noexcept
 Register any plugins or data types needed. More...
 
virtual bool unregisterHostPlugins (const PluginHostData *pluginData) const noexcept
 Unregister any previously registered plugins or data types. More...
 

Static Public Member Functions

static const char * createFuncName () noexcept
 Get the name of the function used to create a new TypeTranslation from a shared library. More...
 

Detailed Description

BifrostGraph Executor TypeTranslation.

TypeTranslation can be used to perform conversions from specific host data types to Amino types, and vice-versa.

A TypeTranslation should be allocated on the heap, not on the stack. The Workspace will manage its lifetime and delete it by calling TypeTranslation::deleteThis when the Workspace gets unloaded.

Definition at line 53 of file TypeTranslation.h.

Member Typedef Documentation

◆ CreateFunc

The signature of the function used to create the TypeTranslation.

Definition at line 98 of file TypeTranslation.h.

◆ String

◆ StringArray

Constructor & Destructor Documentation

◆ TypeTranslation()

BifrostGraph::Executor::TypeTranslation::TypeTranslation ( String  name)
explicitnoexcept

Constructor.

Parameters
[in]nameThe name of this TypeTranslation for logging purposes.

◆ ~TypeTranslation()

virtual BifrostGraph::Executor::TypeTranslation::~TypeTranslation ( )
virtualnoexcept

Destructor.

Member Function Documentation

◆ convertValueFromHost()

virtual bool BifrostGraph::Executor::TypeTranslation::convertValueFromHost ( const Amino::Type &  type,
Amino::Any any,
const ValueData valueData 
) const
virtualnoexcept

Convert a host value to an Amino::Any.

Note
Default implementation does nothing and returns false.
Parameters
[in]typeThe Amino value type.
[out]anyThe destination Amino::Any.
[in]valueDataA pointer to a ValueData instance, used to access the host value.
Returns
true if the value was successfully converted.

◆ convertValueToHost()

virtual bool BifrostGraph::Executor::TypeTranslation::convertValueToHost ( const Amino::Any any,
ValueData valueData 
) const
virtualnoexcept

Convert an Amino::Any to a host value.

Note
Default implementation does nothing and returns false.
Parameters
[in]anyThe source Amino::Any.
[in,out]valueDataA pointer to a ValueData instance, used to access the host value.
Returns
true if the value was successfully converted.

◆ createFuncName()

static const char * BifrostGraph::Executor::TypeTranslation::createFuncName ( )
staticnoexcept

Get the name of the function used to create a new TypeTranslation from a shared library.

This function is the C entry point used to register a TypeTranslation with Bifrost. The client code must declare and define the entry point. This function must have the CreateFunc signature.

Note that BIFROSTGRAPH_EXECUTOR_SHARED_DECL is for symbol visiblity, see ExecutorExport.h file.

extern "C" {
BIFROSTGRAPH_EXECUTOR_SHARED_DECL BifrostGraph::Executor::TypeTranslation*
createBifrostTypeTranslation(void);
BIFROSTGRAPH_EXECUTOR_SHARED_DECL BifrostGraph::Executor::TypeTranslation*
createBifrostTypeTranslation(void) {
// Return a pointer to my class that implements
// BifrostGraph::Executor::TypeTranslation interface.
return new MyTypeTranslation();
}
BifrostGraph Executor TypeTranslation.

The TypeTranslation shared library is exposed to Bifrost via a config file. The JSON config file will need a typesTranslationlibs section. Note that, to be portable and depending on the platform, Bifrost config file parsing will automatically add the prefix "lib" and suffix "dll", "so", or "dylib".

{
"AminoConfigurations": [
{
"vendorName": "MyCompany",
"libraryVersion": "0.0.1",
"libraryName": "MyPackName",
"typesTranslationlibs": [
{
"path": "Directory containing the shared lib",
"files": [
"MyTypeTranslation"
]
}
]
}
]
}
Returns
"createBifrostTypeTranslation"

◆ deleteThis()

virtual void BifrostGraph::Executor::TypeTranslation::deleteThis ( )
pure virtualnoexcept

Instruct the TypeTranslation to delete itself.

◆ getName()

String BifrostGraph::Executor::TypeTranslation::getName ( ) const
noexcept

Get the name of this TypeTranslation for logging purposes.

Returns
The name of this TypeTranslation

◆ getSupportedTypeNames()

virtual void BifrostGraph::Executor::TypeTranslation::getSupportedTypeNames ( StringArray names) const
virtualnoexcept

Get the fully qualified names of the types handled by the TypeTranslation.

The Workspace will call getSupportedTypes and this method, in this order, to build the complete list of types handled by this TypeTranslation. The default implementation of this method adds no type name to names. The deriving class may override this default implementation to list the fully qualified names of the types it handles, in addition to the types it may have listed in its implementation of getSupportedTypes. If the same type name is listed more than once by this method, or if a type name listed by this method was already listed by getSupportedTypes, these duplicates are ignored.

Parameters
[out]namesThe fully qualified names of the types handled by this TypeTranslation.

◆ getSupportedTypes()

virtual void BifrostGraph::Executor::TypeTranslation::getSupportedTypes ( const Amino::Library &  amLibrary,
Amino::TypeConstIndexedList types 
) const
virtualnoexcept

Get the list of the types handled by this TypeTranslation.

The Workspace will call this method and getSupportedTypeNames, in this order, to build the complete list of types handled by this TypeTranslation. The default implementation of this method adds no type to types. The deriving class may override this default implementation to list the types it handles, and it may complement these types by listing extra ones in its implementation of getSupportedTypeNames. If the same type is listed by both this method and by getSupportedTypeNames, the duplicate listed by getSupportedTypeNames is ignored.

Parameters
[in]amLibraryThe Amino Library
[out]typesThe types handled by this TypeTranslation.

◆ portAdded()

virtual bool BifrostGraph::Executor::TypeTranslation::portAdded ( const String name,
PortDirection  direction,
const Amino::Type &  type,
const Amino::Metadata &  metadata,
PortClass  portClass,
PortData portData 
) const
virtualnoexcept

Notification method called when a port is created/added.

Note
Default implementation does nothing and returns true.
Parameters
[in]nameThe name of the port.
[in]directionThe direction of the port (undefined, input or output).
[in]typeThe type of the port.
[in]portClassThe class of the port (regular, terminal or job port).
[in]metadataMetadata for the port.
[in]portDataA pointer to a PortData instance, used to create the host port.
Returns
true if the host port was successfully created.

◆ portRemoved()

virtual bool BifrostGraph::Executor::TypeTranslation::portRemoved ( const String name,
const String graphName 
) const
virtualnoexcept

Notification method called when a port is removed.

Note
Default implementation does nothing and returns true.
Parameters
[in]nameThe name of the port to be removed.
[in]graphNameThe name of the graph that has this port.
Returns
true if the host port was successfully removed.

◆ portRenamed()

virtual bool BifrostGraph::Executor::TypeTranslation::portRenamed ( const String prevName,
const String name,
const String graphName 
) const
virtualnoexcept

Notification method called when a port is renamed.

Note
Default implementation does nothing and returns true.
Parameters
[in]prevNameThe previous name of the port.
[in]nameThe new name of the port.
[in]graphNameThe name of the graph that has this port.
Returns
true if the host port was successfully renamed.

◆ registerHostPlugins()

virtual bool BifrostGraph::Executor::TypeTranslation::registerHostPlugins ( const PluginHostData pluginData) const
virtualnoexcept

Register any plugins or data types needed.

Note
Default implementation does nothing and returns true.
Parameters
[in]pluginDataThe host data.
Returns
true on success, false otherwise.

◆ unregisterHostPlugins()

virtual bool BifrostGraph::Executor::TypeTranslation::unregisterHostPlugins ( const PluginHostData pluginData) const
virtualnoexcept

Unregister any previously registered plugins or data types.

Note
Default implementation does nothing and returns true.
Parameters
[in]pluginDataThe host data.
Returns
true on success, false otherwise.