|
|
|
@ -49,7 +49,7 @@ class EXPORT ObjectBase
|
|
|
|
|
bool isError() const {return err;} |
|
|
|
|
// Pure virtual api
|
|
|
|
|
virtual ~ObjectBase(){} |
|
|
|
|
virtual ObjectBase* Copy() const=0; |
|
|
|
|
virtual const ObjectBase* Copy() const=0; |
|
|
|
|
virtual bool Print() const=0; |
|
|
|
|
virtual std::string Type() const=0; |
|
|
|
|
|
|
|
|
@ -167,7 +167,7 @@ class EXPORT ObjectError: public ObjectBase
|
|
|
|
|
const std::string& Function() const {return function;} |
|
|
|
|
const std::string& Reason() const {return reason;} |
|
|
|
|
// Pure virtual overrides
|
|
|
|
|
ObjectBase* Copy() const override {return new ObjectError(function,reason);} |
|
|
|
|
const ObjectBase* Copy() const override {return new ObjectError(function,reason);} |
|
|
|
|
bool Print() const override |
|
|
|
|
{ |
|
|
|
|
COUT(NORMAL)<<std::endl<<"Object type: "<<Type()<<std::endl; |
|
|
|
@ -193,7 +193,7 @@ public:
|
|
|
|
|
ObjectSimple(const T* t):val(*t) {} |
|
|
|
|
~ObjectSimple() {} |
|
|
|
|
// Pure virtual overrides
|
|
|
|
|
ObjectBase* Copy() const override {return new ObjectSimple<T>(val);} |
|
|
|
|
const ObjectBase* Copy() const override {return new ObjectSimple<T>(val);} |
|
|
|
|
bool Print() const override |
|
|
|
|
{ |
|
|
|
|
COUT(NORMAL)<<std::endl<<"Object type: "<<Type()<<std::endl; |
|
|
|
@ -236,15 +236,15 @@ class EXPORT ObjectPair: public ObjectBase
|
|
|
|
|
{ |
|
|
|
|
private: |
|
|
|
|
std::string name; |
|
|
|
|
std::shared_ptr<ObjectBase> val; |
|
|
|
|
std::shared_ptr<const ObjectBase> val; |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
ObjectPair() {} |
|
|
|
|
ObjectPair(const std::string& n, ObjectBase* v):name(n) {val.reset(v);} |
|
|
|
|
ObjectPair(const std::string* n, ObjectBase* v):name(*n) {val.reset(v);} |
|
|
|
|
ObjectPair(const std::string& n, const ObjectBase* v):name(n) {val.reset(v);} |
|
|
|
|
ObjectPair(const std::string* n, const ObjectBase* v):name(*n) {val.reset(v);} |
|
|
|
|
~ObjectPair() {} |
|
|
|
|
// Pure virtual overrides
|
|
|
|
|
ObjectBase* Copy() const override |
|
|
|
|
const ObjectBase* Copy() const override |
|
|
|
|
{ |
|
|
|
|
auto ret=new ObjectPair; |
|
|
|
|
ret->name=name; ret->val=val; |
|
|
|
@ -265,7 +265,7 @@ public:
|
|
|
|
|
|
|
|
|
|
// Own functions
|
|
|
|
|
bool Exist() const {return nullptr!=val.get();} |
|
|
|
|
ObjectBase* Get(const std::string& gname) const |
|
|
|
|
const ObjectBase* Get(const std::string& gname) const |
|
|
|
|
{ |
|
|
|
|
if(gname==name) return val->Copy(); |
|
|
|
|
else return new ObjectError("ObjectPair Get","pair has name "+name+" not "+gname); |
|
|
|
@ -277,7 +277,7 @@ public:
|
|
|
|
|
else return nullptr; |
|
|
|
|
} |
|
|
|
|
std::string Name() const {return name;} |
|
|
|
|
void SetPair(const std::string& n, ObjectBase* v) {if(!Exist()) {name=n; val.reset(v);}} |
|
|
|
|
void SetPair(const std::string& n, const ObjectBase* v) {if(!Exist()) {name=n; val.reset(v);}} |
|
|
|
|
const ObjectBase* Value() const {return val.get();} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -285,16 +285,16 @@ public:
|
|
|
|
|
class EXPORT ObjectList: public ObjectBase |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
typedef std::deque<ObjectBase*> ListValues; |
|
|
|
|
typedef std::deque<const ObjectBase*> ListValues; |
|
|
|
|
private: |
|
|
|
|
std::shared_ptr<ListValues> vals; |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
ObjectList() {vals.reset(new ListValues, [](ListValues* p){for(auto& i: *p) delete i; delete p;});} |
|
|
|
|
ObjectList(ObjectBase* o) {vals.reset(new ListValues, [](ListValues* p){for(auto& i: *p) delete i; delete p;}); PushBack(o);} |
|
|
|
|
ObjectList(const ObjectBase* o) {vals.reset(new ListValues, [](ListValues* p){for(auto& i: *p) delete i; delete p;}); PushBack(o);} |
|
|
|
|
~ObjectList() {} |
|
|
|
|
// Pure virtual overrides
|
|
|
|
|
ObjectBase* Copy() const override |
|
|
|
|
const ObjectBase* Copy() const override |
|
|
|
|
{ |
|
|
|
|
auto ret=new ObjectList; |
|
|
|
|
ret->vals=vals; |
|
|
|
@ -321,7 +321,7 @@ public:
|
|
|
|
|
// Own functions
|
|
|
|
|
const ObjectBase* At(ListValues::size_type i) const {return (*vals)[i];} |
|
|
|
|
bool Exist() const {return 0!=vals->size();} |
|
|
|
|
ObjectBase* Get(const std::string& gname) const |
|
|
|
|
const ObjectBase* Get(const std::string& gname) const |
|
|
|
|
{ |
|
|
|
|
const ObjectBase* p=Find(gname); |
|
|
|
|
return (nullptr==p)?new ObjectError("ObjectList Get","name "+gname+" not found in list"):p->Copy(); |
|
|
|
@ -342,11 +342,11 @@ public:
|
|
|
|
|
return nullptr; |
|
|
|
|
} |
|
|
|
|
ListValues::size_type Size() const {return vals->size();} |
|
|
|
|
ObjectList* PushBack(ObjectBase* p) {vals->push_back(p); return this;} |
|
|
|
|
ObjectList* PushFront(ObjectBase* p) {vals->push_front(p); return this;} |
|
|
|
|
ObjectList* PushBack(const ObjectBase* p) {vals->push_back(p); return this;} |
|
|
|
|
ObjectList* PushFront(const ObjectBase* p) {vals->push_front(p); return this;} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
typedef ObjectBase* (*Func)(const ObjectList*); |
|
|
|
|
typedef const ObjectBase* (*Func)(const ObjectList*); |
|
|
|
|
typedef int (*ModuleInitFunc)(const void*); |
|
|
|
|
|
|
|
|
|
extern "C" { |
|
|
|
@ -355,7 +355,7 @@ EXPORT int LoadModule(const std::string& name, const void* p, const std::string&
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<class T> |
|
|
|
|
ObjectBase* Get(const ObjectList* input) |
|
|
|
|
const ObjectBase* Get(const ObjectList* input) |
|
|
|
|
{ |
|
|
|
|
if(input->Size()!=2) return new ObjectError("GET","incorrect number of arguments"); |
|
|
|
|
OBType<T> ob(input->At(0)); |
|
|
|
|