#include #include #include "JLang/JClonable.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" namespace { using namespace JPP; struct __A__ : public JClonable<__A__> { virtual ~__A__() {} virtual int get() const = 0; }; struct __B__ : public JClonable<__A__, __B__> { static const int value = 1; virtual int get() const { return __B__::value; } }; struct __C__ : public JClonable<__A__, __C__> { static const int value = 2; virtual int get() const { return __C__::value; } }; } /** * \file * * Example program to test JLANG::JClonable class. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; int debug; try { JParser<> zap("Example program to test object cloning."); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } __B__ b; __C__ c; { __A__* p = b.clone(); ASSERT(p->get() == __B__::value); delete p; } { __A__* p = c.clone(); ASSERT(p->get() == __C__::value); delete p; } return 0; }