smgl 0.11.0
Structured Metadata Engine and Graph Objects Library
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
smgl::InputPort< T > Class Template Reference

Typed InputPort class. More...

#include <smgl/Ports.hpp>

Inheritance diagram for smgl::InputPort< T >:
[legend]
Collaboration diagram for smgl::InputPort< T >:
[legend]

Public Member Functions

 ~InputPort () override=default
 
 InputPort (T *target)
 Construct with pointer to target object.
 
 InputPort (std::function< void(T)> target)
 Construct with std::function target.
 
template<class Obj , class ObjMemberFn >
 InputPort (Obj *obj, ObjMemberFn &&fn)
 Construct with member function target.
 
 InputPort (const InputPort &)=delete
 
InputPortoperator= (const InputPort &)=delete
 
 InputPort (const InputPort &&)=delete
 
InputPortoperator= (const InputPort &&)=delete
 
void post (const Update< T > &u)
 Post an update to the port.
 
void post (T v, bool immediate=false)
 Post an update to the port.
 
void operator() (const Update< T > &u)
 Post an update to the port.
 
void operator() (T v, bool immediate=false)
 Post an update to the port.
 
InputPort< T > & operator= (T v)
 Post an update to the port.
 
InputPort< T > & operator= (Output &op) override
 Connect an output port to an input port.
 
bool update () override
 Update the target with the most recently posted update.
 
void notify (State s) override
 Receive a state update from a connected port.
 
Metadata serialize () override
 Get port metadata.
 
void deserialize (const Metadata &m) override
 Load port metadata.
 
- Public Member Functions inherited from smgl::Input
std::vector< ConnectiongetConnections () const
 
std::size_t numConnections () const
 Get the number of connections.
 
- Public Member Functions inherited from smgl::Port
State state () const
 
void setState (State s)
 
void setParent (Node *p)
 
- Public Member Functions inherited from smgl::UniquelyIdentifiable
auto uuid () const -> Uuid
 
void setUuid (const Uuid &uuid)
 

Private Attributes

std::function< void(T)> target_
 
Update< T > queued_update_
 

Additional Inherited Members

- Public Types inherited from smgl::Port
enum class  State { Idle , Waiting , Queued , Error }
 
- Protected Member Functions inherited from smgl::Input
 Input ()
 
 ~Input () override
 
virtual void connect (Output *op) final
 
virtual void disconnect (Output *op) final
 
- Protected Member Functions inherited from smgl::Port
 Port ()=default
 
 Port (State s)
 
virtual ~Port ()=default
 
- Protected Member Functions inherited from smgl::UniquelyIdentifiable
 UniquelyIdentifiable ()=default
 
- Protected Attributes inherited from smgl::Input
Outputsrc_ {nullptr}
 
std::size_t last_updated_ {0}
 
- Protected Attributes inherited from smgl::Port
State state_ {State::Idle}
 
Nodeparent_ {nullptr}
 
- Protected Attributes inherited from smgl::UniquelyIdentifiable
Uuid uuid_ {Uuid::Uuid4()}
 

Detailed Description

template<typename T>
class smgl::InputPort< T >

Typed InputPort class.

An InputPort receives values via the post() function and passes them to a target object or function. It is similar to a setter function. T should be default constructible.

Template Parameters
TType of object received by this port

Definition at line 212 of file Ports.hpp.

Constructor & Destructor Documentation

◆ ~InputPort()

template<typename T >
smgl::InputPort< T >::~InputPort ( )
overridedefault

Default destructor

◆ InputPort() [1/5]

template<typename T >
smgl::InputPort< T >::InputPort ( T *  target)
explicit

Construct with pointer to target object.

Definition at line 10 of file PortsImpl.hpp.

◆ InputPort() [2/5]

template<typename T >
smgl::InputPort< T >::InputPort ( std::function< void(T)>  target)
explicit

Construct with std::function target.

Definition at line 15 of file PortsImpl.hpp.

◆ InputPort() [3/5]

template<typename T >
template<class Obj , class ObjMemberFn >
smgl::InputPort< T >::InputPort ( Obj *  obj,
ObjMemberFn &&  fn 
)
explicit

Construct with member function target.

Definition at line 21 of file PortsImpl.hpp.

◆ InputPort() [4/5]

template<typename T >
smgl::InputPort< T >::InputPort ( const InputPort< T > &  )
delete

Disable copy

◆ InputPort() [5/5]

template<typename T >
smgl::InputPort< T >::InputPort ( const InputPort< T > &&  )
delete

Disable move

Member Function Documentation

◆ deserialize()

template<typename T >
void smgl::InputPort< T >::deserialize ( const Metadata m)
overridevirtual

Load port metadata.

Implements smgl::Port.

Definition at line 102 of file PortsImpl.hpp.

◆ notify()

template<typename T >
void smgl::InputPort< T >::notify ( State  s)
overridevirtual

Receive a state update from a connected port.

Implements smgl::Port.

Definition at line 86 of file PortsImpl.hpp.

◆ operator()() [1/2]

template<typename T >
void smgl::InputPort< T >::operator() ( const Update< T > &  u)

Post an update to the port.

The target is not updated until update() has been called.

Definition at line 46 of file PortsImpl.hpp.

◆ operator()() [2/2]

template<typename T >
void smgl::InputPort< T >::operator() ( v,
bool  immediate = false 
)

Post an update to the port.

If immediate = true, the target will be updated immediately.

Warning
Should only be used when testing or debugging.

Definition at line 52 of file PortsImpl.hpp.

◆ operator=() [1/4]

template<typename T >
InputPort & smgl::InputPort< T >::operator= ( const InputPort< T > &&  )
delete

Disable move

◆ operator=() [2/4]

template<typename T >
InputPort & smgl::InputPort< T >::operator= ( const InputPort< T > &  )
delete

Disable copy

◆ operator=() [3/4]

template<typename T >
auto smgl::InputPort< T >::operator= ( Output op)
overridevirtual

Connect an output port to an input port.

Exceptions
smgl::bad_connectionif port instances do not share underlying type T

Reimplemented from smgl::Input.

Definition at line 65 of file PortsImpl.hpp.

◆ operator=() [4/4]

template<typename T >
auto smgl::InputPort< T >::operator= ( v)

Post an update to the port.

If immediate = true, the target will be updated immediately.

Warning
Should only be used when testing or debugging.

Definition at line 58 of file PortsImpl.hpp.

◆ post() [1/2]

template<typename T >
void smgl::InputPort< T >::post ( const Update< T > &  u)

Post an update to the port.

The target is not updated until update() has been called.

Definition at line 27 of file PortsImpl.hpp.

◆ post() [2/2]

template<typename T >
void smgl::InputPort< T >::post ( v,
bool  immediate = false 
)

Post an update to the port.

If immediate = true, the target will be updated immediately.

Warning
Should only be used when testing or debugging.

Definition at line 37 of file PortsImpl.hpp.

◆ serialize()

template<typename T >
auto smgl::InputPort< T >::serialize ( )
overridevirtual

Get port metadata.

Implements smgl::Port.

Definition at line 93 of file PortsImpl.hpp.

◆ update()

template<typename T >
auto smgl::InputPort< T >::update ( )
overridevirtual

Update the target with the most recently posted update.

Implements smgl::Port.

Definition at line 73 of file PortsImpl.hpp.

Member Data Documentation

◆ queued_update_

template<typename T >
Update<T> smgl::InputPort< T >::queued_update_
private

Most recently posted update

Definition at line 281 of file Ports.hpp.

◆ target_

template<typename T >
std::function<void(T)> smgl::InputPort< T >::target_
private

Target object updated by std::function

Definition at line 279 of file Ports.hpp.


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