GlobalData.h

См. документацию.
00001 /* 
00002  * File:   GlobalData.h
00003  * Author: nick
00004  *
00005  * Created on 12 Сентябрь 2011 г., 16:24
00006  */
00007 
00008 #ifndef _GLOBALDATA_H
00009 #define _GLOBALDATA_H
00010 #include <map>
00011 #include <string>
00012 using namespace std;
00013 
00014 struct OpenedFilesInfo {
00015     //ID клиента, число открытий
00016     map<unsigned int,unsigned int> file_info;
00017     unsigned int flags;
00018 };
00019 
00020 class GlobalData{
00021 private:
00022 //    static pthread_mutex_t openedFiles_mutex;// = PTHREAD_MUTEX_INITIALIZER;*/
00023     /*static map<string,OpenedFilesInfo> openedFiles;*/
00024     GlobalData(){
00025  //       pthread_mutex_init(&openedFiles_mutex,NULL);
00026     }
00027 /*    ~GlobalData(){
00028         pthread_mutex_destroy(&openedFiles_mutex);
00029     }*/
00030 public:
00031     pthread_mutex_t* get_openedFiles_mutex(){
00032         static pthread_mutex_t openedFiles_mutex = PTHREAD_MUTEX_INITIALIZER;
00033         return &openedFiles_mutex;
00034     }
00035 
00036     map<string,OpenedFilesInfo>* get_OpenedFiles(){
00037         static map<string,OpenedFilesInfo> openedFiles;
00038         return &openedFiles;
00039     }
00040 
00041     static GlobalData* get_Instance(){
00042         static GlobalData gd;
00043         return &gd;
00044     }
00045 };
00046 
00047 #endif  /* _GLOBALDATA_H */
00048