Scopira 20080306

timeslice.h

00001 
00002 /*
00003  *  Copyright (c) 2009    National Research Council
00004  *
00005  *  All rights reserved.
00006  *
00007  *  This material is confidential and proprietary information of
00008  *  National Research Council Canada ("Confidential Information").
00009  *  This Confidential Information may only be used and reproduced
00010  *  in accordance with the terms of the license agreement.
00011  *
00012  */
00013 
00014 #ifndef __INCLUDED_SCOPIRA_AGENT_TIMESLICE_H__
00015 #define __INCLUDED_SCOPIRA_AGENT_TIMESLICE_H__
00016 
00017 #include <scopira/tool/time.h>
00018 
00019 namespace scopira
00020 {
00021   namespace agent
00022   {
00023     class timeslice;
00024     class global_timeslice;
00025     class subtimeslice;
00026     class simple_timeslice;
00027   }
00028 }
00029 
00036 class scopira::agent::timeslice
00037 {
00038   public:
00046     timeslice(const char * prefix);
00047 
00049     ~timeslice();
00050 
00051   private:
00052     static const int num_timers = 5;
00053     double dm_numerators[num_timers];
00054     const char *dm_prefix;
00055     
00056     scopira::tool::chrono dm_chrono;
00057 
00058     friend class scopira::agent::subtimeslice;
00059 };
00060 
00067 class scopira::agent::global_timeslice : public scopira::agent::timeslice
00068 {
00069   public:
00071     global_timeslice(const char * prefix = "global_timeslice");
00073     ~global_timeslice();
00074 
00076     static global_timeslice * instance(void) { return dm_instance; }
00077 
00078   private:
00079     static global_timeslice * dm_instance;
00080 };
00081 
00089 class scopira::agent::subtimeslice
00090 {
00091   public:
00097     subtimeslice(timeslice &parent, int index);
00104     subtimeslice(int index);
00106     ~subtimeslice();
00107   private:
00108     timeslice *dm_parent;
00109     int dm_index;
00110     double dm_starttime;
00111 };
00112 
00118 class scopira::agent::simple_timeslice
00119 {
00120   public:
00122     simple_timeslice(void);
00124     ~simple_timeslice();
00125 
00126   private:
00127     scopira::tool::chrono dm_chrono;
00128 };
00129 
00130 #endif
00131