|
|
|
@ -36,15 +36,17 @@ inline std::string ToString<std::string>(std::string s) {return s;}
|
|
|
|
|
// Base class for all objects
|
|
|
|
|
class EXPORT ObjectBase |
|
|
|
|
{ |
|
|
|
|
protected: |
|
|
|
|
// No save by default
|
|
|
|
|
virtual const int8_t* Blob(size_t* size) const { *size=0; return 0; } |
|
|
|
|
virtual void DeallocBlob(const int8_t* ptr) const {}; |
|
|
|
|
public: |
|
|
|
|
protected: |
|
|
|
|
bool err; |
|
|
|
|
// No save by default
|
|
|
|
|
virtual const int8_t* Blob(size_t* size) const { *size=0; return 0; } |
|
|
|
|
virtual void DeallocBlob(const int8_t* ptr) const {}; |
|
|
|
|
ObjectBase():err(false) {} |
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
ObjectBase() = default; |
|
|
|
|
ObjectBase(const ObjectBase&) = delete; |
|
|
|
|
bool Save(const char* fname) const; |
|
|
|
|
bool isError() const {return err;} |
|
|
|
|
// Pure virtual api
|
|
|
|
|
virtual ~ObjectBase(){} |
|
|
|
|
virtual ObjectBase* Copy() const=0; |
|
|
|
@ -149,6 +151,30 @@ class OBTypeM<Func>
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Error class
|
|
|
|
|
class EXPORT ObjectError: public ObjectBase |
|
|
|
|
{ |
|
|
|
|
std::string function, reason; |
|
|
|
|
ObjectError() = delete; |
|
|
|
|
ObjectError(const ObjectError&) = delete; |
|
|
|
|
ObjectError(ObjectError&&) = delete; |
|
|
|
|
public: |
|
|
|
|
template<class F, class R> |
|
|
|
|
ObjectError(F f, R r):function(f),reason(r) {ObjectBase::err=true;} |
|
|
|
|
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);} |
|
|
|
|
bool Print() const override |
|
|
|
|
{ |
|
|
|
|
COUT(NORMAL)<<std::endl<<"Object type: "<<Type()<<std::endl; |
|
|
|
|
COUT(NORMAL)<<"Value: "<<Function()<<": "<<Reason()<<std::endl; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
std::string Type() const override {return "ERROR";} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Template for objects without specific constructor/destructor
|
|
|
|
|
template<class T> |
|
|
|
|
class EXPORT ObjectSimple: public ObjectBase |
|
|
|
|