]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Animation.cc
considerable refactoring
[chaz/yoink] / src / Moof / Animation.cc
index 39dcb5a40a8b643a7e98958e293ecdcfc7b30ac4..7eaec1947eb0a69f6d730a986890dbf92c268412 100644 (file)
@@ -46,8 +46,9 @@ namespace Mf {
  * instances.
  */
 
-struct Animation::Impl
+class Animation::Impl
 {
+       friend class Animation;
 
        /**
         * Contains "global" animation data for the various animations which get
@@ -55,8 +56,11 @@ struct Animation::Impl
         * which wants to use these loaded sequences.
         */
 
-       struct GlobalData : public Mippleton<GlobalData>
+       class Data : public Mippleton<Data>
        {
+               friend class Impl;
+               friend class Mippleton<Data>;
+
                /**
                 * A frame of an animation sequence.  A frame is merely an index which
                 * presumably represents a "slide" or tile which should be displayed,
@@ -73,15 +77,15 @@ struct Animation::Impl
                         * frame map which is probably loaded within an animation file.
                         */
                
-                       Frame(SerializablePtr root) :
+                       Frame(SerializableP root) :
                                index(0),
                                duration(1.0)
                        {
-                               std::map<std::string,SerializablePtr> rootObj;
+                               Serializable::Map rootObj;
 
                                if (root->get(rootObj))
                                {
-                                       std::map<std::string,SerializablePtr>::iterator it;
+                                       Serializable::Map::iterator it;
 
                                        for (it = rootObj.begin(); it != rootObj.end(); ++it)
                                        {
@@ -123,26 +127,26 @@ struct Animation::Impl
                         * constructor which loads each individual frame.
                         */
 
-                       Sequence(SerializablePtr root) :
+                       Sequence(SerializableP root) :
                                delay(0.0),
                                loop(true)
                        {
-                               std::map<std::string,SerializablePtr> rootObj;
+                               Serializable::Map rootObj;
 
                                if (root->get(rootObj))
                                {
-                                       std::map<std::string,SerializablePtr>::iterator it;
+                                       Serializable::Map::iterator it;
                                        for (it = rootObj.begin(); it != rootObj.end(); ++it)
                                        {
                                                std::string key = (*it).first;
 
                                                if (key == "frames")
                                                {
-                                                       std::vector<SerializablePtr> framesObj;
+                                                       Serializable::Array framesObj;
 
                                                        if ((*it).second->get(framesObj))
                                                        {
-                                                               std::vector<SerializablePtr>::iterator jt;
+                                                               Serializable::Array::iterator jt;
 
                                                                for (jt = framesObj.begin();
                                                                                jt != framesObj.end(); ++jt)
@@ -186,15 +190,15 @@ struct Animation::Impl
 
                        Deserializer deserializer(filePath);
 
-                       SerializablePtr root = deserializer.deserialize();
+                       SerializableP root = deserializer.deserialize();
 
                        if (root)
                        {
-                               std::map<std::string,SerializablePtr> rootObj;
+                               Serializable::Map rootObj;
 
                                if (root->get(rootObj))
                                {
-                                       std::map<std::string,SerializablePtr>::iterator it;
+                                       Serializable::Map::iterator it;
 
                                        for (it = rootObj.begin(); it != rootObj.end(); ++it)
                                        {
@@ -210,8 +214,8 @@ struct Animation::Impl
                 * registers itself as a mippleton and then loads the animation data.
                 */
 
-               explicit GlobalData(const std::string& name) :
-                       Mippleton<GlobalData>(name)
+               explicit Data(const std::string& name) :
+                       Mippleton<Data>(name)
                {
                        loadFromFile();
                }
@@ -225,7 +229,7 @@ struct Animation::Impl
         */
 
        Impl(const std::string& name) :
-               data(GlobalData::getInstance(name)),
+               data(Data::getInstance(name)),
                currentSequence(0),
                frameCounter(0),
                frameIndex(0),
@@ -241,7 +245,7 @@ struct Animation::Impl
 
        void startSequence(const std::string& name)
        {
-               std::map<std::string,GlobalData::Sequence>::iterator it;
+               std::map<std::string,Data::Sequence>::iterator it;
 
                it = data->sequences.find(name);
 
@@ -299,13 +303,13 @@ struct Animation::Impl
                }
        }
 
-       boost::shared_ptr<GlobalData> data;                     ///< Internal data.
+       boost::shared_ptr<Data> data;                           ///< Internal data.
 
-       GlobalData::Sequence*   currentSequence;        ///< Active sequence.
-       unsigned        frameCounter;                                           ///< Current frame.
-       unsigned        frameIndex;                                                     ///< Index of current frame.
-       Scalar          timeAccum;                                                      ///< Time accumulation.
-       Scalar          frameDuration;                                          ///< Scaled frame duration.
+       Data::Sequence*                 currentSequence;        ///< Active sequence.
+       unsigned                                frameCounter;           ///< Current frame.
+       unsigned                                frameIndex;                     ///< Index of current frame.
+       Scalar                                  timeAccum;                      ///< Time accumulation.
+       Scalar                                  frameDuration;          ///< Scaled frame duration.
 };
 
 
This page took 0.026033 seconds and 4 git commands to generate.