Panda3D
|
00001 // Filename: timedCycle.h 00002 // Created by: jason (01Aug00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef TIMED_CYCLE_H 00016 #define TIMED_CYCLE_H 00017 // 00018 //////////////////////////////////////////////////////////////////// 00019 // Includes 00020 //////////////////////////////////////////////////////////////////// 00021 #include "pandabase.h" 00022 00023 #include "clockObject.h" 00024 00025 class Datagram; 00026 class DatagramIterator; 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Class : TimedCycle 00030 // Description : A class for anything that needs to cycle over 00031 // some finite list of elements in increments based on 00032 // time. All time variables are assumed to be set in 00033 // seconds. 00034 //////////////////////////////////////////////////////////////////// 00035 00036 class EXPCL_PANDA_PUTIL TimedCycle 00037 { 00038 public: 00039 INLINE TimedCycle(); 00040 INLINE TimedCycle(PN_stdfloat cycle_time, int element_count); 00041 00042 INLINE void set_element_count(int element_count); 00043 INLINE void set_cycle_time(PN_stdfloat cycle_time); 00044 INLINE int next_element(); 00045 00046 public: 00047 void write_datagram(Datagram &me); 00048 void fillin(DatagramIterator &scan); 00049 00050 private: 00051 ClockObject* _global_clock; 00052 PN_stdfloat _cycle_time; 00053 PN_stdfloat _inv_cycle_time; 00054 double _next_switch; 00055 int _current_child; 00056 int _element_count; 00057 }; 00058 00059 #include "timedCycle.I" 00060 00061 #endif