more updates
[synfig.git] / synfig-core / trunk / src / synfig / keyframe.h
1 /* === S I N F G =========================================================== */
2 /*!     \file keyframe.h
3 **      \brief Template Header
4 **
5 **      $Id: keyframe.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === S T A R T =========================================================== */
23
24 #ifndef __SINFG_KEYFRAME_H
25 #define __SINFG_KEYFRAME_H
26
27 /* === H E A D E R S ======================================================= */
28
29 #include <ETL/handle>
30 #include <vector>
31 #include "string.h"
32 #include "time.h"
33 #include "uniqueid.h"
34 #include "guid.h"
35
36 /* === M A C R O S ========================================================= */
37
38 /* === T Y P E D E F S ===================================================== */
39
40 /* === C L A S S E S & S T R U C T S ======================================= */
41
42 namespace sinfg {
43
44 //! \writeme
45 class Keyframe :  public UniqueID
46 {
47 public:
48
49         Time time_;
50         String desc_;
51         GUID guid_;
52         
53 public:
54
55         Keyframe();
56
57         Keyframe(const Time &time);
58
59         ~Keyframe();
60
61         void set_time(Time x) { time_=x; }
62         
63         Time get_time()const { return time_; }
64
65         void set_description(String x) { desc_=x; }
66         
67         String get_description()const { return desc_; }
68
69         const GUID& get_guid()const { return guid_; }
70         void set_guid(const GUID& x) { guid_=x; }
71
72         using UniqueID::operator<;
73         using UniqueID::operator==;
74         using UniqueID::operator!=;
75         using UniqueID::operator=;
76         
77         bool operator<(const Keyframe &rhs)const { return time_<rhs.time_; }
78         bool operator<(const Time &rhs)const { return time_<rhs; }
79
80 //      bool operator==(const Keyframe &rhs)const { return id_==rhs.id_; }
81         bool operator==(const Time &rhs)const { return time_==rhs; }
82
83 //      bool operator!=(const Keyframe &rhs)const { return id_!=rhs.id_; }
84         bool operator!=(const Time &rhs)const { return time_!=rhs; }
85 }; // END of class Keyframe
86
87 class KeyframeList : public std::vector<Keyframe>
88 {
89
90 public:
91
92         iterator add(const Keyframe &x);
93
94         void erase(const UniqueID &x);
95
96         iterator find(const UniqueID &x);
97
98         const_iterator find(const UniqueID &x)const;
99
100         //! Finds the keyframe at an exact point in time
101         iterator find(const Time &x);
102
103         //! Finds the keyframe after that point in time
104         iterator find_next(const Time &x);
105
106         //! Finds the keyframe before that point in time
107         iterator find_prev(const Time &x);
108
109         const_iterator find(const Time &x)const;
110         const_iterator find_next(const Time &x)const;
111         const_iterator find_prev(const Time &x)const;
112         
113         void find_prev_next(const Time& time, Time &prev, Time &next)const;
114
115         void insert_time(const Time& location, const Time& delta);
116
117         void dump()const;
118         void sync();    
119 };
120
121 //typedef std::list<Keyframe> KeyframeList;
122
123 }; // END of namespace sinfg
124
125 /* === E N D =============================================================== */
126
127 #endif