40 #include <boost/noncopyable.hpp> 41 #include <boost/optional.hpp> 42 #include <boost/shared_ptr.hpp> 60 #define ECTO_RETURN_VALUES \ 61 (OK)(QUIT)(DO_OVER)(BREAK)(CONTINUE)(UNKNOWN) \ 95 typedef boost::shared_ptr<cell>
ptr;
103 void declare_params();
145 std::string
type()
const {
return dispatch_name(); }
152 {
return instance_name_.size() ? instance_name_ : dispatch_name(); }
155 void name(
const std::string& name)
156 { instance_name_ = name; }
160 {
return dispatch_short_doc(); }
164 { dispatch_short_doc(short_doc); }
174 std::string gen_doc(
const std::string& doc =
"A module...")
const;
176 void verify_params()
const;
177 void verify_inputs()
const;
186 return process_connected_inputs_only_;
189 process_connected_inputs_only_ = value;
204 virtual bool init() = 0;
208 virtual void dispatch_declare_params(
tendrils& t) = 0;
213 virtual void dispatch_configure(
const tendrils& params,
217 virtual void dispatch_activate() = 0;
219 virtual void dispatch_deactivate() = 0;
224 virtual void dispatch_start() = 0;
225 virtual void dispatch_stop() = 0;
227 virtual std::string dispatch_name()
const = 0;
229 virtual ptr dispatch_clone()
const = 0;
232 {
return std::string(); }
255 typedef char (&no)[2];
260 static yes test_declare_params(__typeof__(&U::declare_params));
262 static no test_declare_params(...);
265 declare_params =
sizeof(test_declare_params<T> (0)) ==
sizeof(yes)
269 static yes test_declare_io(__typeof__(&U::declare_io));
271 static no test_declare_io(...);
274 declare_io =
sizeof(test_declare_io<T> (0)) ==
sizeof(yes)
278 static yes test_configure(__typeof__(&U::configure));
280 static no test_configure(...);
283 configure =
sizeof(test_configure<T> (0)) ==
sizeof(yes)
287 static yes test_activate(__typeof__(&U::activate));
289 static no test_activate(...);
292 activate =
sizeof(test_activate<T> (0)) ==
sizeof(yes)
296 static yes test_deactivate(__typeof__(&U::deactivate));
298 static no test_deactivate(...);
301 deactivate =
sizeof(test_deactivate<T> (0)) ==
sizeof(yes)
305 static yes test_process(__typeof__(&U::process));
307 static no test_process(...);
310 process =
sizeof(test_process<T> (0)) ==
sizeof(yes)
314 static yes test_start(__typeof__(&U::start));
316 static no test_start(...);
319 start =
sizeof(test_start<T> (0)) ==
sizeof(yes)
323 static yes test_stop(__typeof__(&U::stop));
325 static no test_stop(...);
328 stop =
sizeof(test_stop<T> (0)) ==
sizeof(yes)
338 typedef boost::shared_ptr<cell_<Impl> >
ptr;
345 dispatch_deactivate();
347 template <
int I>
struct int_ { };
357 { Impl::declare_params(params); }
360 { declare_params(params, has_declare_params()); }
363 { declare_params(params); }
373 { Impl::declare_io(params, inputs, outputs); }
379 { declare_io(params, inputs, outputs, has_declare_io()); }
383 { declare_io(params, inputs, outputs); }
391 const tendrils& outputs, implemented)
392 { impl_->configure(params,inputs,outputs); }
402 {
if(impl_) impl_->activate(); }
411 {
if(impl_) impl_->deactivate(); }
422 {
return ReturnCode(impl_->process(inputs, outputs)); }
430 void start(implemented) { impl_->start(); }
436 void stop(implemented) { impl_->stop(); }
456 ECTO_ASSERT(impl_,
"impl is null, call configure first");
460 ECTO_ASSERT(impl_,
"impl is null, call configure first");
476 template<
typename Impl>
482 impl_.reset(
new Impl);
486 parameters.realize_potential(i);
487 inputs.realize_potential(i);
488 outputs.realize_potential(i);
490 return static_cast<bool>(impl_);
491 }
catch (
const std::exception& e) {
493 BOOST_THROW_EXCEPTION(except::CellException()
494 << except::when(
"Construction")
495 << except::type(
name_of(
typeid(e)))
496 << except::cell_name(name())
497 << except::what(e.what()));
500 BOOST_THROW_EXCEPTION(except::CellException()
501 << except::when(
"Construction")
502 << except::what(
"(unknown exception)")
503 << except::cell_name(name()));
507 template<
typename Impl>
510 template<
typename Impl>
513 template<
typename Impl>
516 template<
typename Impl>
#define ECTO_TRACE_EXCEPTION(E)
Definition: log.hpp:74
std::string type() const
Return the type of the child class.
Definition: cell.hpp:145
static void declare_params(tendrils ¶ms, implemented)
Definition: cell.hpp:356
int_< 1 > implemented
Definition: cell.hpp:349
void dispatch_activate()
Definition: cell.hpp:404
void stop(not_implemented)
Definition: cell.hpp:435
Definition: strand.hpp:38
Definition: traits.hpp:36
bool process_connected_inputs_only_
Definition: cell.hpp:242
void dispatch_declare_params(tendrils ¶ms)
Definition: cell.hpp:362
cell_()
Definition: cell.hpp:340
#define ECTO_LOG_DEBUG(fmg, args)
Definition: log.hpp:66
ReturnCode dispatch_process(const tendrils &inputs, const tendrils &outputs)
Definition: cell.hpp:424
boost::shared_ptr< cell > ptr
A convenience pointer typedef.
Definition: cell.hpp:95
std::string instance_name_
Definition: cell.hpp:239
Helper class for determining if client modules have function implementations or not.
Definition: cell.hpp:252
static void declare_io(const tendrils ¶ms, tendrils &inputs, tendrils &outputs)
Definition: cell.hpp:377
void dispatch_stop()
Definition: cell.hpp:437
std::string dispatch_short_doc() const
Definition: cell.hpp:440
void short_doc(const std::string &short_doc)
Set the short_doc_ of the instance.
Definition: cell.hpp:163
ecto::cell is the non virtual interface to the basic building block of ecto graphs. This interface should never be the parent of client cell, but may be used for polymorphic access to client cells.
Definition: cell.hpp:93
static void declare_io(const tendrils ¶ms, tendrils &inputs, tendrils &outputs, not_implemented)
Definition: cell.hpp:367
const Impl & impl() const
Definition: cell.hpp:459
int_< has_f< Impl >::declare_io > has_declare_io
Definition: cell.hpp:375
tendrils parameters
Parameters.
Definition: cell.hpp:195
ReturnCode process(const tendrils &, const tendrils &, not_implemented)
Definition: cell.hpp:417
void dispatch_deactivate()
Definition: cell.hpp:413
static const std::string CELL_TYPE_NAME
Definition: cell.hpp:453
#define ECTO_EXPORT
Definition: util.hpp:49
Unknown return code.
Definition: cell.hpp:57
Definition: parameters.hpp:11
void deactivate(not_implemented)
Definition: cell.hpp:408
void configure(const tendrils &, const tendrils &, const tendrils &, not_implemented)
Definition: cell.hpp:386
bool init()
Definition: cell.hpp:477
cell::ptr dispatch_clone() const
Definition: cell.hpp:443
static void declare_params(tendrils ¶ms)
Definition: cell.hpp:359
This modules' process call needs to be made again.
Definition: cell.hpp:54
const std::string & ReturnCodeToStr(int rval)
Stop execution in my scope, jump to top of scope.
Definition: cell.hpp:56
static std::string MODULE_NAME
The module that the cell is part of.
Definition: cell.hpp:452
boost::scoped_ptr< Impl > impl_
Definition: cell.hpp:465
boost::optional< strand > strand_
The strand that this cell should be executed in.
Definition: cell.hpp:202
void start(implemented)
Definition: cell.hpp:430
ReturnCode process(const tendrils &inputs, const tendrils &outputs, implemented)
Definition: cell.hpp:420
tendrils outputs
Outputs, outboxes, always have a valid value ( may be NULL )
Definition: cell.hpp:199
void init_strand(boost::mpl::true_)
Definition: cell.hpp:466
void dispatch_declare_io(const tendrils ¶ms, tendrils &inputs, tendrils &outputs)
Definition: cell.hpp:381
int_< has_f< Impl >::declare_params > has_declare_params
Definition: cell.hpp:352
void init_strand(boost::mpl::false_)
Definition: cell.hpp:468
bool configured_
Definition: cell.hpp:240
boost::shared_ptr< cell_< Impl > > ptr
Definition: cell.hpp:338
ECTO_EXPORT const std::string & name_of(const std::type_info &ti)
Get the unmangled type name of a type_info object.
static void declare_io(const tendrils ¶ms, tendrils &inputs, tendrils &outputs, implemented)
Definition: cell.hpp:371
void dispatch_configure(const tendrils ¶ms, const tendrils &inputs, const tendrils &outputs)
Definition: cell.hpp:394
void configure(const tendrils ¶ms, const tendrils &inputs, const tendrils &outputs, implemented)
Definition: cell.hpp:390
Everything A OK.
Definition: cell.hpp:52
char yes
Definition: cell.hpp:254
static std::string CELL_NAME
The python name for the cell.
Definition: cell.hpp:450
void name(const std::string &name)
Set the name of the instance.
Definition: cell.hpp:155
Explicit quit now.
Definition: cell.hpp:53
std::string short_doc() const
Set the short_doc_ of the instance.
Definition: cell.hpp:159
std::string name() const
Grab the name of the instance.
Definition: cell.hpp:151
Stop execution in my scope, jump to outer scope.
Definition: cell.hpp:55
ReturnCode
Return values for cell::process(). TODO: Should these live in cell? These are appropriate for non exc...
Definition: cell.hpp:50
tendrils inputs
Inputs, inboxes, always have a valid value ( may be NULL )
Definition: cell.hpp:197
void dispatch_start()
Definition: cell.hpp:431
void activate(implemented)
Definition: cell.hpp:401
bool activated_
Definition: cell.hpp:241
virtual void dispatch_short_doc(const std::string &)
Definition: cell.hpp:234
void start(not_implemented)
Definition: cell.hpp:429
virtual std::string dispatch_short_doc() const
Definition: cell.hpp:231
void deactivate(implemented)
Definition: cell.hpp:410
std::string dispatch_name() const
Definition: cell.hpp:439
static void declare_params(tendrils ¶ms, not_implemented)
Definition: cell.hpp:354
bool process_connected_inputs_only() const
Processing mode query - only connected tendrils or all. Typically used by the scheduler to arrange in...
Definition: cell.hpp:185
void dispatch_short_doc(const std::string &)
Definition: cell.hpp:441
void stop(implemented)
Definition: cell.hpp:436
void set_process_connected_inputs_only(const bool &value)
Definition: cell.hpp:188
int_< 0 > not_implemented
Definition: cell.hpp:348
static std::string SHORT_DOC
Definition: cell.hpp:448
~cell_()
Definition: cell.hpp:343
The tendrils are a collection for the ecto::tendril class, addressable by a string key...
Definition: tendrils.hpp:53
void activate(not_implemented)
Definition: cell.hpp:399
Impl & impl()
Grab a typed reference to the implementation of the cell.
Definition: cell.hpp:455
cell_<T> is for registering an arbitrary class with the the cell NVI. This adds a barrier between cli...
Definition: cell.hpp:336
#define ECTO_ASSERT(X, msg)
Definition: log.hpp:49