Biorithm  1.1
 All Classes Functions Variables Typedefs Friends
Monitorable.h
00001 /**************************************************************************
00002  * Copyright (c) 2007 Clifford Conley Owens III                           *
00003  *                                                                        *
00004  * This file is part of Biorithm.                                         *
00005  *                                                                        *
00006  * Biorithm is free software: you can redistribute it and/or modify       *
00007  * it under the terms of the GNU General Public License as published by   *
00008  * the Free Software Foundation, either version 3 of the License, or      *
00009  * (at your option) any later version.                                    *
00010  *                                                                        *
00011  * Biorithm is distributed in the hope that it will be useful,            *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00014  * GNU General Public License for more details.                           *
00015  *                                                                        *
00016  * You should have received a copy of the GNU General Public License      *
00017  * along with Biorithm.  If not, see <http://www.gnu.org/licenses/>.      *
00018  *                                                                        *
00019  **************************************************************************/
00020 
00032 #ifndef MONITORABLE_H
00033 #define MONITORABLE_H
00034 
00035 // ---------------------------- External Headers ---------------------------- //
00036 
00037 #include <iostream>
00038 #include <pthread.h>
00039 
00040 using namespace std;
00041 
00047 class Monitorable
00048 {
00049     private:
00050         // The status interval
00051         unsigned int status_interval;
00052 
00053         // Whether or not we are monitoring status
00054         bool monitoring;
00055 
00056         // Whether or not we are allowing monitoring
00057         bool allow_monitoring;
00058 
00059         // The thread data
00060         void* thread_data[3];
00061 
00062         // The thread
00063         pthread_t thread;
00064 
00065     protected:
00066         // The current status
00067         double status;
00068 
00069         // The status stream
00070         ostream* status_out;
00071 
00072         void startStatusMonitoring();
00073         void stopStatusMonitoring();
00074 
00075     public:
00076         Monitorable();
00077         Monitorable(const Monitorable& src);
00078         virtual ~Monitorable();
00079         Monitorable& operator =(const Monitorable& rhs);
00080         void enableStatusMonitoring(ostream* status_out);
00081         void disableStatusMonitoring();
00082         void setStatusInterval(unsigned int status_interval);
00083 };
00084 
00085 #endif
 All Classes Functions Variables Typedefs Friends