最近下班后,闲得无聊,打算在Oracle的occi基础之上封装一个访问层,便于处理Oracle的读写操作.
打算主要参照Poco库和OTL以及DTL,利用模板和STL,tr1和log4cplus等库,实现跨平台的要求.
之后,在此基础上,参与Java的Hibernate和ibatis等技术,实现一个简单的对象持久化层.
最近先作了一些技术上的测试和设计工作吧
先贴一段C++工厂方法与反射的简单实现的实现代码
#include <iostream> #include <memory> using namespace std; class Object { public: virtual bool Save() = 0; virtual bool Get(...) { return false; } }; class A { public: A(){} A( int _value ) { this->value = _value; } int value; }; #define register_class(Class) \ class Class##Adpter : public Object, public Class \ { \ public: \ Class##Adpter(){} \ virtual bool Save() \ { \ return true; \ } \ static Object* createInstance() \ { \ return new Class##Adpter; \ } \ virtual bool Get( ... ) \ { \ return true; \ } \ public: \ Class object; \ }; typedef shared_ptr<Object> Shared_Object; template<class ObjType> class ObjectFactory { public: static Shared_Object CreateInstance() { return Shared_Object(new ObjType); } }; register_class(A) int main() { Shared_Object a = ObjectFactory<AAdpter>::CreateInstance(); cout << a->Save() << endl; cout << a->Get(1) << endl; }