]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Animation.cc
dispatcher alias methods
[chaz/yoink] / src / Moof / Animation.cc
index 38ffa6c9c5e5c8ca9fdb83806e46f731d9bd274b..7eaec1947eb0a69f6d730a986890dbf92c268412 100644 (file)
@@ -39,15 +39,16 @@ namespace Mf {
 
 /**
  * The collection of nested animation classes.  The animation implementation
- * consists of an AnimationImpl classes which is allocated and initialized with
- * the interface object.  This class contains the specific fields which are
- * required to run a single instance of an animation.  The sequence data is
- * loaded in a difference class which can be shared amongst multiple animation
- * implementation instances.
+ * consists of an Impl class which is allocated and initialized with the
+ * interface object.  This class contains the specific fields which are required
+ * to run a single instance of an animation.  The sequence data is loaded in a
+ * different class which can be shared amongst multiple animation implementation
+ * instances.
  */
 
-struct Animation::AnimationImpl
+class Animation::Impl
 {
+       friend class Animation;
 
        /**
         * Contains "global" animation data for the various animations which get
@@ -55,8 +56,11 @@ struct Animation::AnimationImpl
         * which wants to use these loaded sequences.
         */
 
-       struct AnimationData : public Mippleton<AnimationData>
+       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::AnimationImpl
                         * 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::AnimationImpl
                         * 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)
@@ -182,19 +186,19 @@ struct Animation::AnimationImpl
 
                void loadFromFile()
                {
-                       std::string filePath = Animation::getPathToResource(getName());
+                       std::string filePath = Animation::getPath(getName());
 
                        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::AnimationImpl
                 * registers itself as a mippleton and then loads the animation data.
                 */
 
-               explicit AnimationData(const std::string& name) :
-                       Mippleton<AnimationData>(name)
+               explicit Data(const std::string& name) :
+                       Mippleton<Data>(name)
                {
                        loadFromFile();
                }
@@ -224,8 +228,8 @@ struct Animation::AnimationImpl
         * Construction is intialization.
         */
 
-       AnimationImpl(const std::string& name) :
-               data(AnimationData::retain(name), &AnimationData::release),
+       Impl(const std::string& name) :
+               data(Data::getInstance(name)),
                currentSequence(0),
                frameCounter(0),
                frameIndex(0),
@@ -241,7 +245,7 @@ struct Animation::AnimationImpl
 
        void startSequence(const std::string& name)
        {
-               std::map<std::string,AnimationData::Sequence>::iterator it;
+               std::map<std::string,Data::Sequence>::iterator it;
 
                it = data->sequences.find(name);
 
@@ -299,19 +303,19 @@ struct Animation::AnimationImpl
                }
        }
 
-       boost::shared_ptr<AnimationData> data;                  ///< Internal data.
+       boost::shared_ptr<Data> data;                           ///< Internal data.
 
-       AnimationData::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.
 };
 
 
 Animation::Animation(const std::string& name) :
        // pass through
-       impl_(new Animation::AnimationImpl(name)) {}
+       impl_(new Animation::Impl(name)) {}
 
 
 void Animation::startSequence(const std::string& name)
@@ -343,9 +347,9 @@ unsigned Animation::getFrame() const
  * "animations" subdirectory of any of the searched directories.
  */
 
-std::string Animation::getPathToResource(const std::string& name)
+std::string Animation::getPath(const std::string& name)
 {
-       return Resource::getPathToResource("animations/" + name + ".json");
+       return Resource::getPath("animations/" + name + ".json");
 }
 
 
This page took 0.023356 seconds and 4 git commands to generate.