Bifrost SDK
Bifrost SDK documentation
BifrostGraph::Executor::Library Class Referencefinal

A Library of types and node definitions that can be used by Bifrost. More...

#include <Library.h>

Public Member Functions

 ~Library () noexcept
 Destructor. More...
 
bool isValid () const noexcept
 Check if this Library has been successfully initialized. More...
 
bool loadDefinitionFile (const Amino::String &filePath, StringArray &nameList) noexcept
 Load into the Library the types, operators, terminal nodes and compounds found in a Bifrost definition JSON file, if the file has not already been loaded. More...
 
bool saveDefinitionFile (const Amino::String &filePath) noexcept
 Save from the Library the types, operators, terminal nodes and compounds found in a Bifrost definition JSON file, if the file has already been loaded. More...
 
const Private::IRestrictedLibraryServices & getRestrictedServices () const noexcept
 Obtain an interface giving access to private Library services. More...
 
Private::IRestrictedLibraryServices & getRestrictedServices () noexcept
 Obtain an interface giving access to private Library services. More...
 

Static Public Member Functions

static LibrarygetInvalid () noexcept
 Get a statically allocated Library that is uninitialized, invalid and not owned by any Workspace. Any operation on this instance will always fail and Library::isValid will return false. More...
 

Protected Member Functions

 Library (const Amino::String &name) noexcept
 Construct a Library with the given name. More...
 
 Library (Uninitialized uninitialized) noexcept
 Constructor that leaves the Library in an uninitialized state. More...
 
 EXECUTOR_DECLARE_MAKE_OWNER_FRIENDSHIP ()
 Allow the makeOwner<> factory functions to access the constructors of this class. More...
 

Friends

class Workspace
 Allow the Workspace class to access the constructors of a Library. More...
 

Detailed Description

A Library of types and node definitions that can be used by Bifrost.

Access to types and node definitions is provided through a Library. Types and node definitions are added to the Library by loading resource files.

Definition at line 53 of file Library.h.

Constructor & Destructor Documentation

◆ Library() [1/2]

BifrostGraph::Executor::Library::Library ( const Amino::String name)
explicitprotectednoexcept

Construct a Library with the given name.

If an error occurs during the construction of this Library, or its underlying Amino::Context or Amino::Library, then BifrostGraph::Executor::Library::isValid will return false and all future operations on the Library will fail.

This constructor is private to force the usage of factory functions BifrostGraph::Executor::makeOwner (see Factory.h) to create it.

Parameters
[in]nameAn optional name for the Library.

◆ Library() [2/2]

BifrostGraph::Executor::Library::Library ( Uninitialized  uninitialized)
explicitprotectednoexcept

Constructor that leaves the Library in an uninitialized state.

After this constructor returns, the method BifrostGraph::Executor::Library::isValid will return false and all future operations on the Library will fail.

Parameters
[in]uninitializedan Uninitialized enum value.
Warning
This constructor is used internally by the Executor. Use with caution.

◆ ~Library()

BifrostGraph::Executor::Library::~Library ( )
noexcept

Destructor.

Member Function Documentation

◆ EXECUTOR_DECLARE_MAKE_OWNER_FRIENDSHIP()

BifrostGraph::Executor::Library::EXECUTOR_DECLARE_MAKE_OWNER_FRIENDSHIP ( )
protected

Allow the makeOwner<> factory functions to access the constructors of this class.

◆ getInvalid()

static Library & BifrostGraph::Executor::Library::getInvalid ( )
staticnoexcept

Get a statically allocated Library that is uninitialized, invalid and not owned by any Workspace. Any operation on this instance will always fail and Library::isValid will return false.

◆ getRestrictedServices() [1/2]

const Private::IRestrictedLibraryServices & BifrostGraph::Executor::Library::getRestrictedServices ( ) const
noexcept

Obtain an interface giving access to private Library services.

Precondition
This Library must be valid (BifrostGraph::Executor::Library::isValid). Calling this method on an invalid Library will produce undefined behavior.
Note
This is an internal method used by the Executor SDK.
Returns
A reference to the IRestrictedLibraryServices interface of this Library.

◆ getRestrictedServices() [2/2]

Private::IRestrictedLibraryServices & BifrostGraph::Executor::Library::getRestrictedServices ( )
noexcept

Obtain an interface giving access to private Library services.

Precondition
This Library must be valid (BifrostGraph::Executor::Library::isValid). Calling this method on an invalid Library will produce undefined behavior.
Note
This is an internal method used by the Executor SDK.
Returns
A reference to the IRestrictedLibraryServices interface of this Library.

◆ isValid()

bool BifrostGraph::Executor::Library::isValid ( ) const
noexcept

Check if this Library has been successfully initialized.

If an error occurs during the construction of a Library, isValid() will return false and all future operations on the Library will fail.

Returns
true if this Library has been successfully initialized and is ready to be used; false otherwise.

◆ loadDefinitionFile()

bool BifrostGraph::Executor::Library::loadDefinitionFile ( const Amino::String filePath,
StringArray nameList 
)
noexcept

Load into the Library the types, operators, terminal nodes and compounds found in a Bifrost definition JSON file, if the file has not already been loaded.

Parameters
[in]filePathPath to a Bifrost definition JSON file.
[out]nameListThe list of fully qualified names of the public compounds loaded from the Bifrost definition JSON file designated by filePath. This returned list is filled even when the Bifrost definition JSON file was already loaded.
Returns
true if the Bifrost definition JSON file designated by filePath was already loaded or if it has just been successfully loaded; false otherwise.

◆ saveDefinitionFile()

bool BifrostGraph::Executor::Library::saveDefinitionFile ( const Amino::String filePath)
noexcept

Save from the Library the types, operators, terminal nodes and compounds found in a Bifrost definition JSON file, if the file has already been loaded.

Re-saving updates the resources and applies migration.

Parameters
[in]filePathPath to a Bifrost definition JSON file.
Returns
true if the Bifrost definition JSON file was already loaded and successfully saved; false otherwise.

Friends And Related Function Documentation

◆ Workspace

friend class Workspace
friend

Allow the Workspace class to access the constructors of a Library.

Definition at line 84 of file Library.h.