source: trunk/FACT++/src/FilesStatisticsService.h@ 11293

Last change on this file since 11293 was 11292, checked in by lyard, 14 years ago
added configurations to everything that can be tweaked
File size: 2.4 KB
Line 
1//*************************************************************************************
2/** @class FilesStatisticsService
3 *
4 * @brief provides a statistics service telling the free space on disk and the total size written so far
5 *
6 */
7//*************************************************************************************
8#ifndef FILESSTATISTICSSERVICE_H_
9#define FILESSTATISTICSSERVICE_H_
10
11#include "MessageDim.h"
12#include <boost/thread.hpp>
13#include <mutex>
14#include <string>
15#include <set>
16
17using namespace std;
18
19struct FileStatisticsData {
20 long sizeWritten;
21 long freeSpace;
22 long writingRate;
23};
24class FilesStatisticsService
25{
26private:
27 ///The name of the server which created the object
28 string fServerName;
29 ///The current folder being watched for free space
30 string fCurrentFolder;
31 ///The boost thread used to update the service
32 boost::thread fThread;
33 ///The data structure holding the stat data
34 FileStatisticsData fStats;
35 ///The mutex used to make sure that the service isn't updated while changing conf.
36 mutex fMutex;
37 ///the Dim service
38 DimDescribedService* fService;
39 ///Bool indicating if main loop should be exited
40 bool fContinueStats;
41 ///Bool indicating if debug information should be printed
42 bool fDebug;
43 ///Main loop
44 void UpdateService();
45 ///Returns the free space on the disk of the folder being watched (fCurrentFolder)
46 long GetFreeSpace();
47 ///Returns the size on disk of a given file
48 long GetFileSizeOnDisk(const string& file);
49 ///This is the total base size of all opened files
50 long fBaseSize;
51 ///This is the list of all opened files. set is used to easily check for entries
52 set<string> fOpenedFiles;
53 ///This is the duration, in second between two service updates. 0 means no more updates
54 float fPeriodDuration;
55 ///This is the MessageImp object used for messaging
56 MessageImp* fMess;
57public:
58 ///Constructor
59 FilesStatisticsService(const string& serverName, MessageImp* mess);
60 ///Default destructor
61 ~FilesStatisticsService();
62 ///Configures that current folder where files are written to
63 bool SetCurrentFolder(const string& folder);
64 bool FileOpened(const string& fileName);
65 void SetDebugMode(bool);
66 void SetStatPeriod(const float duration);
67 void GetTotalSizeWritten(FileStatisticsData& data);
68 void Reset();
69};
70
71#endif /* FILESSTATISTICSSERVICE_H_ */
Note: See TracBrowser for help on using the repository browser.