Panda3D

pStatThreadData.h

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