DPsim
Public Member Functions | Protected Attributes | Friends | List of all members
CPS::AttributeDynamic< T > Class Template Reference

#include <Attribute.h>

Inheritance diagram for CPS::AttributeDynamic< T >:
[legend]
Collaboration diagram for CPS::AttributeDynamic< T >:
[legend]

Public Member Functions

 AttributeDynamic (T initialValue=T())
 
void addTask (UpdateTaskKind kind, typename AttributeUpdateTaskBase< T >::Ptr task)
 
void clearTasks (UpdateTaskKind kind)
 
void clearAllTasks ()
 
virtual void setReference (typename Attribute< T >::Ptr reference) override
 
virtual std::shared_ptr< T > asRawPointer () override
 
virtual void set (T value) override
 
virtual T & get () override
 
virtual bool isStatic () const override
 
virtual void appendDependencies (AttributeBase::Set *deps) override
 
- Public Member Functions inherited from CPS::Attribute< T >
 Attribute (T initialValue=T())
 
String toString () override
 Fallback method for all attribute types not covered by the specifications in Attribute.cpp.
 
 operator const T & ()
 User-defined cast operator. More...
 
T & operator* ()
 User-defined dereference operator. More...
 
bool copyValue (AttributeBase::Ptr copyFrom) override
 Copy the attribute value of copyFrom onto this attribute. More...
 
const std::type_info & getType () override
 Get the type of this attribute. More...
 
AttributeBase::Ptr cloneValueOntoNewAttribute () override
 Generates a new attribute of the same type and copies the current value in the heap. Does not copy any dependency relations! More...
 
template<class U >
Attribute< U >::Ptr derive (typename AttributeUpdateTask< U, T >::Actor getter=typename AttributeUpdateTask< U, T >::Actor(), typename AttributeUpdateTask< U, T >::Actor setter=typename AttributeUpdateTask< U, T >::Actor())
 
template<typename U = T, std::enable_if_t< std::is_same_v< Complex, U >, bool > = true>
AttributePointer< Attribute< Real > > deriveReal ()
 
template<typename U = T, std::enable_if_t< std::is_same_v< Complex, U >, bool > = true>
AttributePointer< Attribute< Real > > deriveImag ()
 
template<typename U = T, std::enable_if_t< std::is_same_v< Complex, U >, bool > = true>
AttributePointer< Attribute< Real > > deriveMag ()
 
template<typename U = T, std::enable_if_t< std::is_same_v< Complex, U >, bool > = true>
AttributePointer< Attribute< Real > > derivePhase ()
 
template<typename U = T, std::enable_if_t< std::is_same_v< Real, U >||std::is_same_v< Complex, U >, bool > = true>
AttributePointer< Attribute< T > > deriveScaled (T scale)
 
template<class U , class V = T, std::enable_if_t< std::is_same_v< CPS::MatrixVar< U >, V >, bool > = true>
AttributePointer< Attribute< U > > deriveCoeff (typename CPS::MatrixVar< U >::Index row, typename CPS::MatrixVar< U >::Index column)
 
String toString ()
 
String toString ()
 
String toString ()
 
- Public Member Functions inherited from CPS::AttributeBase
virtual AttributeBase::Set getDependencies () final
 

Protected Attributes

std::vector< typename AttributeUpdateTaskBase< T >::PtrupdateTasksOnce
 
std::vector< typename AttributeUpdateTaskBase< T >::PtrupdateTasksOnGet
 
std::vector< typename AttributeUpdateTaskBase< T >::PtrupdateTasksOnSet
 
- Protected Attributes inherited from CPS::Attribute< T >
std::shared_ptr< T > mData
 

Friends

class SharedFactory< AttributeDynamic< T > >
 

Additional Inherited Members

- Public Types inherited from CPS::Attribute< T >
using Type = T
 
using Ptr = AttributePointer< Attribute< T > >
 
- Public Types inherited from CPS::AttributeBase
typedef AttributePointer< AttributeBasePtr
 
typedef std::vector< PtrList
 
typedef std::set< Ptr, AttributeCmp< AttributeBase > > Set
 
typedef std::map< String, PtrMap
 
- Static Public Member Functions inherited from SharedFactory< AttributeDynamic< T > >
static std::shared_ptr< AttributeDynamic< T > > make (Args &&...args)
 

Detailed Description

template<class T>
class CPS::AttributeDynamic< T >

Class for dynamic attributes. A dynamic attribute has an internal value which can be updated by update tasks.

Definition at line 569 of file Attribute.h.

Member Function Documentation

◆ addTask()

template<class T >
void CPS::AttributeDynamic< T >::addTask ( UpdateTaskKind  kind,
typename AttributeUpdateTaskBase< T >::Ptr  task 
)
inline

Allows for adding a new update task to this attribute.

Parameters
kindThe kind of update task
taskThe update task itself

THISISBAD: This is probably not the right time to run this kind of task

Definition at line 586 of file Attribute.h.

◆ appendDependencies()

template<class T >
virtual void CPS::AttributeDynamic< T >::appendDependencies ( AttributeBase::Set *  deps)
inlineoverridevirtual

Implementation for dynamic attributes.This will recursively collect all attributes this attribute depends on, either in the UPDATE_ONCE or the UPDATE_ON_GET tasks. This is done by performing a Depth-First-Search on the dependency graph where the task dependencies of each attribute are the outgoing edges. The deps set contains all the nodes that have already been visited in the graph

Implements CPS::AttributeBase.

Definition at line 680 of file Attribute.h.

◆ asRawPointer()

template<class T >
virtual std::shared_ptr<T> CPS::AttributeDynamic< T >::asRawPointer ( )
inlineoverridevirtual

Exposing the underlying shared_ptr for this attribute's data. Used to create reference relations between two attributes.

Returns
The shared_ptr to this attribute's underlying data

Implements CPS::Attribute< T >.

Definition at line 652 of file Attribute.h.

◆ clearAllTasks()

template<class T >
void CPS::AttributeDynamic< T >::clearAllTasks ( )
inline

Remove all update tasks from this attribute, regardless of their kind.

Definition at line 628 of file Attribute.h.

◆ clearTasks()

template<class T >
void CPS::AttributeDynamic< T >::clearTasks ( UpdateTaskKind  kind)
inline

Removes all update tasks of a given kind from this attribute.

Parameters
kindThe kind of tasks to remove

Definition at line 609 of file Attribute.h.

◆ get()

template<class T >
virtual T& CPS::AttributeDynamic< T >::get ( )
inlineoverridevirtual

Get a mutable reference to the attribute's underlying data. This method is also called when dereferencing an attribute using the * operator

Implements CPS::Attribute< T >.

Definition at line 666 of file Attribute.h.

◆ isStatic()

template<class T >
virtual bool CPS::AttributeDynamic< T >::isStatic ( ) const
inlineoverridevirtual

Check whether this is a static or dynamic attribute

Returns
true for instances of AttributeStatic, false for instances of AttributeDynamic

Implements CPS::AttributeBase.

Definition at line 673 of file Attribute.h.

◆ set()

template<class T >
virtual void CPS::AttributeDynamic< T >::set ( value)
inlineoverridevirtual

Manually set the attribute to the given value. For dynamic attributes, this will trigger the UPDATE_ON_SET tasks for updating any dependency attributes.

Implements CPS::Attribute< T >.

Definition at line 659 of file Attribute.h.

◆ setReference()

template<class T >
virtual void CPS::AttributeDynamic< T >::setReference ( typename Attribute< T >::Ptr  reference)
inlineoverridevirtual

Convenience method for setting this attribute to always equal another attribute. When this is dynamic, this will set up an UPDATE_ONCE task that sets this attribute's data pointer to equal the data pointer of the referenced attribute. If this is static, calling this method will result in a runtime error.

Parameters
referenceThe attribute which's value will be adapted

Implements CPS::Attribute< T >.

Definition at line 634 of file Attribute.h.


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