1 /* === S I N F G =========================================================== */
3 ** \brief Template Header
5 ** $Id: node.h,v 1.3 2005/01/10 07:40:26 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
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.
20 /* ========================================================================= */
22 /* === S T A R T =========================================================== */
24 #ifndef __SINFG_PARENTNODE_H
25 #define __SINFG_PARENTNODE_H
27 /* === H E A D E R S ======================================================= */
29 #include <sigc++/signal.h>
34 #include "interpolation.h"
37 /* === M A C R O S ========================================================= */
39 /* === T Y P E D E F S ===================================================== */
41 /* === C L A S S E S & S T R U C T S ======================================= */
49 Interpolation before,after;
52 TimePoint(const Time& x=Time::begin()):
55 before(INTERPOLATION_NIL),
56 after(INTERPOLATION_NIL)
60 const GUID& get_guid()const { return guid; }
61 const Time& get_time()const { return time; }
62 Interpolation get_before()const { return before; }
63 Interpolation get_after()const { return after; }
65 void set_guid(const GUID& x) { guid=x; }
66 void set_time(const Time& x) { time=x; }
67 void set_before(Interpolation x) { before=x; }
68 void set_after(Interpolation x) { after=x; }
70 void absorb(const TimePoint& x);
71 }; // END of class TimePoint
73 inline TimePoint operator+(TimePoint lhs,const Time& rhs)
74 { lhs.set_time(lhs.get_time()+rhs); return lhs; }
76 inline bool operator<(const TimePoint& lhs,const TimePoint& rhs)
77 { return lhs.get_time()<rhs.get_time(); }
79 inline bool operator<(const TimePoint& lhs,const Time& rhs)
80 { return lhs.get_time()<rhs; }
82 inline bool operator<(const Time& lhs,const TimePoint& rhs)
83 { return lhs<rhs.get_time(); }
85 inline bool operator==(const TimePoint& lhs,const TimePoint& rhs)
86 { return lhs.get_time()==rhs.get_time(); }
88 inline bool operator!=(const TimePoint& lhs,const TimePoint& rhs)
89 { return lhs.get_time()!=rhs.get_time(); }
91 class TimePointSet : public std::set<TimePoint>
94 iterator insert(const TimePoint& x);
96 template <typename ITER> void insert(ITER begin, ITER end)
97 { for(;begin!=end;++begin) insert(*begin); }
99 }; // END of class TimePointSet
101 class Node : public etl::rshared_object
104 -- ** -- T Y P E S -----------------------------------------------------------
110 typedef TimePointSet time_set;
113 -- ** -- D A T A -------------------------------------------------------------
121 //! cached time values for all the childrens
122 mutable time_set times;
125 mutable bool bchanged;
128 mutable int time_last_changed_;
131 mutable RWLock rw_lock_;
138 //! \todo This should really be private
139 std::set<Node*> parent_set;
142 -- ** -- S I G N A L S -------------------------------------------------------
147 sigc::signal<void> signal_changed_;
150 /*! \note The second parameter is the *OLD* guid! */
151 sigc::signal<void,GUID> signal_guid_changed_;
154 sigc::signal<void> signal_deleted_;
157 -- ** -- S I G N A L I N T E R F A C E -------------------------------------
162 sigc::signal<void>& signal_deleted() { return signal_deleted_; }
164 sigc::signal<void>& signal_changed() { return signal_changed_; }
167 /*! \note The second parameter is the *OLD* guid! */
168 sigc::signal<void,GUID>& signal_guid_changed() { return signal_guid_changed_; }
171 -- ** -- C O N S T R U C T O R S ---------------------------------------------
178 // This class cannot be copied -- use clone() if necessary
186 -- ** -- M E M B E R F U N C T I O N S -------------------------------------
193 //! Gets the GUID for this value node
194 const GUID& get_guid()const;
196 //! Sets the GUID for this value node
197 void set_guid(const GUID& x);
199 int get_time_last_changed()const;
201 void add_child(Node*x);
203 void remove_child(Node*x);
205 int parent_count()const;
207 const time_set &get_times() const;
209 RWLock& get_rw_lock()const { return rw_lock_; }
216 -- ** -- V I R T U A L F U N C T I O N S -----------------------------------
220 virtual void on_changed();
222 virtual void on_guid_changed(GUID guid);
224 /*! Function to be overloaded that fills
226 virtual void get_times_vfunc(time_set &set) const = 0;
229 sinfg::Node* sinfg::find_node(const sinfg::GUID& guid);
231 template<typename T> etl::handle<T>
232 guid_cast(const sinfg::GUID& guid)
234 return etl::handle<T>::cast_dynamic(sinfg::find_node(guid));
237 }; // END of namespace sinfg
239 /* === E N D =============================================================== */