00001 00010 #ifndef BS_PY_DATA_STORAGE_INTERFACE_H_ 00011 #define BS_PY_DATA_STORAGE_INTERFACE_H_ 00012 00013 #include "data_storage_interface.h" 00014 00015 namespace blue_sky 00016 { 00017 namespace python 00018 { 00019 00020 00021 class BS_API_PLUGIN py_data_storage : public py_objbase 00022 { 00023 public: 00024 00025 typedef py_objbase base_t; 00026 00027 public: 00028 00029 py_data_storage (PyObject *self); 00030 virtual ~py_data_storage (); 00031 00032 void save (const std::string &name, const std::string &value); 00033 void save_default (const std::string &name, const std::string &value); 00034 00035 private: 00036 00037 PyObject *self_; 00038 }; 00039 00040 class BS_API_PLUGIN py_data_serializer : public py_objbase, public data_serializer 00041 { 00042 public: 00043 00044 typedef data_serializer wrapped_t; 00045 typedef py_objbase base_t; 00046 00047 public: 00048 00049 py_data_serializer (PyObject *self) 00050 : base_t (this) 00051 , self_ (self) 00052 { 00053 00054 } 00055 00056 void save (const sp_storage_t &storage, const sp_obj &obj); 00057 void save_impl (py_data_storage storage, py_objbase obj); 00058 00059 private: 00060 00061 PyObject *self_; 00062 }; 00063 00064 00065 class BS_API_PLUGIN py_data_storage_interface : public py_objbase 00066 { 00067 public: 00068 00069 typedef data_storage_interface wrapped_t; 00070 typedef py_objbase base_t; 00071 00072 public: 00073 00074 py_data_storage_interface () 00075 : base_t (wrapped_t::bs_type ()) 00076 { 00077 00078 } 00079 00080 00081 void save (const py_objbase &obj); 00082 00083 // see py_data_serializer::save for explanation 00084 //void register_serializer (py_data_serializer *serializer); 00085 00086 void set_storage (const py_data_storage &storage); 00087 }; 00088 00089 bool 00090 data_storage_proxy_register_type (const blue_sky::plugin_descriptor &pd); 00091 00092 void 00093 py_export_data_storage_interface (); 00094 00095 } // namespace python 00096 } // namespace blue_sky 00097 00098 00099 00100 #endif // #ifndef BS_PY_DATA_STORAGE_INTERFACE_H_