Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / synfig_0_61_04 / synfig-core / src / synfig / keyframe.h
1 /* === S Y N F I 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-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === S T A R T =========================================================== */
24
25 #ifndef __SYNFIG_KEYFRAME_H
26 #define __SYNFIG_KEYFRAME_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include <ETL/handle>
31 #include <vector>
32 #include "string.h"
33 #include "time.h"
34 #include "uniqueid.h"
35 #include "guid.h"
36
37 /* === M A C R O S ========================================================= */
38
39 /* === T Y P E D E F S ===================================================== */
40
41 /* === C L A S S E S & S T R U C T S ======================================= */
42
43 namespace synfig {
44
45 //! \writeme
46 class Keyframe :  public UniqueID
47 {
48 public:
49
50         Time time_;
51         String desc_;
52         GUID guid_;
53         
54 public:
55
56         Keyframe();
57
58         Keyframe(const Time &time);
59
60         ~Keyframe();
61
62         void set_time(Time x) { time_=x; }
63         
64         Time get_time()const { return time_; }
65
66         void set_description(String x) { desc_=x; }
67         
68         String get_description()const { return desc_; }
69
70         const GUID& get_guid()const { return guid_; }
71         void set_guid(const GUID& x) { guid_=x; }
72
73         using UniqueID::operator<;
74         using UniqueID::operator==;
75         using UniqueID::operator!=;
76         using UniqueID::operator=;
77         
78         bool operator<(const Keyframe &rhs)const { return time_<rhs.time_; }
79         bool operator<(const Time &rhs)const { return time_<rhs; }
80
81 //      bool operator==(const Keyframe &rhs)const { return id_==rhs.id_; }
82         bool operator==(const Time &rhs)const { return time_==rhs; }
83
84 //      bool operator!=(const Keyframe &rhs)const { return id_!=rhs.id_; }
85         bool operator!=(const Time &rhs)const { return time_!=rhs; }
86 }; // END of class Keyframe
87
88 class KeyframeList : public std::vector<Keyframe>
89 {
90
91 public:
92
93         iterator add(const Keyframe &x);
94
95         void erase(const UniqueID &x);
96
97         iterator find(const UniqueID &x);
98
99         const_iterator find(const UniqueID &x)const;
100
101         //! Finds the keyframe at an exact point in time
102         iterator find(const Time &x);
103
104         //! Finds the keyframe after that point in time
105         iterator find_next(const Time &x);
106
107         //! Finds the keyframe before that point in time
108         iterator find_prev(const Time &x);
109
110         const_iterator find(const Time &x)const;
111         const_iterator find_next(const Time &x)const;
112         const_iterator find_prev(const Time &x)const;
113         
114         void find_prev_next(const Time& time, Time &prev, Time &next)const;
115
116         void insert_time(const Time& location, const Time& delta);
117
118         void dump()const;
119         void sync();    
120 };
121
122 //typedef std::list<Keyframe> KeyframeList;
123
124 }; // END of namespace synfig
125
126 /* === E N D =============================================================== */
127
128 #endif