Open Search
    Registry< T, R > Class Template Reference

    #include <registrybase.h>

    Detailed Description

    template<typename T, typename R>
    class maxon::Registry< T, R >

    A Registry manages a set of entries of the same type. E.g., all classes are registered at the registry Classes, while all data types are registered at DataTypes.

    Registries are declared by the macro MAXON_REGISTRY as derived classes of Registry with the template parameter R being the derived class. For the entries all types are supported which are supported by Data.

    Each registry is identified by a unique identifier.

    Template Parameters
    TType of the values which are stored at the registry. Has to be supported by Data.
    RRegistry class (created by the macro MAXON_REGISTRY).

    Classes

    class  IdIteratorBase
     
    class  IteratorBase
     
    class  IteratorTemplate
     

    Public Types

    using Dependencies = Tuple<>
     
    using EntryType = T
     
    using Iterator = IteratorTemplate< IteratorBase >
     
    using IdIterator = IteratorTemplate< IdIteratorBase >
     

    Static Public Member Functions

    static Iterator GetEntries ()
     
    static IdIterator GetEntriesWithId ()
     
    static const T * Find (const Id &eid)
     
    static const T & Get (const Id &eid)
     
    static Result< void > Insert (const Id &eid, const T &object, const ModuleInfo *module)
     
    static Result< void > Insert (const Id &eid, T &&object, const ModuleInfo *module)
     
    static Result< void > PrivateInsert (const Id &eid, T &object, const ModuleInfo *module)
     
    static Result< GenericDataRegister (const Id &eid, const T &object)
     
    static Result< GenericDataRegister (const Id &eid, T &&object)
     
    static Result< GenericDataPrivateRegister (const Id &eid, T &object)
     
    static Result< BoolErase (const Id &eid)
     

    Member Typedef Documentation

    ◆ Dependencies

    using Dependencies = Tuple<>

    ◆ EntryType

    using EntryType = T

    The type of entries stored at this registry.

    ◆ Iterator

    ◆ IdIterator

    Member Function Documentation

    ◆ GetEntries()

    static Iterator GetEntries ( )
    static

    Returns an iterator over all entries registered at this registry. Because the iterator supports the foreach-protocol, you can write

    for (const Class<ExecutionRef>& execCls : ExecutionJobs::GetEntries())
    {
    ...
    }

    If you are also interested in the Id of the entry, you have to use the iterator returned by GetEntriesWithId().

    Returns
    Iterator over all entries.

    ◆ GetEntriesWithId()

    static IdIterator GetEntriesWithId ( )
    static

    Returns an iterator over all entries registered at this registry. Each entry is returned as a pair of the Id and the entry itself. Because the iterator supports the foreach-protocol, you can write

    for (const auto& entry : ExecutionJobs::GetEntriesWithId())
    {
    const Id& eid = entry.GetKey();
    const Class<ExecutionRef>& execCls = entry.GetValue();
    ...
    }
    Returns
    Iterator over all registry entries (i.e., id-entry-pairs).

    ◆ Find()

    static const T* Find ( const Id eid)
    static

    Returns a pointer to the registry entry registered at this registry under the given identifier. If no entry exists for the given identifier, nullptr is returned.

    Parameters
    [in]eidIdentifier within this registry.
    Returns
    Registered entry, or nullptr.

    ◆ Get()

    static const T& Get ( const Id eid)
    static

    Returns the entry registered at this registry under the given identifier. If no entry exists for the given identifier, a null-value reference is returned.

    Parameters
    [in]eidIdentifier within this registry.
    Returns
    Registered entry, or a null-value reference.

    ◆ Insert() [1/2]

    static Result<void> Insert ( const Id eid,
    const T &  object,
    const ModuleInfo *  module 
    )
    static

    Registers an entry at this registry under the given identifier. If an entry already exists for the identifier, nothing happens, and an IllegalStateError is returned.

    Parameters
    [in]eidIdentifier within this registry.
    [in]objectValue to register.
    [in]moduleThe module which initiates the call. When the module is freed, the entry will be freed too.
    Returns
    Success of operation.

    ◆ Insert() [2/2]

    static Result<void> Insert ( const Id eid,
    T &&  object,
    const ModuleInfo *  module 
    )
    static

    Registers an entry at this registry under the given identifier. If an entry already exists for the identifier, nothing happens, and an IllegalStateError is returned.

    Parameters
    [in]eidIdentifier within this registry.
    [in]objectValue to register.
    [in]moduleThe module which initiates the call. When the module is freed, the entry will be freed too.
    Returns
    Success of operation.

    ◆ PrivateInsert()

    static Result<void> PrivateInsert ( const Id eid,
    T &  object,
    const ModuleInfo *  module 
    )
    static

    ◆ Register() [1/2]

    static Result<GenericData> Register ( const Id eid,
    const T &  object 
    )
    static

    Registers an entry at this registry under the given identifier. If an entry already exists for the identifier, nothing happens, and an IllegalStateError is returned. The entry will be removed when the lifetime of the object wrapped in the return value ends.

    Parameters
    [in]eidIdentifier within this registry.
    [in]objectValue to register.
    Returns
    An object to which the lifetime of the added entry is bound. You have to keep this alive as long as the entry shall remain in the registry.

    ◆ Register() [2/2]

    static Result<GenericData> Register ( const Id eid,
    T &&  object 
    )
    static

    Registers an entry at this registry under the given identifier. If an entry already exists for the identifier, nothing happens, and an IllegalStateError is returned. The entry will be removed when the lifetime of the object wrapped in the return value ends.

    Parameters
    [in]eidIdentifier within this registry.
    [in]objectValue to register.
    Returns
    An object to which the lifetime of the added entry is bound. You have to keep this alive as long as the entry shall remain in the registry.

    ◆ PrivateRegister()

    static Result<GenericData> PrivateRegister ( const Id eid,
    T &  object 
    )
    static

    ◆ Erase()

    static Result<Bool> Erase ( const Id eid)
    static

    Removes the entry identified by eid from this registry. If no such entry exists, nothing happens.

    Parameters
    [in]eidIdentifier of the entry to be removed.