Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | Private Types | Private Attributes | List of all members
inexor::rpc::SharedVar< T > Class Template Reference

SharedVar wrapper for primitive/immutable objects. More...

#include <SharedVar.hpp>

Public Member Functions

T & operator* ()
 
const T & operator* () const
 
T * operator-> ()
 
 operator T & ()
 
template<typename... Args>
 SharedVar (Args &&...args, SharedOption)
 
 SharedVar (const SharedVar< T > &otr)
 
 SharedVar (T &otr)
 
 SharedVar (T &&otr)
 
 SharedVar (T &otr, SharedOption)
 
 SharedVar (T &&otr, SharedOption)
 
operator= (const char *c)
 
operator= (const T &otr)
 
operator= (T &&otr)
 
 UNR (++)
 
 UNR (--)
 
 UNL (++)
 
 UNL (--)
 
 ASGN (+)
 
 ASGN (-)
 
ASGN * ASGN (/);ASGN(%
 
ASGN & ASGN (|);ASGN(^
 
 ASGN (<<)
 
 ASGN (>>)
 
void setnosync (const char *c)
 
void setnosync (const T &otr)
 
void setnosync (T &&otr)
 
void sync ()
 

Public Attributes

signal< void(const T &, const T &)> onChange
 Event that is fired when a new value is assigned;. More...
 

Private Types

typedef SharedVar< T > TMe
 
template<typename... A>
using signal = boost::signals2::signal< A...>
 

Private Attributes

value
 

Detailed Description

template<typename T>
class inexor::rpc::SharedVar< T >

SharedVar wrapper for primitive/immutable objects.

This first and foremost is a wrapper around stuff. We provide * and -> operators to work with the value and define a cast operator that casts to the contained value. It best works with primitive or non mutable values, as changes to the value can not be detected.

The cast operator can make some problems, when the compiler can not figure out what to use and you might see some giant error cascades. In these cases, try using the value itself (*observ_instance) or using an explicit cast.

SharedVar provides a special assignment operator: If that is called, it first calls the onChange event with the old and the new value. Only afterwards the new value is assigned.

The value of the variable inside SharedVar is undefined while the listeners are called;

During the event, do not change the value of the variable (that would create an recursive event), or the parameters.

Example

``` SharedVar<int> oi = 22;

oi.onChange.connect([] (const int &a, const int &b) { Log.std->info("hey we changed! (old: {} new: {}", a, b); } );

void main() { oi = 33; oi += 22; } ```

Member Typedef Documentation

template<typename T>
template<typename... A>
using inexor::rpc::SharedVar< T >::signal = boost::signals2::signal<A...>
private
template<typename T>
typedef SharedVar<T> inexor::rpc::SharedVar< T >::TMe
private

Constructor & Destructor Documentation

template<typename T>
template<typename... Args>
inexor::rpc::SharedVar< T >::SharedVar ( Args &&...  args,
SharedOption   
)
inlineexplicit
template<typename T>
inexor::rpc::SharedVar< T >::SharedVar ( const SharedVar< T > &  otr)
inlineexplicit
template<typename T>
inexor::rpc::SharedVar< T >::SharedVar ( T &  otr)
inlineexplicit
template<typename T>
inexor::rpc::SharedVar< T >::SharedVar ( T &&  otr)
inlineexplicit
template<typename T>
inexor::rpc::SharedVar< T >::SharedVar ( T &  otr,
SharedOption   
)
inlineexplicit
template<typename T>
inexor::rpc::SharedVar< T >::SharedVar ( T &&  otr,
SharedOption   
)
inlineexplicit

Member Function Documentation

template<typename T>
inexor::rpc::SharedVar< T >::ASGN ( )
template<typename T>
inexor::rpc::SharedVar< T >::ASGN ( )
template<typename T>
ASGN* inexor::rpc::SharedVar< T >::ASGN ( )
template<typename T>
ASGN& inexor::rpc::SharedVar< T >::ASGN ( )
template<typename T>
inexor::rpc::SharedVar< T >::ASGN ( <<  )
template<typename T>
inexor::rpc::SharedVar< T >::ASGN ( >>  )
template<typename T>
inexor::rpc::SharedVar< T >::operator T & ( )
inline
template<typename T>
T& inexor::rpc::SharedVar< T >::operator* ( )
inline
template<typename T>
const T& inexor::rpc::SharedVar< T >::operator* ( ) const
inline
template<typename T>
T* inexor::rpc::SharedVar< T >::operator-> ( )
inline
template<typename T>
T inexor::rpc::SharedVar< T >::operator= ( const char *  c)
inline
template<typename T>
T inexor::rpc::SharedVar< T >::operator= ( const T &  otr)
inline
template<typename T>
T inexor::rpc::SharedVar< T >::operator= ( T &&  otr)
inline
template<typename T>
void inexor::rpc::SharedVar< T >::setnosync ( const char *  c)
inline
template<typename T>
void inexor::rpc::SharedVar< T >::setnosync ( const T &  otr)
inline
template<typename T>
void inexor::rpc::SharedVar< T >::setnosync ( T &&  otr)
inline
template<typename T>
void inexor::rpc::SharedVar< T >::sync ( )
inline
template<typename T>
inexor::rpc::SharedVar< T >::UNL ( ++  )
template<typename T>
inexor::rpc::SharedVar< T >::UNL ( --  )
template<typename T>
inexor::rpc::SharedVar< T >::UNR ( ++  )
template<typename T>
inexor::rpc::SharedVar< T >::UNR ( --  )

Member Data Documentation

template<typename T>
signal<void(const T&, const T&)> inexor::rpc::SharedVar< T >::onChange

Event that is fired when a new value is assigned;.

This does however not fire, when the value is merely modified

params: old value, new value

Referenced by inexor::util::log_manager::log_manager(), inexor::util::Logger::Logger(), inexor::rpc::SharedVar< char * >::operator=(), inexor::rpc::SharedVar< char * >::SharedVar(), and inexor::rpc::SharedVar< char * >::sync().

template<typename T>
T inexor::rpc::SharedVar< T >::value
private

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