Sen API
Sen Libraries
Loading...
Searching...
No Matches
sen::NativeObject Class Referenceabstract

An object instantiated in this process. This is the base class for all user-implemented objects. More...

#include <native_object.h>

Inheritance diagram for sen::NativeObject:

Public Member Functions

 ~NativeObject () override
virtual void registered (kernel::RegistrationApi &api)
 Implement this function to react to the fact that the object has been created and registered into the execution context.
virtual void update (kernel::RunApi &runApi)
 Implement this function to perform changes to your object state or interactions with other objects. This method is typically called in an execution loop. Does nothing by default.
virtual void unregistered (kernel::RegistrationApi &api)
 Implement this function to react to the fact that the object has been unregistered from the execution context.
virtual bool needsPreDrainOrPreCommit () const noexcept
 True if preUpdate and postUpdate needs to be called for this object. Defaults to false.
virtual void preDrain ()
 Implement this function if you need to perform some action before the draining inputs the component where the object lives. The needsPreDrainOrPreCommit() function should return true for this function to be called.
virtual void preCommit ()
 Implement this function if you need to perform some action before the commit is called in the component where the object lives. The needsPreDrainOrPreCommit() function should return true for this function to be called.
void setNextPropertyUntyped (const Property *property, const Var &value)
 Untyped version of the setNext family of methods that get generated by subclasses.
Var getNextPropertyUntyped (const Property *property) const
 Untyped version of the getNext family of methods that get generated by subclasses.
ObjectId getId () const noexcept final
 Global unique object identification.
const std::string & getName () const noexcept final
 The name given to the object upon construction.
Var getPropertyUntyped (const Property *prop) const final
 Variant-based property getter.
NativeObjectasNativeObject () noexcept final
 Helper that checks if the object is local (without dynamic casts).
const NativeObjectasNativeObject () const noexcept final
 Helper that checks if the object is local (without dynamic casts).
const std::string & getLocalName () const noexcept final
 An alias used as an alternate way of identifying this object locally.
TimeStamp getLastCommitTime () const noexcept override
 The point in time when the last commit was called.
ConnectionGuard onEventUntyped (const Event *ev, EventCallback< VarList > &&callback) final
 Reflection-based interface for reacting to events.
void invokeUntyped (const Method *method, const VarList &args, MethodCallback< Var > &&onDone) final
 Reflection- and variant- based interface for (asynchronously) invoking a method on this object. This mechanism is meant to be used only when the natively generated functions are not available or when performance or type safety are of no particular concern. NOLINTNEXTLINE(google-default-arguments).
ConnectionGuard onPropertyChangedUntyped (const Property *prop, EventCallback< VarList > &&callback) final
 Reflection-based interface for detecting property changes.
virtual ConstTypeHandle< ClassType > getClass () const noexcept=0
 Reflection information.
virtual impl::ProxyObject * asProxyObject () noexcept
 Helper that checks if the object is a proxy (without dynamic casts).
virtual const impl::ProxyObject * asProxyObject () const noexcept
 Helper that checks if the object is a proxy (without dynamic casts).
virtual void invokeAllPropertyCallbacks ()=0
 Helper method that invokes all the registered property callbacks, even if/when the property has not changed. This might prove helpful in situations where the initialization code is similar to the one of these callbacks.

Protected Member Functions

 NativeObject (const std::string &name)
void commit (TimeStamp time)
virtual Var senImplGetPropertyImpl (MemberHash propertyId) const =0
virtual void senImplSetNextPropertyUntyped (MemberHash propertyId, const Var &value)=0
virtual Var senImplGetNextPropertyUntyped (MemberHash propertyId) const =0
uint32_t senImplComputeMaxReliableSerializedPropertySize () const
virtual void senImplCommitImpl (TimeStamp time)=0
virtual void senImplWriteChangedPropertiesToStream (OutputStream &confirmed, impl::BufferProvider uni, impl::BufferProvider multi)=0
virtual void senImplStreamCall (MemberHash methodId, InputStream &in, StreamCallForwarder &&fwd)=0
virtual void senImplVariantCall (MemberHash methodId, const VarList &args, VariantCallForwarder &&fwd)=0
virtual impl::FieldValueGetter senImplGetFieldValueGetter (MemberHash propertyId, Span< uint16_t > fields) const =0
ConnId senImplMakeConnectionId () noexcept
void senImplRemoveUntypedConnection (ConnId id, MemberHash memberHash) override
template<typename R, typename... Args, typename F, class C>
void senImplAsyncCall (C *instance, MethodCallback< R > &&callback, F &&f, bool forcePush, Args... args)
 Queues a call to a method for future execution (non-const version).
template<typename R, typename... Args, typename F, class C>
void senImplAsyncCall (const C *instance, MethodCallback< R > &&callback, F &&f, bool forcePush, Args... args) const
 Queues a call to a method for future execution (const version).
void senImplAsyncCall (const Method *method, const VarList &args, MethodCallback< Var > &&callback)
 Queues a call to a method using a variant-based approach.
template<typename R, typename... Args, typename F, class C>
void senImplAsyncDeferredCall (C *instance, MethodCallback< R > &&callback, F &&f, bool forcePush, Args... args)
 Queues a call to a method for future execution with deferred semantics (non-const version).
template<typename... T>
void senImplProduceEvent (impl::EventBuffer< T... > &eventBuffer, Emit emissionMode, MemberHash eventId, TransportMode transportMode, bool addToTransportQueue, MaybeRef< T >... args)
 Helper to call eventBuffer.produce() with our data.
void senImplEventEmitted (MemberHash id, std::function< VarList()> &&argsGetter, const EventInfo &info) final
 Called by EventBuffer when emitting an event.
void addWorkToQueue (sen::std_util::move_only_function< void()> &&call, bool forcePush) const
 Queues a function (no specific task) into the work queue.
impl::SerializableEventQueue * getOutputEventQueue () noexcept
std::lock_guard< std::shared_mutex > createWriterLock () const
std::shared_lock< std::shared_mutex > createReaderLock () const
virtual void senImplRemoveTypedConnection (ConnId id)=0
ObjectId senImplMakeId (std::string_view objectName) const
 Creates a unique id.
ConnectionGuard senImplMakeConnectionGuard (ConnId id, MemberHash member, bool typed)
 Creates a guard for a callback.
virtual void senImplWriteAllPropertiesToStream (OutputStream &out) const =0
 Writes all properties to out.
virtual void senImplWriteStaticPropertiesToStream (OutputStream &out) const =0
 Writes all static properties to out.
virtual void senImplWriteDynamicPropertiesToStream (OutputStream &out) const =0
 Writes all dynamic properties to out.

Static Protected Member Functions

template<typename R>
static void tryToGetResult (std::shared_ptr< std::future< R > > future, MethodCallback< R > &&callback, bool forcePush)
 Tries to get a result from the future, queuing back the check until timed out.
static void senImplValidateName (std::string_view name)
 Throws std::exception if the name is not valid.
static std::string senImplComputeLocalName (std::string_view name, std::string_view prefix)
 The name, with a prefix (if any).

Friends

template<typename... T>
class impl::EventBuffer
class impl::NativeObjectProxy
class impl::FilteredProvider
class kernel::impl::RemoteParticipant
class kernel::impl::LocalParticipant
class kernel::impl::Runner
class kernel::impl::ObjectUpdate
class kernel::PipelineComponent
impl::WorkQueue * impl::getWorkQueue (NativeObject *object) noexcept

Detailed Description

An object instantiated in this process. This is the base class for all user-implemented objects.

Constructor & Destructor Documentation

◆ ~NativeObject()

sen::NativeObject::~NativeObject ( )
override

◆ NativeObject()

sen::NativeObject::NativeObject ( const std::string & name)
explicitprotected

Member Function Documentation

◆ registered()

virtual void sen::NativeObject::registered ( kernel::RegistrationApi & api)
virtual

Implement this function to react to the fact that the object has been created and registered into the execution context.

◆ update()

virtual void sen::NativeObject::update ( kernel::RunApi & runApi)
virtual

Implement this function to perform changes to your object state or interactions with other objects. This method is typically called in an execution loop. Does nothing by default.

◆ unregistered()

virtual void sen::NativeObject::unregistered ( kernel::RegistrationApi & api)
virtual

Implement this function to react to the fact that the object has been unregistered from the execution context.

◆ needsPreDrainOrPreCommit()

virtual bool sen::NativeObject::needsPreDrainOrPreCommit ( ) const
inlinenodiscardvirtualnoexcept

True if preUpdate and postUpdate needs to be called for this object. Defaults to false.

◆ preDrain()

virtual void sen::NativeObject::preDrain ( )
inlinevirtual

Implement this function if you need to perform some action before the draining inputs the component where the object lives. The needsPreDrainOrPreCommit() function should return true for this function to be called.

◆ preCommit()

virtual void sen::NativeObject::preCommit ( )
inlinevirtual

Implement this function if you need to perform some action before the commit is called in the component where the object lives. The needsPreDrainOrPreCommit() function should return true for this function to be called.

◆ setNextPropertyUntyped()

void sen::NativeObject::setNextPropertyUntyped ( const Property * property,
const Var & value )

Untyped version of the setNext family of methods that get generated by subclasses.

◆ getNextPropertyUntyped()

Var sen::NativeObject::getNextPropertyUntyped ( const Property * property) const
nodiscard

Untyped version of the getNext family of methods that get generated by subclasses.

◆ getId()

ObjectId sen::NativeObject::getId ( ) const
nodiscardfinalvirtualnoexcept

Global unique object identification.

Implements sen::Object.

◆ getName()

const std::string & sen::NativeObject::getName ( ) const
nodiscardfinalvirtualnoexcept

The name given to the object upon construction.

Implements sen::Object.

◆ getPropertyUntyped()

Var sen::NativeObject::getPropertyUntyped ( const Property * prop) const
nodiscardfinalvirtual

Variant-based property getter.

Implements sen::Object.

◆ asNativeObject() [1/2]

NativeObject * sen::NativeObject::asNativeObject ( )
nodiscardfinalvirtualnoexcept

Helper that checks if the object is local (without dynamic casts).

Reimplemented from sen::Object.

◆ asNativeObject() [2/2]

const NativeObject * sen::NativeObject::asNativeObject ( ) const
nodiscardfinalvirtualnoexcept

Helper that checks if the object is local (without dynamic casts).

Reimplemented from sen::Object.

◆ getLocalName()

const std::string & sen::NativeObject::getLocalName ( ) const
nodiscardfinalvirtualnoexcept

An alias used as an alternate way of identifying this object locally.

Implements sen::Object.

◆ getLastCommitTime()

TimeStamp sen::NativeObject::getLastCommitTime ( ) const
nodiscardoverridevirtualnoexcept

The point in time when the last commit was called.

Implements sen::Object.

◆ onEventUntyped()

ConnectionGuard sen::NativeObject::onEventUntyped ( const Event * ev,
EventCallback< VarList > && callback )
nodiscardfinalvirtual

Reflection-based interface for reacting to events.

Note
Only one callback per event is stored. This mechanism is meant to be used only when the natively generated functions are not available or when performance or type safety are of no particular concern.

Implements sen::Object.

◆ invokeUntyped()

void sen::NativeObject::invokeUntyped ( const Method * method,
const VarList & args,
MethodCallback< Var > && onDone )
inlinefinalvirtual

Reflection- and variant- based interface for (asynchronously) invoking a method on this object. This mechanism is meant to be used only when the natively generated functions are not available or when performance or type safety are of no particular concern. NOLINTNEXTLINE(google-default-arguments).

Implements sen::Object.

◆ onPropertyChangedUntyped()

ConnectionGuard sen::NativeObject::onPropertyChangedUntyped ( const Property * prop,
EventCallback< VarList > && callback )
nodiscardfinalvirtual

Reflection-based interface for detecting property changes.

Note
Only one callback per property is stored. This mechanism is meant to be used only when the natively generated functions are not available or when performance or type safety are of no particular concern.

Implements sen::Object.

◆ commit()

void sen::NativeObject::commit ( TimeStamp time)
protected

◆ senImplGetPropertyImpl()

virtual Var sen::NativeObject::senImplGetPropertyImpl ( MemberHash propertyId) const
nodiscardprotectedpure virtual

◆ senImplSetNextPropertyUntyped()

virtual void sen::NativeObject::senImplSetNextPropertyUntyped ( MemberHash propertyId,
const Var & value )
protectedpure virtual

◆ senImplGetNextPropertyUntyped()

virtual Var sen::NativeObject::senImplGetNextPropertyUntyped ( MemberHash propertyId) const
nodiscardprotectedpure virtual

◆ senImplComputeMaxReliableSerializedPropertySize()

uint32_t sen::NativeObject::senImplComputeMaxReliableSerializedPropertySize ( ) const
inlinenodiscardprotected

◆ senImplCommitImpl()

virtual void sen::NativeObject::senImplCommitImpl ( TimeStamp time)
protectedpure virtual

◆ senImplWriteChangedPropertiesToStream()

virtual void sen::NativeObject::senImplWriteChangedPropertiesToStream ( OutputStream & confirmed,
impl::BufferProvider uni,
impl::BufferProvider multi )
protectedpure virtual

◆ senImplStreamCall()

virtual void sen::NativeObject::senImplStreamCall ( MemberHash methodId,
InputStream & in,
StreamCallForwarder && fwd )
protectedpure virtual

◆ senImplVariantCall()

virtual void sen::NativeObject::senImplVariantCall ( MemberHash methodId,
const VarList & args,
VariantCallForwarder && fwd )
protectedpure virtual

◆ senImplGetFieldValueGetter()

virtual impl::FieldValueGetter sen::NativeObject::senImplGetFieldValueGetter ( MemberHash propertyId,
Span< uint16_t > fields ) const
nodiscardprotectedpure virtual

◆ senImplMakeConnectionId()

ConnId sen::NativeObject::senImplMakeConnectionId ( )
nodiscardprotectednoexcept

◆ senImplRemoveUntypedConnection()

void sen::NativeObject::senImplRemoveUntypedConnection ( ConnId id,
MemberHash memberHash )
overrideprotectedvirtual

Implements sen::Object.

◆ senImplAsyncCall() [1/3]

template<typename R, typename... Args, typename F, class C>
void sen::NativeObject::senImplAsyncCall ( C * instance,
MethodCallback< R > && callback,
F && f,
bool forcePush,
Args... args )
inlineprotected

Queues a call to a method for future execution (non-const version).

◆ senImplAsyncCall() [2/3]

template<typename R, typename... Args, typename F, class C>
void sen::NativeObject::senImplAsyncCall ( const C * instance,
MethodCallback< R > && callback,
F && f,
bool forcePush,
Args... args ) const
inlineprotected

Queues a call to a method for future execution (const version).

◆ senImplAsyncCall() [3/3]

void sen::NativeObject::senImplAsyncCall ( const Method * method,
const VarList & args,
MethodCallback< Var > && callback )
protected

Queues a call to a method using a variant-based approach.

◆ senImplAsyncDeferredCall()

template<typename R, typename... Args, typename F, class C>
void sen::NativeObject::senImplAsyncDeferredCall ( C * instance,
MethodCallback< R > && callback,
F && f,
bool forcePush,
Args... args )
inlineprotected

Queues a call to a method for future execution with deferred semantics (non-const version).

◆ tryToGetResult()

template<typename R>
void sen::NativeObject::tryToGetResult ( std::shared_ptr< std::future< R > > future,
MethodCallback< R > && callback,
bool forcePush )
inlinestaticprotected

Tries to get a result from the future, queuing back the check until timed out.

◆ senImplProduceEvent()

template<typename... T>
void sen::NativeObject::senImplProduceEvent ( impl::EventBuffer< T... > & eventBuffer,
Emit emissionMode,
MemberHash eventId,
TransportMode transportMode,
bool addToTransportQueue,
MaybeRef< T >... args )
inlineprotected

Helper to call eventBuffer.produce() with our data.

◆ senImplEventEmitted()

void sen::NativeObject::senImplEventEmitted ( MemberHash id,
std::function< VarList()> && argsGetter,
const EventInfo & info )
finalprotectedvirtual

Called by EventBuffer when emitting an event.

Implements sen::Object.

◆ addWorkToQueue()

void sen::NativeObject::addWorkToQueue ( sen::std_util::move_only_function< void()> && call,
bool forcePush ) const
protected

Queues a function (no specific task) into the work queue.

◆ getOutputEventQueue()

impl::SerializableEventQueue * sen::NativeObject::getOutputEventQueue ( )
nodiscardprotectednoexcept

◆ createWriterLock()

std::lock_guard< std::shared_mutex > sen::NativeObject::createWriterLock ( ) const
inlinenodiscardprotected

◆ createReaderLock()

std::shared_lock< std::shared_mutex > sen::NativeObject::createReaderLock ( ) const
inlinenodiscardprotected

◆ getClass()

virtual ConstTypeHandle< ClassType > sen::Object::getClass ( ) const
nodiscardpure virtualnoexceptinherited

Reflection information.

◆ asProxyObject() [1/2]

virtual impl::ProxyObject * sen::Object::asProxyObject ( )
inlinenodiscardvirtualnoexceptinherited

Helper that checks if the object is a proxy (without dynamic casts).

◆ asProxyObject() [2/2]

virtual const impl::ProxyObject * sen::Object::asProxyObject ( ) const
inlinenodiscardvirtualnoexceptinherited

Helper that checks if the object is a proxy (without dynamic casts).

◆ invokeAllPropertyCallbacks()

virtual void sen::Object::invokeAllPropertyCallbacks ( )
pure virtualinherited

Helper method that invokes all the registered property callbacks, even if/when the property has not changed. This might prove helpful in situations where the initialization code is similar to the one of these callbacks.

◆ senImplRemoveTypedConnection()

virtual void sen::Object::senImplRemoveTypedConnection ( ConnId id)
protectedpure virtualinherited

◆ senImplMakeId()

ObjectId sen::Object::senImplMakeId ( std::string_view objectName) const
nodiscardprotectedinherited

Creates a unique id.

◆ senImplMakeConnectionGuard()

ConnectionGuard sen::Object::senImplMakeConnectionGuard ( ConnId id,
MemberHash member,
bool typed )
nodiscardprotectedinherited

Creates a guard for a callback.

◆ senImplValidateName()

void sen::Object::senImplValidateName ( std::string_view name)
staticprotectedinherited

Throws std::exception if the name is not valid.

◆ senImplComputeLocalName()

std::string sen::Object::senImplComputeLocalName ( std::string_view name,
std::string_view prefix )
staticnodiscardprotectedinherited

The name, with a prefix (if any).

◆ senImplWriteAllPropertiesToStream()

virtual void sen::Object::senImplWriteAllPropertiesToStream ( OutputStream & out) const
protectedpure virtualinherited

Writes all properties to out.

◆ senImplWriteStaticPropertiesToStream()

virtual void sen::Object::senImplWriteStaticPropertiesToStream ( OutputStream & out) const
protectedpure virtualinherited

Writes all static properties to out.

◆ senImplWriteDynamicPropertiesToStream()

virtual void sen::Object::senImplWriteDynamicPropertiesToStream ( OutputStream & out) const
protectedpure virtualinherited

Writes all dynamic properties to out.

◆ impl::EventBuffer

template<typename... T>
friend class impl::EventBuffer
friend

◆ impl::NativeObjectProxy

friend class impl::NativeObjectProxy
friend

◆ impl::FilteredProvider

friend class impl::FilteredProvider
friend

◆ kernel::impl::RemoteParticipant

friend class kernel::impl::RemoteParticipant
friend

◆ kernel::impl::LocalParticipant

friend class kernel::impl::LocalParticipant
friend

◆ kernel::impl::Runner

friend class kernel::impl::Runner
friend

◆ kernel::impl::ObjectUpdate

friend class kernel::impl::ObjectUpdate
friend

◆ kernel::PipelineComponent

friend class kernel::PipelineComponent
friend

◆ impl::getWorkQueue

impl::WorkQueue * impl::getWorkQueue ( NativeObject * object)
friend

The documentation for this class was generated from the following file: