![]() |
LibraryLink Utilities
3.0.1
Modern C++ wrapper over LibraryLink and WSTP
|
ManagedExpressionStore will keep track of instances of managed class T and will provide safe access to them.
| T | - managed class |
#include <ManagedExpression.hpp>
Public Types | |
| using | iterator = typename std::unordered_map< mint, std::shared_ptr< T > >::iterator |
| Iterator over ManagedExpressionStore - it iterates over the underlying hash map. More... | |
| using | const_iterator = typename std::unordered_map< mint, std::shared_ptr< T > >::const_iterator |
| Constant iterator over ManagedExpressionStore - it "const-iterates" over the underlying hash map. More... | |
| using | size_type = typename std::unordered_map< mint, std::shared_ptr< T > >::size_type |
| Size type of the Store is the same as size_type of the underlying hash map. More... | |
Public Member Functions | |
| void | manageInstance (mbool mode, mint id) |
| Function that will actually be called by LibraryLink when an instance of Managed Expression is created or deleted. More... | |
| template<class DynamicType = T, typename... Args> | |
| T & | createInstance (mint id, Args &&... args) |
| Create new object of class T that will be managed from Wolfram Language and place it in the map of managed objects. More... | |
| T & | createInstance (mint id, std::shared_ptr< T > ptr) |
| Create instance in the store from a pointer to the managed class object. More... | |
| T & | createInstance (mint id, std::unique_ptr< T > ptr) |
| Create instance in the store from a unique pointer to the managed class object. More... | |
| int | releaseInstance (mint id) |
| Release an instance managed by this Store. More... | |
| bool | hasInstance (mint id) const |
Check if instance with given id is present in the store. More... | |
| T & | getInstance (mint id) |
Get managed instance with given id. More... | |
| std::shared_ptr< T > | getInstancePointer (mint id) |
Get a shared pointer to a managed instance with given id. More... | |
| const std::string & | getExpressionName () const noexcept |
| Get symbol name that is used in the WL to represent Managed Expressions stored in this Store. More... | |
| size_type | size () const noexcept |
| Get the number of currently managed expressions. More... | |
| iterator | begin () noexcept |
| Get the iterator to the first element of the Store. More... | |
| const_iterator | begin () const noexcept |
| Get the const iterator to the first element of the Store. More... | |
| const_iterator | cbegin () const noexcept |
| Get the const iterator to the first element of the Store. More... | |
| iterator | end () noexcept |
| Get the iterator past the last element of the Store. More... | |
| const_iterator | end () const noexcept |
| Get the const iterator past the last element of the Store. More... | |
| const_iterator | cend () const noexcept |
| Get the const iterator past the last element of the Store. More... | |
| void | registerType (std::string name, WolframLibraryData libData=LibraryData::API()) noexcept |
Register class T as managed expression under given name. More... | |
| void | unregisterType (WolframLibraryData libData=LibraryData::API()) const noexcept |
| Unregister class T as managed expression. More... | |
| using LLU::ManagedExpressionStore< T >::const_iterator = typename std::unordered_map<mint, std::shared_ptr<T> >::const_iterator |
Constant iterator over ManagedExpressionStore - it "const-iterates" over the underlying hash map.
| using LLU::ManagedExpressionStore< T >::iterator = typename std::unordered_map<mint, std::shared_ptr<T> >::iterator |
Iterator over ManagedExpressionStore - it iterates over the underlying hash map.
| using LLU::ManagedExpressionStore< T >::size_type = typename std::unordered_map<mint, std::shared_ptr<T> >::size_type |
Size type of the Store is the same as size_type of the underlying hash map.
|
inlinenoexcept |
Get the const iterator to the first element of the Store.
|
inlinenoexcept |
Get the iterator to the first element of the Store.
|
inlinenoexcept |
Get the const iterator to the first element of the Store.
|
inlinenoexcept |
Get the const iterator past the last element of the Store.
|
inline |
Create new object of class T that will be managed from Wolfram Language and place it in the map of managed objects.
| DynamicType | - actual type of the constructed object, it allows Store to keep objects of subclasses of T |
| Args | - constructor arguments types |
| id | - id of the newly created managed object |
| args | - constructor arguments |
|
inline |
Create instance in the store from a pointer to the managed class object.
This is useful when you have an existing object to be managed or when objects of class T cannot be constructed directly (e.g. because T is an abstract class).
| id | - id of the newly created managed object |
| ptr | - pointer to an instance of T or a subclass |
|
inline |
Create instance in the store from a unique pointer to the managed class object.
The store will claim shared ownership of the managed object.
| id | - id of the newly created managed object |
| ptr | - pointer to an instance of T or a subclass |
|
inlinenoexcept |
Get the const iterator past the last element of the Store.
|
inlinenoexcept |
Get the iterator past the last element of the Store.
|
inlinenoexcept |
Get symbol name that is used in the WL to represent Managed Expressions stored in this Store.
|
inline |
Get managed instance with given id.
Throw if the id is invalid or if there is no corresponding instance.
| id | - id of instance of interest |
|
inline |
Get a shared pointer to a managed instance with given id.
Throw if the id is invalid.
| id | - id of instance of interest |
|
inline |
Check if instance with given id is present in the store.
| id | - id to be checked |
|
inline |
Function that will actually be called by LibraryLink when an instance of Managed Expression is created or deleted.
Notice that this function does not actually create a new object of class T. This is because there is no way to pass constructor arguments here.
| mode | - are we deleting existing instance (True) or creating new one (False) |
| id | - id of the instance of interest |
|
inlinenoexcept |
Register class T as managed expression under given name.
| name | - name of the Wolfram Language symbol that will be used to manage class T |
| libData | - optionally specify WolframLibraryData instance |
WolframLibrary_initialize
|
inline |
Release an instance managed by this Store.
| id | - id of the instance to be released |
|
inlinenoexcept |
Get the number of currently managed expressions.
|
inlinenoexcept |
Unregister class T as managed expression.
| libData | - optionally specify WolframLibraryData instance |
WolframLibrary_uninitialize