Merge branch 'genete_master'
authorCarlos Lopez <genetita@gmail.com>
Tue, 16 Feb 2010 15:34:03 +0000 (16:34 +0100)
committerCarlos Lopez <genetita@gmail.com>
Tue, 16 Feb 2010 15:34:03 +0000 (16:34 +0100)
synfig-core/src/synfig/layer.h
synfig-core/src/synfig/module.h
synfig-core/src/synfig/target.cpp
synfig-core/src/synfig/target.h
synfig-core/src/synfig/valuenode.h
synfig-core/src/tool/main.cpp

index f729c40..1e321b0 100644 (file)
@@ -162,7 +162,9 @@ class Layer : public Node
 
 public:
 
-       //! Type that represents a pointer to a layer's constructor
+       //! Type that represents a pointer to a Layer's constructor.
+       /*! As a pointer to the constructor, it represents a "factory" of layers.
+       */
        typedef Layer* (*Factory)();
 
        struct BookEntry
@@ -188,6 +190,13 @@ public:
                        version(version) { }
        };
 
+       //! Book of types of layers indexed by layer type name.
+       /*! While the sifz file is read, each time a new layer entry is found,
+       **  the factory constructor that the "factory" pointer member of the 
+       **  "BookEntry" struct points to, is called, and a new layer of that type
+       **  is created.
+       **  \sa Layer::Factory
+       */
        typedef std::map<String,BookEntry> Book;
 
        static void register_in_book(const BookEntry &);
index 26638cd..d064fe9 100644 (file)
 //! 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<synfig::Target::Factory,synfig::String>                                                                               \
-                       (x::create,synfig::String(x::ext__));                                                                                           \
+#define TARGET(x)                                                       \
+       synfig::Target::book()[synfig::String(x::name__)].factory =           \
+               reinterpret_cast<synfig::Target::Factory>       (x::create);              \
+  synfig::Target::book()[synfig::String(x::name__)].filename =          \
+    synfig::String(x::ext__);                                           \
        synfig::Target::ext_book()[synfig::String(x::ext__)]=x::name__;
 
 #define TARGET_EXT(x,y) synfig::Target::ext_book()[synfig::String(y)]=x::name__;
index 6a73822..47727be 100644 (file)
@@ -54,9 +54,15 @@ Target::subsys_init()
        default_gamma_=new synfig::Gamma(1.0/2.2);
        //default_gamma_->set_black_level(0.05); // Default to 5% black level.
 
-       book()["null"]=std::pair<synfig::Target::Factory,String>(Target_Null::create,"null");
+       // At least one target must be available.
+       book()["null"].factory =
+               reinterpret_cast<synfig::Target::Factory>(&Target_Null::create);
+  book()["null"].filename = "null";
        ext_book()["null"]="null";
-       book()["null-tile"]=std::pair<synfig::Target::Factory,String>(Target_Null_Tile::create,"null-tile");
+
+       book()["null-tile"].factory =
+    reinterpret_cast<synfig::Target::Factory>(&Target_Null_Tile::create);
+  book()["null-tile"].filename = "null-tile";
        ext_book()["null-tile"]="null-tile";
 
        return true;
@@ -109,5 +115,5 @@ Target::create(const String &name, const String &filename)
        if(!book().count(name))
                return handle<Target>();
 
-       return Target::Handle(book()[name].first(filename.c_str()));
+       return Target::Handle(book()[name].factory(filename.c_str()));
 }
index 9f6e304..f93cf87 100644 (file)
@@ -102,10 +102,20 @@ public:
        */
 
 public:
+       //! Type that represents a pointer to a Target's constructor.
+       /*! As a pointer to the constructor, it represents a "factory" of targets.
+       **  Receives the output filename (including path).
+       */
        typedef Target* (*Factory)(const char *filename);
-
-       //! A type for a map of targets, indexed by the name of the Target
-       typedef std::map<String,std::pair<Factory,String> > Book;
+       
+       struct BookEntry
+       {
+               Factory factory;
+               String filename; ///< Output filename including path
+       };
+
+       //! Book of types of targets indexed by the name of the Target.
+       typedef std::map<String,BookEntry> Book;
 
        typedef std::map<String,String> ExtBook;
 
index 38e5c56..9b838b7 100644 (file)
@@ -305,6 +305,9 @@ public:
 
 
        //! Type that represents a pointer to a ValueNode's constructor
+       /*! As a pointer to the constructor, it represents a "factory" of 
+       **  objects of this class.
+       */
        typedef LinkableValueNode* (*Factory)(const ValueBase&);
 
        typedef bool (*CheckType)(ValueBase::Type);
@@ -317,6 +320,13 @@ public:
                ReleaseVersion release_version; // which version of synfig introduced this valuenode type
        };
 
+       //! Book of types of linkable value nodes indexed by type name.
+       /*! While the sifz file is read, each time a new LinkableValueNode entry 
+       **  is found, the factory constructor that the "factory" pointer member 
+       **  of the "BookEntry" struct points to, is called, and a new object of 
+       **  that type is created.
+       **  \sa LinkableValueNode::Factory
+       */
        typedef std::map<String,BookEntry> Book;
 
        static Book& book();
index fbf64b0..e325515 100644 (file)
@@ -1307,7 +1307,7 @@ int main(int argc, char *argv[])
                        {
                                job_list.front().outfilename = filename_sans_extension(job_list.front().filename) + '.';
                                if(Target::book().count(target_name))
-                                       job_list.front().outfilename+=Target::book()[target_name].second;
+                                       job_list.front().outfilename+=Target::book()[target_name].filename;
                                else
                                        job_list.front().outfilename+=target_name;
                        }