Panda3D

pStatFrameData.h

00001 // Filename: pStatFrameData.h
00002 // Created by:  drose (10Jul00)
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 PSTATFRAMEDATA_H
00016 #define PSTATFRAMEDATA_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "pnotify.h"
00021 
00022 #include "pvector.h"
00023 
00024 class Datagram;
00025 class DatagramIterator;
00026 class PStatClientVersion;
00027 class PStatClient;
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : PStatFrameData
00031 // Description : Contains the raw timing and level data for a single
00032 //               frame.  This is a sequence of start/stop events, as
00033 //               well as a table of level values, associated with a
00034 //               number of collectors within a single frame.
00035 ////////////////////////////////////////////////////////////////////
00036 class EXPCL_PANDA_PSTATCLIENT PStatFrameData {
00037 public:
00038   INLINE bool is_time_empty() const;
00039   INLINE bool is_level_empty() const;
00040   INLINE bool is_empty() const;
00041   INLINE void clear();
00042   INLINE void swap(PStatFrameData &other);
00043 
00044   INLINE void add_start(int index, double time);
00045   INLINE void add_stop(int index, double time);
00046   INLINE void add_level(int index, double level);
00047 
00048   void sort_time();
00049 
00050   INLINE double get_start() const;
00051   INLINE double get_end() const;
00052   INLINE double get_net_time() const;
00053 
00054   INLINE int get_num_events() const;
00055   INLINE int get_time_collector(int n) const;
00056   INLINE bool is_start(int n) const;
00057   INLINE double get_time(int n) const;
00058 
00059   INLINE int get_num_levels() const;
00060   INLINE int get_level_collector(int n) const;
00061   INLINE double get_level(int n) const;
00062 
00063   bool write_datagram(Datagram &destination, PStatClient *client) const;
00064   void read_datagram(DatagramIterator &source, PStatClientVersion *version);
00065 
00066 private:
00067   class DataPoint {
00068   public:
00069     INLINE bool operator < (const DataPoint &other) const;
00070 
00071     int _index;
00072     double _value;
00073   };
00074   typedef pvector<DataPoint> Data;
00075 
00076   Data _time_data, _level_data;
00077 };
00078 
00079 #include "pStatFrameData.I"
00080 
00081 #endif
00082 
 All Classes Functions Variables Enumerations