ecto
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
ecto::tendril Class Reference

A tendril is the slender, winding organ of the ecto::cell that gives it its awesome type erasure and uber flexibility. More...

#include <tendril.hpp>

Collaboration diagram for ecto::tendril:
Collaboration graph
[legend]

Classes

struct  Caller
 
struct  Converter
 
struct  ConverterImpl
 
struct  ConverterImpl< none, _ >
 
struct  empty_t
 
struct  none
 A none type for tendril when the tendril is uninitialized. More...
 

Public Types

enum  {
  DEFAULT_VALUE =0, DIRTY, USER_SUPPLIED, REQUIRED,
  OPTIONAL, N_FLAGS
}
 
typedef boost::function1< void, tendril & > TendrilJob
 

Public Member Functions

 tendril ()
 Creates a tendril that is initialized with the tendril::none type. This should be fairly cheap. More...
 
 ~tendril ()
 
 tendril (const tendril &rhs)
 
tendriloperator= (const tendril &rhs)
 
template<typename T >
 tendril (const T &t, const std::string &doc)
 A convenience constructor for creating a tendril that holds the given type. More...
 
std::string type_name () const
 This is an unmangled type name for what ever tendril is holding. More...
 
const char * type_id () const
 
std::string doc () const
 A doc string for this tendril, "foo is for the input and will be mashed with spam.". More...
 
void set_doc (const std::string &doc_str)
 The doc for this tendril is runtime defined, so you may want to update it. More...
 
template<typename T >
void set_default_val (const T &val=T())
 This sets the default value of the tendril. This is a. More...
 
void required (bool b)
 
bool required () const
 
template<typename T >
const T & get () const
 
template<typename T >
T & get ()
 
template<typename T >
void operator<< (const T &val)
 
void operator<< (const boost::python::object &obj)
 
tendriloperator<< (const tendril &rhs)
 
template<typename T >
bool is_type () const
 runtime check if the tendril is of the given type. More...
 
bool same_type (const tendril &rhs) const
 Test if the given tendril is the same type as this one. More...
 
bool compatible_type (const tendril &rhs) const
 
void enforce_compatible_type (const tendril &rhs) const
 
template<typename T >
void enforce_type () const
 runtime check if the tendril is of the given type, this will throw. More...
 
bool user_supplied () const
 The value that this tendril holds was supplied by the user at some point. More...
 
void user_supplied (bool v)
 
bool has_default () const
 The tendril was initialized with default value. More...
 
template<typename Signature >
boost::signals2::connection connect (Signature slot)
 
template<typename T >
tendrilset_callback (typename boost::function1< void, T > cb)
 
void notify ()
 Notify the callback, only if this is dirty. More...
 
bool dirty () const
 
void dirty (bool)
 Set the tendril dirty, implying that the value has changed. More...
 
template<typename T >
void operator>> (T &val) const
 
void operator>> (boost::python::object &obj) const
 
void operator>> (const tendril_ptr &rhs) const
 
void operator>> (tendril_ptr &rhs) const
 
void operator>> (tendril &rhs) const
 
template<typename Archive >
void serialize (Archive &ar, const unsigned int)
 

Static Public Attributes

static const empty_t empty
 

Private Types

typedef boost::signals2::signal< void(tendril &)> job_signal_t
 

Private Member Functions

template<typename T >
const T & unsafe_get () const
 
template<typename T >
T & unsafe_get ()
 
template<typename T >
void set_holder (const T &t=T())
 
void copy_holder (const tendril &rhs)
 

Private Attributes

boost::any holder_
 
const char * type_ID_
 
std::string doc_
 
std::bitset< N_FLAGSflags_
 
job_signal_t jobs_
 
Converterconverter
 

Friends

template<typename T >
void operator>> (const tendril_cptr &rhs, T &val)
 
void operator>> (const tendril_ptr &rhs, boost::python::object &obj)
 
void operator>> (const tendril_cptr &rhs, boost::python::object &obj)
 
template<typename T >
void operator<< (const tendril_ptr &lhs, const T &rhs)
 
void operator<< (const tendril_ptr &lhs, const tendril_ptr &rhs)
 
void operator<< (const tendril_ptr &lhs, const tendril_cptr &rhs)
 
template<typename T >
tendril_ptr make_tendril ()
 

Detailed Description

A tendril is the slender, winding organ of the ecto::cell that gives it its awesome type erasure and uber flexibility.

Each tendril is a type erasing holder for any instance of any type, and allows introspection including its value, type, and doc string.

The tendril operates as a value holder, so treat it as such. If you would like to pass it around without copies, construct a pointer to tendril, perhaps with the make_tendril<T>() function.

Items held by the tendril must be copy constructible and copiable.

Member Typedef Documentation

typedef boost::signals2::signal<void(tendril&)> ecto::tendril::job_signal_t
private
typedef boost::function1<void, tendril&> ecto::tendril::TendrilJob

Member Enumeration Documentation

anonymous enum
Enumerator
DEFAULT_VALUE 
DIRTY 
USER_SUPPLIED 
REQUIRED 
OPTIONAL 
N_FLAGS 

Constructor & Destructor Documentation

ecto::tendril::tendril ( )

Creates a tendril that is initialized with the tendril::none type. This should be fairly cheap.

ecto::tendril::~tendril ( )
ecto::tendril::tendril ( const tendril rhs)
template<typename T >
ecto::tendril::tendril ( const T &  t,
const std::string &  doc 
)
inline

A convenience constructor for creating a tendril that holds the given type.

Template Parameters
TThe type to hide in this tendril
Parameters
tdefault value for t
doca documentation string

Member Function Documentation

bool ecto::tendril::compatible_type ( const tendril rhs) const
template<typename Signature >
boost::signals2::connection ecto::tendril::connect ( Signature  slot)
inline
void ecto::tendril::copy_holder ( const tendril rhs)
private
bool ecto::tendril::dirty ( ) const

The tendril has likely been modified since the last time that notify has beend called. This gets unset after its changed-callbacks have fired

void ecto::tendril::dirty ( bool  )

Set the tendril dirty, implying that the value has changed.

std::string ecto::tendril::doc ( ) const

A doc string for this tendril, "foo is for the input and will be mashed with spam.".

Returns
A very descriptive human readable string of whatever the tendril is holding on to.
void ecto::tendril::enforce_compatible_type ( const tendril rhs) const
template<typename T >
void ecto::tendril::enforce_type ( ) const
inline

runtime check if the tendril is of the given type, this will throw.

template<typename T >
const T& ecto::tendril::get ( ) const
inline

Given T this will get the type from the tendril, also enforcing type with an exception.

Returns
a const reference to the value of the tendril (no copies)
template<typename T >
T& ecto::tendril::get ( )
inline
bool ecto::tendril::has_default ( ) const

The tendril was initialized with default value.

template<typename T >
bool ecto::tendril::is_type ( ) const
inline

runtime check if the tendril is of the given type.

Returns
true if it is the type.
void ecto::tendril::notify ( )

Notify the callback, only if this is dirty.

template<typename T >
void ecto::tendril::operator<< ( const T &  val)
inline
void ecto::tendril::operator<< ( const boost::python::object &  obj)
tendril& ecto::tendril::operator<< ( const tendril rhs)
tendril& ecto::tendril::operator= ( const tendril rhs)
template<typename T >
void ecto::tendril::operator>> ( T &  val) const
inline
void ecto::tendril::operator>> ( boost::python::object &  obj) const
inline
void ecto::tendril::operator>> ( const tendril_ptr rhs) const
inline
void ecto::tendril::operator>> ( tendril_ptr rhs) const
inline
void ecto::tendril::operator>> ( tendril rhs) const
inline
void ecto::tendril::required ( bool  b)
bool ecto::tendril::required ( ) const
bool ecto::tendril::same_type ( const tendril rhs) const

Test if the given tendril is the same type as this one.

Parameters
rhsThe tendril to test against.
Returns
true if they are the same type.
template<typename Archive >
void ecto::tendril::serialize ( Archive &  ar,
const unsigned  int 
)
template<typename T >
tendril& ecto::tendril::set_callback ( typename boost::function1< void, T >  cb)
inline

Register a typed callback with the tendril... Will throw on wrong type.

Parameters
cbWill be called by the notify function, if the tendril is dirty.
Returns
this
template<typename T >
void ecto::tendril::set_default_val ( const T &  val = T())
inline

This sets the default value of the tendril. This is a.

Parameters
val
void ecto::tendril::set_doc ( const std::string &  doc_str)

The doc for this tendril is runtime defined, so you may want to update it.

Parameters
doc_strA human readable description of the tendril.
template<typename T >
void ecto::tendril::set_holder ( const T &  t = T())
inlineprivate
const char* ecto::tendril::type_id ( ) const
inline
std::string ecto::tendril::type_name ( ) const

This is an unmangled type name for what ever tendril is holding.

Returns
the unmangled name, e.g. "cv::Mat", or "pcl::PointCloud<pcl::PointXYZ>"
template<typename T >
const T& ecto::tendril::unsafe_get ( ) const
inlineprivate
template<typename T >
T& ecto::tendril::unsafe_get ( )
inlineprivate
bool ecto::tendril::user_supplied ( ) const

The value that this tendril holds was supplied by the user at some point.

void ecto::tendril::user_supplied ( bool  v)

Friends And Related Function Documentation

template<typename T >
tendril_ptr make_tendril ( )
friend
template<typename T >
void operator<< ( const tendril_ptr lhs,
const T &  rhs 
)
friend
void operator<< ( const tendril_ptr lhs,
const tendril_ptr rhs 
)
friend
void operator<< ( const tendril_ptr lhs,
const tendril_cptr rhs 
)
friend
template<typename T >
void operator>> ( const tendril_cptr rhs,
T &  val 
)
friend
void operator>> ( const tendril_ptr rhs,
boost::python::object &  obj 
)
friend
void operator>> ( const tendril_cptr rhs,
boost::python::object &  obj 
)
friend

Member Data Documentation

Converter* ecto::tendril::converter
private
std::string ecto::tendril::doc_
private
const empty_t ecto::tendril::empty
static
std::bitset<N_FLAGS> ecto::tendril::flags_
private
boost::any ecto::tendril::holder_
private
job_signal_t ecto::tendril::jobs_
private
const char* ecto::tendril::type_ID_
private

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