00001 // Filename: pStatThreadData.h 00002 // Created by: drose (08Jul00) 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 #ifndef PSTATTHREADDATA_H 00020 #define PSTATTHREADDATA_H 00021 00022 #include <pandatoolbase.h> 00023 00024 #include <referenceCount.h> 00025 00026 #include "pdeque.h" 00027 00028 class PStatCollectorDef; 00029 class PStatFrameData; 00030 class PStatClientData; 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Class : PStatThreadData 00034 // Description : A collection of FrameData structures for 00035 // recently-received frames within a particular thread. 00036 // This holds the raw data as reported by the client, 00037 // and it automatically handles frames received 00038 // out-of-order or skipped. You can ask for a 00039 // particular frame by frame number or time and receive 00040 // the data for the nearest frame. 00041 //////////////////////////////////////////////////////////////////// 00042 class PStatThreadData : public ReferenceCount { 00043 public: 00044 PStatThreadData(const PStatClientData *client_data); 00045 ~PStatThreadData(); 00046 00047 INLINE const PStatClientData *get_client_data() const; 00048 00049 bool is_empty() const; 00050 00051 int get_latest_frame_number() const; 00052 int get_oldest_frame_number() const; 00053 bool has_frame(int frame_number) const; 00054 const PStatFrameData &get_frame(int frame_number) const; 00055 00056 float get_latest_time() const; 00057 float get_oldest_time() const; 00058 const PStatFrameData &get_frame_at_time(float time) const; 00059 int get_frame_number_at_time(float time, int hint = -1) const; 00060 00061 const PStatFrameData &get_latest_frame() const; 00062 00063 float get_frame_rate(float time = 3.0) const; 00064 00065 00066 void set_history(float time); 00067 float get_history() const; 00068 00069 void record_new_frame(int frame_number, PStatFrameData *frame_data); 00070 00071 private: 00072 const PStatClientData *_client_data; 00073 00074 typedef pdeque<PStatFrameData *> Frames; 00075 Frames _frames; 00076 int _first_frame_number; 00077 float _history; 00078 00079 static PStatFrameData _null_frame; 00080 }; 00081 00082 #include "pStatThreadData.I" 00083 00084 #endif 00085