30 #include <boost/shared_ptr.hpp> 31 #include <boost/function/function1.hpp> 32 #ifndef BOOST_SIGNALS2_MAX_ARGS 33 #define BOOST_SIGNALS2_MAX_ARGS 3 35 #include <boost/signals2.hpp> 36 #include <boost/any.hpp> 119 template <
typename T>
124 flags_[DEFAULT_VALUE]=
true;
138 const char*
type_id()
const {
return type_ID_;}
154 set_doc(
const std::string& doc_str);
165 flags_[DEFAULT_VALUE] =
true;
169 void required(
bool b);
171 bool required()
const;
182 return unsafe_get<T>();
190 return unsafe_get<T>();
193 template <
typename T>
207 void operator<<(
const boost::python::object& obj);
219 return name_of<T>() == type_name();
228 same_type(
const tendril& rhs)
const;
231 compatible_type(
const tendril& rhs)
const;
234 enforce_compatible_type(
const tendril& rhs)
const;
244 BOOST_THROW_EXCEPTION(except::TypeMismatch()
245 << except::from_typename(type_name())
246 << except::to_typename(name_of<T>()));
251 user_supplied()
const;
253 void user_supplied(
bool v);
266 os <<
"ecto::tendril::none";
return os;
273 typedef typename boost::function1<void, T>
CbT;
286 template<
typename Signature>
287 boost::signals2::connection
connect(Signature slot)
289 return jobs_.connect(slot);
303 connect(CallerT(cb));
325 return *boost::unsafe_any_cast<
const T>(&holder_);
331 return *boost::unsafe_any_cast<T>(&holder_);
336 virtual void operator()(
tendril& t,
const boost::python::object& o)
const = 0;
337 virtual void operator()(boost::python::object& o,
const tendril& t)
const = 0;
340 template <
typename T,
typename _=
void>
348 boost::python::extract<T> get_T(obj);
352 BOOST_THROW_EXCEPTION(except::FailedFromPythonConversion()
361 const T& v = t.
get<T>();
362 boost::python::object obj(v);
367 template <
typename _>
381 o = boost::python::object();
385 template <
typename T>
389 type_ID_ = name_of<T>().c_str();
391 registry::tendril::add<T>(*this);
393 void copy_holder(
const tendril& rhs);
406 template <
typename T>
414 (*converter)(obj, *
this);
437 BOOST_THROW_EXCEPTION(except::NullTendril()
438 << except::from_typename(
"(null)")
439 << except::to_typename(name_of<T>()));
446 operator>>(
const tendril_ptr& rhs, boost::python::object& obj);
451 operator>>(
const tendril_cptr& rhs, boost::python::object& obj);
458 BOOST_THROW_EXCEPTION(except::NullTendril()
459 << except::to_typename(
"(null)")
460 << except::from_typename(name_of<T>()));
471 template <
typename Archive>
472 void serialize(Archive& ar,
const unsigned int);
476 template <
typename T>
481 template <
typename T>
489 template <
typename T,
typename _>
493 template <
typename _>
boost::function1< void, T > CbT
Definition: tendril.hpp:273
void operator>>(tendril &rhs) const
Definition: tendril.hpp:427
std::string type_name() const
This is an unmangled type name for what ever tendril is holding.
CbT cb
Definition: tendril.hpp:283
Definition: tendril.hpp:341
boost::function1< void, tendril & > TendrilJob
Definition: tendril.hpp:87
std::vector< std::string > type_names()
tendril & set_callback(typename boost::function1< void, T > cb)
Definition: tendril.hpp:299
Definition: tendril.hpp:93
void set_holder(const T &t=T())
Definition: tendril.hpp:386
const char * type_ID_
Definition: tendril.hpp:396
const none & operator=(const none &) const
Definition: tendril.hpp:262
tendril(const T &t, const std::string &doc)
A convenience constructor for creating a tendril that holds the given type.
Definition: tendril.hpp:120
void operator()(tendril &t, const boost::python::object &obj) const
Definition: tendril.hpp:372
void set_default_val(const T &val=T())
This sets the default value of the tendril. This is a.
Definition: tendril.hpp:162
boost::shared_ptr< const tendril > tendril_cptr
Definition: forward.hpp:36
#define ECTO_EXPORT
Definition: util.hpp:49
bool is_type() const
runtime check if the tendril is of the given type.
Definition: tendril.hpp:217
A none type for tendril when the tendril is uninitialized.
Definition: tendril.hpp:260
Definition: parameters.hpp:11
Definition: tendril.hpp:94
const char * type_id() const
Definition: tendril.hpp:138
Definition: tendril.hpp:98
bool add(const ecto::tendril &t)
Definition: tendril.hpp:65
std::bitset< N_FLAGS > flags_
Definition: tendril.hpp:398
void operator()(tendril &t, const boost::python::object &obj) const
Definition: tendril.hpp:345
void operator>>(const tendril_ptr &rhs) const
Definition: tendril.hpp:417
tendril_ptr make_tendril()
Definition: tendril.hpp:482
void operator>>(boost::python::object &obj) const
Definition: tendril.hpp:412
static ConverterImpl< none, _ > instance
Definition: tendril.hpp:370
std::string repr(const boost::python::object &obj)
Converter * converter
Definition: tendril.hpp:401
Definition: tendril.hpp:271
#define ECTO_SCOPED_CALLPYTHON()
Definition: python.hpp:88
friend void operator>>(const tendril_cptr &rhs, T &val)
Definition: tendril.hpp:434
T & unsafe_get()
Definition: tendril.hpp:329
void operator>>(tendril_ptr &rhs) const
Definition: tendril.hpp:422
none & operator=(const none &)
Definition: tendril.hpp:261
const T & unsafe_get() const
Definition: tendril.hpp:323
void enforce_type() const
runtime check if the tendril is of the given type, this will throw.
Definition: tendril.hpp:241
Definition: tendril.hpp:91
boost::signals2::connection connect(Signature slot)
Definition: tendril.hpp:287
friend std::ostream & operator<<(std::ostream &os, const none &)
Definition: tendril.hpp:264
boost::shared_ptr< tendril > tendril_ptr
Definition: forward.hpp:34
Caller(CbT cb)
Definition: tendril.hpp:274
std::string doc_
Definition: tendril.hpp:397
job_signal_t jobs_
Definition: tendril.hpp:400
Definition: tendril.hpp:58
void operator()(boost::python::object &o, const tendril &t) const
Definition: tendril.hpp:378
A tendril is the slender, winding organ of the ecto::cell that gives it its awesome type erasure and ...
Definition: tendril.hpp:84
boost::any holder_
Definition: tendril.hpp:395
Definition: tendril.hpp:368
boost::signals2::signal< void(tendril &)> job_signal_t
Definition: tendril.hpp:399
E const & operator<<(E const &x, error_info< ::ecto::except::detail::wrap< Tag >, T > const &v)
void operator()(tendril &t)
Definition: tendril.hpp:279
const T & get() const
Definition: tendril.hpp:179
static const empty_t empty
Definition: tendril.hpp:99
void operator>>(T &val) const
Definition: tendril.hpp:407
void operator()(boost::python::object &o, const tendril &t) const
Definition: tendril.hpp:358
static ConverterImpl< T, _ > instance
Definition: tendril.hpp:343
friend bool operator==(const none &, const none &)
Definition: tendril.hpp:263
Definition: tendril.hpp:334
entry(const ecto::tendril &t)
Definition: tendril.hpp:59
Definition: tendril.hpp:92