Lifecycle of CellsΒΆ

This tutorial is more of a demo of what happens during the lifetime of a cell. Please read the reference for a cell for a more detailed reference.

This cell will chirp at every point in its life.

Download: srcs/LifeCycle.cpp

#include <ecto/ecto.hpp>
#include <iostream>

using ecto::tendrils;
namespace lifecycle
{
  struct LifeCycle
  {
    static void
    declare_params(tendrils&)
    {
      std::cout << "static " << ecto::name_of<LifeCycle>() << "::declare_params" << std::endl;
    }

    static void
    declare_io(const tendrils&, tendrils&, tendrils&)
    {
      std::cout << "static " << ecto::name_of<LifeCycle>() << "::declare_io" << std::endl;

    }

    LifeCycle()
    {
      std::cout << ecto::name_of<LifeCycle>() << "::LifeCycle()  this=" << this << std::endl;
    }

    ~LifeCycle()
    {
      std::cout << ecto::name_of<LifeCycle>() << "::~LifeCycle()  this=" << this << std::endl;
    }

    void
    configure(const tendrils&, const tendrils&, const tendrils&)
    {
      std::cout << ecto::name_of<LifeCycle>() << "::configure  this=" << this << std::endl;
    }

    int
    process(const tendrils&, const tendrils&)
    {
      std::cout << ecto::name_of<LifeCycle>() << "::process  this=" << this << std::endl;
      return ecto::OK;
    }
  };
}

ECTO_DEFINE_MODULE(ecto_lifecycle)
{ }

ECTO_CELL(ecto_lifecycle, lifecycle::LifeCycle, "LifeCycle", "Chirps on each stage of life.");

Also here is a python script that will trigger the lifecycle exploration.

Download: srcs/lifecycler.py

#!/usr/bin/env python
import ecto

def doit():
    print "**** pre import of ecto_lifecycle ********"
    import ecto.ecto_lifecycle as ecto_lifecycle
    print "**** post import of ecto_lifecycle *******"

    print "**** pre allocation of LifeCycle cell ********"
    lifecycle = ecto_lifecycle.LifeCycle() #allocate a cell
    print "**** post allocation of LifeCycle cell *******"

    plasm = ecto.Plasm()
    print "**** pre insert ********"
    plasm.insert(lifecycle)
    print "**** post insert *******"

    print "**** pre execute ********"
    sched = ecto.Scheduler(plasm)
    sched.execute(1)
    print "**** post execute *******"

print "**** pre scope ********"
doit()
print "**** post scope *******"

Lets run it:

No module named PySide.QtCore
**** pre scope ********
**** pre import of ecto_lifecycle ********
static lifecycle::LifeCycle::declare_params
static lifecycle::LifeCycle::declare_io
**** post import of ecto_lifecycle *******
**** pre allocation of LifeCycle cell ********
static lifecycle::LifeCycle::declare_params
static lifecycle::LifeCycle::declare_io
**** post allocation of LifeCycle cell *******
**** pre insert ********
**** post insert *******
**** pre execute ********
lifecycle::LifeCycle::LifeCycle()  this=0x1ad65d0
lifecycle::LifeCycle::configure  this=0x1ad65d0
lifecycle::LifeCycle::process  this=0x1ad65d0
**** post execute *******
lifecycle::LifeCycle::~LifeCycle()  this=0x1ad65d0
**** post scope *******