00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_IO_ENTITY_IO_PLUGIN_H
00020 #define OST_IO_ENTITY_IO_PLUGIN_H
00021
00022 #include <boost/shared_ptr.hpp>
00023 #include <boost/filesystem/operations.hpp>
00024
00025
00026 #include <ost/io/module_config.hh>
00027 #include <ost/io/io_utils.hh>
00028 #include <ost/mol/mol.hh>
00029
00030 namespace ost { namespace io {
00031
00033 class DLLEXPORT_OST_IO EntityIOHandler {
00034 public:
00035 virtual ~EntityIOHandler() {}
00036
00037
00038
00039
00040
00041 virtual void Import(mol::EntityHandle& ent,
00042 const boost::filesystem::path& loc)=0;
00043
00044 virtual void Export(const mol::EntityView& ent,
00045 const boost::filesystem::path& loc) const = 0;
00046
00047 virtual void Import(mol::EntityHandle& ent,
00048 std::istream& stream)=0;
00049
00050 virtual void Export(const mol::EntityView& ent,
00051 std::ostream& stream) const=0;
00052 virtual bool RequiresBuilder() const=0;
00053 };
00054
00055 typedef boost::shared_ptr<EntityIOHandler> EntityIOHandlerP;
00056
00057
00059 class DLLEXPORT_OST_IO EntityIOHandlerFactoryBase {
00060 public:
00061 virtual ~EntityIOHandlerFactoryBase() {}
00062 virtual bool ProvidesImport(const boost::filesystem::path& loc, const String& type) const = 0;
00063 virtual bool ProvidesExport(const boost::filesystem::path& loc, const String& type) const = 0;
00064 virtual EntityIOHandlerP Create() const = 0;
00065 virtual String GetFormatName() const =0;
00066 virtual String GetFormatDescription() const =0;
00067 };
00068
00069 typedef boost::shared_ptr<EntityIOHandlerFactoryBase> EntityIOHandlerFactoryBaseP;
00070
00071 template <class HANDLER>
00072 class EntityIOHandlerFactory: public EntityIOHandlerFactoryBase
00073 {
00074 virtual bool ProvidesImport(const boost::filesystem::path& loc, const String& type) const {
00075 return HANDLER::ProvidesImport(loc,type);
00076 }
00077
00078 virtual bool ProvidesExport(const boost::filesystem::path& loc, const String& type) const {
00079 return HANDLER::ProvidesExport(loc,type);
00080 }
00081
00082 virtual String GetFormatName() const {
00083 return HANDLER::GetFormatName();
00084 }
00085
00086 virtual String GetFormatDescription() const {
00087 return HANDLER::GetFormatDescription();
00088 }
00089
00090 virtual EntityIOHandlerP Create() const {
00091 return EntityIOHandlerP(new HANDLER);
00092 }
00093 };
00094
00095
00096
00097 }}
00098
00099 #endif