X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Fsrc%2Fsynfig%2Fmodule.h;h=19f0c3c55d9ffaec1ad4fc0b5537a370064fae1e;hb=3d1c302c92906f495ffddd9bf295b20083fec3df;hp=26638cd6866b2ff694a160410c4a0d91ecce4d56;hpb=a095981e18cc37a8ecc7cd237cc22b9c10329264;p=synfig.git diff --git a/synfig-core/src/synfig/module.h b/synfig-core/src/synfig/module.h index 26638cd..19f0c3c 100644 --- a/synfig-core/src/synfig/module.h +++ b/synfig-core/src/synfig/module.h @@ -1,6 +1,6 @@ /* === S Y N F I G ========================================================= */ /*! \file synfig/module.h -** \brief writeme +** \brief Base class for all libraries modules ** ** $Id$ ** @@ -91,6 +91,12 @@ #define BEGIN_LAYERS { //! DEPRECATED - use #INCLUDE_LAYER(class) +// Really? ^^ The INCLUDE_LAYER(class) macro is defined in a cpp file and +// is undefined a few lines later. In fact the INCLUDE_LAYER is only +// used in the layer.cpp file and the functionality is the same. Even +// more, I think that we should use register_in_book call because maybe +// the Layer class would like to do something else when register the class. +//! Register a Layer class in the book of layers #define LAYER(class) \ synfig::Layer::register_in_book( \ synfig::Layer::BookEntry(class::create, \ @@ -100,6 +106,7 @@ class::cvs_id__, \ class::version__)); +//! Register a Layer class in the book of layers with an alias #define LAYER_ALIAS(class,alias) \ synfig::Layer::register_in_book( \ synfig::Layer::BookEntry(class::create, \ @@ -115,10 +122,13 @@ //! Marks the start of the targets in the module's inventory #define BEGIN_TARGETS { -#define TARGET(x) \ - synfig::Target::book()[synfig::String(x::name__)]= \ - std::pair \ - (x::create,synfig::String(x::ext__)); \ +#define TARGET(x) \ + synfig::Target::book()[synfig::String(x::name__)].factory = \ + reinterpret_cast (x::create); \ + synfig::Target::book()[synfig::String(x::name__)].filename = \ + synfig::String(x::ext__); \ + synfig::Target::book()[synfig::String(x::name__)].target_param = \ + synfig::TargetParam(); \ synfig::Target::ext_book()[synfig::String(x::ext__)]=x::name__; #define TARGET_EXT(x,y) synfig::Target::ext_book()[synfig::String(y)]=x::name__; @@ -129,8 +139,10 @@ //! Marks the start of the importers in the module's inventory #define BEGIN_IMPORTERS { +//! Register an Importer class in the book of importers by the default extension #define IMPORTER(x) synfig::Importer::book()[synfig::String(x::ext__)]=x::create; +//!Register an Importer class in the book of importers by one file extension string #define IMPORTER_EXT(x,y) synfig::Importer::book()[synfig::String(y)]=x::create; //! Marks the end of the importers in the module's inventory @@ -139,6 +151,7 @@ //! Marks the start of the valuenodes in the module's inventory #define BEGIN_VALUENODES { synfig::LinkableValueNode::Book &book(synfig::LinkableValueNode::book()); +//! Registers a valuenode that is defined in the module's inventory #define VALUENODE(class,name,local,version) \ book[name].factory=reinterpret_cast(&class::create); \ book[name].check_type=&class::check_type; \ @@ -173,21 +186,30 @@ public: typedef etl::handle ConstHandle; public: - typedef Module*(*constructor_type)(ProgressCallback *); + //! Type that represents a pointer to a Module's constructor by name. + //! As a pointer to the member, it represents a constructor of the module. + typedef Module* (*constructor_type)(ProgressCallback *); typedef std::map Book; private: static Book* book_; public: static Book& book(); + //! Inits the book of importers and add the paths to search for the + //! ltdl library utilities. static bool subsys_init(const String &prefix); static bool subsys_stop(); + //! Register not optional modules static void register_default_modules(ProgressCallback *cb=NULL); + //! Register Module by handle static void Register(Handle mod); + //! Register Module by name static bool Register(const String &module_name, ProgressCallback *cb=NULL); + //!Register Module by instance pointer static inline void Register(Module *mod) { Register(Handle(mod)); } + //! Virtual Modules properties wrappers. Must be defined in the modules classes virtual const char * Name() { return " "; } virtual const char * Desc() { return " "; } virtual const char * Author() { return " "; }