Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

direct/src/interval/cInterval.I

Go to the documentation of this file.
00001 // Filename: cInterval.I
00002 // Created by:  drose (27Aug02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: CInterval::get_name
00022 //       Access: Published
00023 //  Description: Returns the interval's name.
00024 ////////////////////////////////////////////////////////////////////
00025 INLINE const string &CInterval::
00026 get_name() const {
00027   return _name;
00028 }
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //     Function: CInterval::get_duration
00032 //       Access: Published
00033 //  Description: Returns the duration of the interval in seconds.
00034 ////////////////////////////////////////////////////////////////////
00035 INLINE double CInterval::
00036 get_duration() const {
00037   recompute();
00038   return _duration;
00039 }
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //     Function: CInterval::get_open_ended
00043 //       Access: Published
00044 //  Description: Returns the state of the "open_ended" flag.  This is
00045 //               primarily intended for instantaneous intervals like
00046 //               FunctionIntervals; it indicates true if the interval
00047 //               has some lasting effect that should be applied even
00048 //               if the interval doesn't get started until after its
00049 //               finish time, or false if the interval is a transitive
00050 //               thing that doesn't need to be called late.
00051 ////////////////////////////////////////////////////////////////////
00052 INLINE bool CInterval::
00053 get_open_ended() const {
00054   return _open_ended;
00055 }
00056 
00057 ////////////////////////////////////////////////////////////////////
00058 //     Function: CInterval::get_state
00059 //       Access: Published
00060 //  Description: Indicates the state the interval believes it is in:
00061 //               whether it has been started, is currently in the
00062 //               middle, or has been finalized.
00063 ////////////////////////////////////////////////////////////////////
00064 INLINE CInterval::State CInterval::
00065 get_state() const {
00066   return _state;
00067 }
00068 
00069 ////////////////////////////////////////////////////////////////////
00070 //     Function: CInterval::is_stopped
00071 //       Access: Published
00072 //  Description: Returns true if the interval is in either its initial
00073 //               or final states (but not in a running or paused
00074 //               state).
00075 ////////////////////////////////////////////////////////////////////
00076 INLINE bool CInterval::
00077 is_stopped() const {
00078   return (_state == S_initial || _state == S_final);
00079 }
00080 
00081 ////////////////////////////////////////////////////////////////////
00082 //     Function: CInterval::set_done_event
00083 //       Access: Published
00084 //  Description: Sets the event that is generated whenever the
00085 //               interval reaches its final state, whether it is
00086 //               explicitly finished or whether it gets there on its
00087 //               own.
00088 ////////////////////////////////////////////////////////////////////
00089 INLINE void CInterval::
00090 set_done_event(const string &event) {
00091   _done_event = event;
00092 }
00093 
00094 ////////////////////////////////////////////////////////////////////
00095 //     Function: CInterval::get_done_event
00096 //       Access: Published
00097 //  Description: Returns the event that is generated whenever the
00098 //               interval reaches its final state, whether it is
00099 //               explicitly finished or whether it gets there on its
00100 //               own.
00101 ////////////////////////////////////////////////////////////////////
00102 INLINE const string &CInterval::
00103 get_done_event() const {
00104   return _done_event;
00105 }
00106 
00107 ////////////////////////////////////////////////////////////////////
00108 //     Function: CInterval::get_t
00109 //       Access: Published
00110 //  Description: Returns the current time of the interval: the last
00111 //               value of t passed to priv_initialize(), priv_step(), or
00112 //               priv_finalize().
00113 ////////////////////////////////////////////////////////////////////
00114 INLINE double CInterval::
00115 get_t() const {
00116   return _curr_t;
00117 }
00118 
00119 ////////////////////////////////////////////////////////////////////
00120 //     Function: CInterval::set_auto_pause
00121 //       Access: Published
00122 //  Description: Changes the state of the 'auto_pause' flag.  If
00123 //               this is true, the interval may be arbitrarily
00124 //               interrupted when the system needs to reset due to
00125 //               some external event by calling
00126 //               CIntervalManager::interrupt().  If this
00127 //               is false (the default), the interval must always be
00128 //               explicitly finished or paused.
00129 ////////////////////////////////////////////////////////////////////
00130 INLINE void CInterval::
00131 set_auto_pause(bool auto_pause) {
00132   _auto_pause = auto_pause;
00133 }
00134 
00135 ////////////////////////////////////////////////////////////////////
00136 //     Function: CInterval::get_auto_pause
00137 //       Access: Published
00138 //  Description: Returns the state of the 'auto_pause' flag.  See
00139 //               set_auto_pause().
00140 ////////////////////////////////////////////////////////////////////
00141 INLINE bool CInterval::
00142 get_auto_pause() const {
00143   return _auto_pause;
00144 }
00145 
00146 ////////////////////////////////////////////////////////////////////
00147 //     Function: CInterval::set_auto_finish
00148 //       Access: Published
00149 //  Description: Changes the state of the 'auto_finish' flag.  If
00150 //               this is true, the interval may be arbitrarily
00151 //               finished when the system needs to reset due to
00152 //               some external event by calling
00153 //               CIntervalManager::interrupt().  If this
00154 //               is false (the default), the interval must always be
00155 //               explicitly finished or paused.
00156 ////////////////////////////////////////////////////////////////////
00157 INLINE void CInterval::
00158 set_auto_finish(bool auto_finish) {
00159   _auto_finish = auto_finish;
00160 }
00161 
00162 ////////////////////////////////////////////////////////////////////
00163 //     Function: CInterval::get_auto_finish
00164 //       Access: Published
00165 //  Description: Returns the state of the 'auto_finish' flag.  See
00166 //               set_auto_finish().
00167 ////////////////////////////////////////////////////////////////////
00168 INLINE bool CInterval::
00169 get_auto_finish() const {
00170   return _auto_finish;
00171 }
00172 
00173 ////////////////////////////////////////////////////////////////////
00174 //     Function: CInterval::set_wants_t_callback
00175 //       Access: Published
00176 //  Description: Changes the state of the 'wants_t_callback' flag.  If
00177 //               this is true, the interval will be returned by
00178 //               CIntervalManager::get_event() each time the
00179 //               interval's time value has been changed, regardless of
00180 //               whether it has any external events.
00181 ////////////////////////////////////////////////////////////////////
00182 INLINE void CInterval::
00183 set_wants_t_callback(bool wants_t_callback) {
00184   _wants_t_callback = wants_t_callback;
00185   _last_t_callback = -1.0;
00186 }
00187 
00188 ////////////////////////////////////////////////////////////////////
00189 //     Function: CInterval::get_wants_t_callback
00190 //       Access: Published
00191 //  Description: Returns the state of the 'wants_t_callback' flag.
00192 //               See set_wants_t_callback().
00193 ////////////////////////////////////////////////////////////////////
00194 INLINE bool CInterval::
00195 get_wants_t_callback() const {
00196   return _wants_t_callback;
00197 }
00198 
00199 ////////////////////////////////////////////////////////////////////
00200 //     Function: CInterval::set_manager
00201 //       Access: Published
00202 //  Description: Indicates the CIntervalManager object which will be
00203 //               responsible for playing this interval.  This defaults
00204 //               to the global CIntervalManager; you should need to
00205 //               change this only if you have special requirements for
00206 //               playing this interval.
00207 ////////////////////////////////////////////////////////////////////
00208 INLINE void CInterval::
00209 set_manager(CIntervalManager *manager) {
00210   _manager = manager;
00211 }
00212 
00213 ////////////////////////////////////////////////////////////////////
00214 //     Function: CInterval::get_manager
00215 //       Access: Published
00216 //  Description: Returns the CIntervalManager object which will be
00217 //               responsible for playing this interval.  Note that
00218 //               this can only return a C++ object; if the particular
00219 //               CIntervalManager object has been extended in the
00220 //               scripting language, this will return the encapsulated
00221 //               C++ object, not the full extended object.
00222 ////////////////////////////////////////////////////////////////////
00223 INLINE CIntervalManager *CInterval::
00224 get_manager() const {
00225   return _manager;
00226 }
00227 
00228 ////////////////////////////////////////////////////////////////////
00229 //     Function: CInterval::check_t_callback
00230 //       Access: Public
00231 //  Description: Returns true if the wants_t_callback() flag is true
00232 //               and the interval's t value has changed since the last
00233 //               call to check_t_callback(), false otherwise.
00234 ////////////////////////////////////////////////////////////////////
00235 INLINE bool CInterval::
00236 check_t_callback() {
00237   if (get_wants_t_callback() && get_t() != _last_t_callback) {
00238     _last_t_callback = get_t();
00239     return true;
00240   }
00241   return false;
00242 }
00243 
00244 ////////////////////////////////////////////////////////////////////
00245 //     Function: CInterval::recompute
00246 //       Access: Protected
00247 //  Description: Calls do_recompute() if the dirty flag has been set.
00248 ////////////////////////////////////////////////////////////////////
00249 INLINE void CInterval::
00250 recompute() const {
00251   if (_dirty) {
00252     ((CInterval *)this)->do_recompute();
00253   }
00254 }
00255 
00256 ////////////////////////////////////////////////////////////////////
00257 //     Function: CInterval::check_stopped
00258 //       Access: Protected
00259 //  Description: Issues a warning if our internal state is not in
00260 //               one of the stopped states.
00261 ////////////////////////////////////////////////////////////////////
00262 INLINE void CInterval::
00263 check_stopped(TypeHandle type, const char *method_name) const {
00264   if (_state == S_started) {
00265     interval_cat.warning()
00266       << type.get_name() << "::" << method_name << "() called for "
00267       << get_name() << " in state " << _state << ".\n";
00268     nassertv(!verify_intervals);
00269   }
00270 }
00271 
00272 ////////////////////////////////////////////////////////////////////
00273 //     Function: CInterval::check_started
00274 //       Access: Protected
00275 //  Description: Issues a warning if our internal state is not in
00276 //               one of the started states.
00277 ////////////////////////////////////////////////////////////////////
00278 INLINE void CInterval::
00279 check_started(TypeHandle type, const char *method_name) const {
00280   if (_state != S_started && _state != S_paused) {
00281     interval_cat.warning()
00282       << type.get_name() << "::" << method_name << "() called for "
00283       << get_name() << " in state " << _state << ".\n";
00284     nassertv(!verify_intervals);
00285   }
00286 }
00287 
00288 INLINE ostream &
00289 operator << (ostream &out, const CInterval &ival) {
00290   ival.output(out);
00291   return out;
00292 }
00293 

Generated on Fri May 2 01:37:39 2003 for Direct by doxygen1.3