diff options
Diffstat (limited to 'meowpp/oo/ObjBase.h')
-rw-r--r-- | meowpp/oo/ObjBase.h | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/meowpp/oo/ObjBase.h b/meowpp/oo/ObjBase.h index 3aa99d7..974fdf1 100644 --- a/meowpp/oo/ObjBase.h +++ b/meowpp/oo/ObjBase.h @@ -7,33 +7,37 @@ #include <string> namespace meow{ - class ObjBase{ - protected: - ObjBase(){ } - public: - virtual ~ObjBase(){ } - // - virtual bool read (FILE* f, bool bin, unsigned int fg){ return false; } - virtual bool write(FILE* f, bool bin, unsigned int fg){ return false; } - // - virtual ObjBase* create() const{ return NULL; } - // - virtual char const* ctype() const{ - static char const* ptr = typeid(*this).name(); - return ptr; - } - virtual std::string type() const{ - return std::string(ctype()); - } - // - static char const* ctypeBase(){ - static char const* ptr = typeid(ObjBase).name(); - return ptr; - } - static std::string typeBase(){ - return std::string(ctypeBase()); - } - }; + +/*! + * @brief 一切物件的Base, 並要求每個物件都要有read, write, create, ... 等功能 + * + * @author cathook + */ +class ObjBase { +protected: + ObjBase(){ } +public: + virtual ~ObjBase(){ } + // + virtual bool write(FILE* f,bool bin,unsigned int fg) const { return false; } + virtual bool read(FILE* f,bool bin,unsigned int fg) { return false; } + // + virtual ObjBase* create() const { return NULL; } + virtual ObjBase* copyFrom(ObjBase const* b) { (*this) = (*b); return this; } + // + virtual char const* ctype() const{ + static char const* ptr = typeid(*this).name(); + return ptr; + } + virtual std::string type() const{ return std::string(ctype()); } + // + static char const* ctypeBase(){ + static char const* ptr = typeid(ObjBase).name(); + return ptr; + } + static std::string typeBase(){ return std::string(ctypeBase()); } +}; + } #endif // oo_ObjBase_H__ |