Source

cy-cxxfwk / lib / lib.cxx

Sebastien Binet feb1a80 










Sebastien Binet 146ca48 






Sebastien Binet feb1a80 





Sebastien Binet 146ca48 
Sebastien Binet feb1a80 












Sebastien Binet 146ca48 
Sebastien Binet feb1a80 






























Sebastien Binet 146ca48 
Sebastien Binet feb1a80 







#include "Python.h"
#include "lib.h"

#include <iostream>

IAlg::~IAlg()
{}

IAlg::IAlg()
{}

void
IAlg::run()
{
  std::cout << ":: IAlg::run()...\n";
  this->run_impl();
}

class Alg : public IAlg
{
public:
  Alg();
  ~Alg();

  void run_impl();
};

Alg::Alg()
{
  std::cout << ":: Alg::Alg()...\n";
}

Alg::~Alg()
{
  std::cout << ":: Alg::~Alg()...\n";
}

void
Alg::run_impl()
{
  std::cout << ":: Alg::run()...\n";
}

IAlg *create_alg(int algid)
{
  switch (algid) {
  case 0:
    return new Alg;
  case 1:
    return 0;
  default:
    return 0;
  }

  return 0;
}

CyAlgBase::CyAlgBase(PyObject *obj, RunFct fct) :
  obj(obj),
  fct(fct)
{
  Py_XINCREF(this->obj);
}

CyAlgBase::~CyAlgBase()
{
  Py_XDECREF(this->obj);
}

void
CyAlgBase::run_impl()
{
  std::cout << "::CyAlgBase::run()...\n";
  if (this->obj && this->fct) {
    return this->fct(this->obj);
  }
  std::cerr << "** invalid cy-state: obj [" << this->obj << "] fct: ["
            << this->fct << "]\n";
  return;
}