XCube Stream Reader SDK
x3c/include/projectManagement/Projects.h
00001 /******************************************************************************
00002  * Projects.h
00003  *
00004  *  Author      : Danni Song
00005  *  Version     :
00006  *  Copyright   : (C) Copyright 2011 XCube Research and Development
00007  *                      All rights reserved.
00008  *  Description : This class provides user functions to projects, refers to the
00009  *                access and manipulation of Logger Data Projects related data
00010  *                on any X3C logger ot DSSC platform.
00011  *  HISTORY     :
00012  *          Oct 14, 2011 - initial version
00013  *
00014  *****************************************************************************/
00015 #ifndef PROJECTS_H_
00016 #define PROJECTS_H_
00017 
00018 #include "xcTypes.h"
00019 #include "CX3cFile.h"
00020 //#include "CMsgHub.h"
00021 #include "xcTaskTools.h"
00022 #include "x3cTaskDefs.h"
00023 
00024 #include <string>
00025 #include <vector>
00026 #include <sstream>
00027 using namespace std;
00028 
00029 #define MNT_POINT_BASE_NUMBER 0;
00030 #define PROJECTNAME_PREFIX "proj_"  //UTC is appended to this string
00031 #define PROJECT_BASE_PATH "/xcube"
00032 // this is defined in lgrTaskDefs.h
00033 //Identifies the TYPE of task,
00034 //#define TASK_ADDR_LGRMGR              ((TASK_TYPE_LGRMGR << 16)   | 0x00000000)
00035 
00036 
00038 
00042 typedef struct  _STREAM_BLOCK_ {
00044 
00046     string strmParent;
00047 
00049 
00051     string strmPath;            // Path from project base path
00052 
00054 
00055     string  strmName;
00056 
00058 
00059     unsigned long long strmSize;
00060 
00062 
00063     unsigned int strmType;
00064 
00066 
00067     unsigned int strmEnum;
00068 
00070 
00071     unsigned int strmRun;
00072 }STREAM;
00073 
00075 
00078 typedef struct  _PROJECT_BLOCK_
00079 {
00081 
00082     string  prjName;
00083 
00085 
00086     UINT64 prjSize;
00087 
00089 
00090     bool activeFlag;
00091 
00093     /* a vector containing all stream of this project*/
00094     vector<STREAM> streamList;
00095 } PROJECT;
00096 
00098 
00102 class Projects
00103 {
00104  protected:
00105 
00107 
00108     string mRootPath;
00109 
00111 
00112     string mMntBasePnt;
00113 
00115 
00116     UINT32 mDiskCount;
00117 
00119 
00120     vector<PROJECT> mProjects;
00121 
00123 
00125     PROJECT* mActiveProject;
00126 
00128     PROJECT* mCurrentProject;
00129 
00131 
00132     static const int MntBasePntNo = MNT_POINT_BASE_NUMBER;
00133 
00134 
00135  public:
00137 
00139     bool mProjectCreated;
00140 
00142 
00152     Projects(string mntBasePnt = "", string projBasePath = "",
00153              unsigned diskCount = 0);
00154 
00156 
00159     virtual ~ Projects();
00160 
00162 
00168     vector<PROJECT> pmGetProjects();
00169 
00171 
00181     int pmDeleteProject(string const& prjName);
00182 
00183     // ! Close project
00189     int pmCloseProject();
00190 
00192 
00199     int pmActivateProject(string prjName);
00200 
00202 
00207     int pmInactivateProject();
00208 
00210 
00216     PROJECT* pmGetActiveProject();
00217 
00219 
00227     int pmGetStreams(vector<STREAM> &streamList);
00228 
00230 
00237     bool pmIsProjectAlive() const;
00238 
00240 
00245     bool pmIsProjectActive();
00246 
00248 
00255     PROJECT* pmGetCurrentProject();
00256 
00258 
00260     void pmSetCurrentProject(string projectName);
00261 
00263 
00268     string pmGetRootPath() const;
00269 
00271 
00276     string pmGetMntBasePnt() const;
00277 
00279 
00284     unsigned pmGetDiskCount() const;
00285 
00287 
00292     void pmSetDiskCount(int numOfDisks);
00293 
00295 
00300     PROJECT* pmGetLatestProject();
00301 
00311     int pmGetStreamFiles(STREAM const& stream, vector<string>& streamFiles);
00312 
00313 protected:
00315 
00322     int pmScanProjects();
00323 
00324     // ! Remove a directory
00333     int pmRemoveDirectory(string path);
00334 
00336 
00343     bool pmIsDirectory(string path);
00344 
00346 
00354     INT64 pmGetProjectDataSize(string const& projName, vector<int> &missingDisks);
00355 
00357 
00365     int pmScanStreams(PROJECT &proj);
00366 
00368 
00373     void pmParseStreamName(STREAM &stream);
00374 
00376 
00383     PROJECT* pmFindProject(string prjName);
00384 
00386 
00392     unsigned long long pmGetStreamSize(STREAM const& stream);
00393 
00401     unsigned long long pmGetStreamSizeDeepSearch(STREAM const& stream);
00402 
00411     unsigned long long pmGetProjectDataSizeDeepSearch(std::string const& prjName);
00412 
00420     int pmDeleteProjectDeepSearch(std::string const& prjName);
00421 };
00422 
00423 #endif /* PROJECTS_H_ */
 All Classes Files Functions Variables Typedefs Friends Defines