XCube Stream Reader SDK
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes
Projects Class Reference

Projects class. More...

#include <Projects.h>

List of all members.

Public Member Functions

 Projects (string mntBasePnt="", string projBasePath="", unsigned diskCount=0)
 Constructor.
virtual ~Projects ()
 De-constructor.
vector< PROJECTpmGetProjects ()
 Return a list of project on the active volume.
int pmDeleteProject (string const &prjName)
 Delete a project.
int pmCloseProject ()
int pmActivateProject (string prjName)
 Mark a project as the active project.
int pmInactivateProject ()
 Close an opened project.
PROJECTpmGetActiveProject ()
 Return the active project currently.
int pmGetStreams (vector< STREAM > &streamList)
 Return all streams belonging to the active project.
bool pmIsProjectAlive () const
 Indicate whether a project is created and alive now.
bool pmIsProjectActive ()
 Whether a project is opened.
PROJECTpmGetCurrentProject ()
 Return a pointer points to the current project.
void pmSetCurrentProject (string projectName)
 Set current project.
string pmGetRootPath () const
 Return the root path of projects.
string pmGetMntBasePnt () const
 Return the path of the base mount point.
unsigned pmGetDiskCount () const
 Get the number of disks.
void pmSetDiskCount (int numOfDisks)
 Set the number of disks.
PROJECTpmGetLatestProject ()
 Get the latest project.
int pmGetStreamFiles (STREAM const &stream, vector< string > &streamFiles)

Public Attributes

bool mProjectCreated
 project created flag

Protected Member Functions

int pmScanProjects ()
 Scan all projects on the active volume.
int pmRemoveDirectory (string path)
bool pmIsDirectory (string path)
 Whether path is a regular file or directory.
INT64 pmGetProjectDataSize (string const &projName, vector< int > &missingDisks)
 Return the size of the data file belonging to a project.
int pmScanStreams (PROJECT &proj)
 Scan all streams of a specific project.
void pmParseStreamName (STREAM &stream)
 Parse the name of a stream.
PROJECTpmFindProject (string prjName)
 search a project based its name
unsigned long long pmGetStreamSize (STREAM const &stream)
 Get stream size.
unsigned long long pmGetStreamSizeDeepSearch (STREAM const &stream)
unsigned long long pmGetProjectDataSizeDeepSearch (std::string const &prjName)
int pmDeleteProjectDeepSearch (std::string const &prjName)

Protected Attributes

string mRootPath
 path of the root of projects,
string mMntBasePnt
 path of the base mount point
UINT32 mDiskCount
 number of disks
vector< PROJECTmProjects
 project list
PROJECTmActiveProject
 opened project pointer
PROJECTmCurrentProject
 current project pointer

Static Protected Attributes

static const int MntBasePntNo = MNT_POINT_BASE_NUMBER
 base mount point number

Detailed Description

Projects class.

Class of project manager, it provides all functionality to manage projects of the logger.


Constructor & Destructor Documentation

Projects::Projects ( string  mntBasePnt = "",
string  projBasePath = "",
unsigned  diskCount = 0 
)

Constructor.

Construct an object of project manager

Parameters:
mntBasePntpath of the base mount point
projBasePathpath of the base project
diskCountnumber of disks of the active volume
mntPtNumAfterBasetrue if the mount point number should follow the projBasePath rather than the mntBasePnt
virtual Projects::~Projects ( ) [virtual]

De-constructor.

De-construct an object of a project manager, clean all fields and memory


Member Function Documentation

int Projects::pmActivateProject ( string  prjName)

Mark a project as the active project.

Only one project may be active at any time.

Parameters:
prjName- name of the project to set active
Returns:
-1 - there is a project opened
-2 - project name not found
0 - success

Close the current project.

Returns:
0 - current project closed
-1 - fail to close current project
int Projects::pmDeleteProject ( string const &  prjName)

Delete a project.

Delete a project, including all sub directories and data streams, across all disks.

Parameters:
prjName- name of the project to delete
Returns:
0 - project deleted
-1 - project not found
-2 - forbid to delete current project
-3 - fail to delete
int Projects::pmDeleteProjectDeepSearch ( std::string const &  prjName) [protected]

Delete a project. The search for the project directories is done starting from the mount point

Parameters:
prjNameA string representing the project name
Returns:
0 if successful, -1 if an error is encountered
PROJECT* Projects::pmFindProject ( string  prjName) [protected]

search a project based its name

Look for a project in the project list for a project matches the name. Project name is unique.

Parameters:
prjName- name of the project to search
Returns:
PROJECT* - NULL if no match or a pointer points to the project found

Return the active project currently.

Search is there any project opened, if yes, return a pointer to the opened project, or return NULL

Returns:
PROJECT* - pointer to the opened project if any, or NULL

Return a pointer points to the current project.

Return the last project descriptor int the project list which is the latest project.

Parameters:
projectName- name of current project
Returns:
PROJECT* - pointer to the current project
unsigned Projects::pmGetDiskCount ( ) const

Get the number of disks.

Return the number of disks detected by the system as usable

Returns:
unsigned - number of disks

Get the latest project.

Return the latest created project

Returns:
PROJECT* - pointer to the latest project or NULL if no project
string Projects::pmGetMntBasePnt ( ) const

Return the path of the base mount point.

For example. "/mnt/disk"

Returns:
string - path of the base mount point
INT64 Projects::pmGetProjectDataSize ( string const &  projName,
vector< int > &  missingDisks 
) [protected]

Return the size of the data file belonging to a project.

Get the total size of a project(Go through all disks and sum up the size of data ), report any missing disks

Parameters:
projNamename of a project
missingDiskslist of missing disks
Returns:
total size of the project
unsigned long long Projects::pmGetProjectDataSizeDeepSearch ( std::string const &  prjName) [protected]

Return total data size of all of the streams in a project. A search for the project is done starting from the mount point. Then each project directory is searched for stream files.

Parameters:
stream- the stream to get size
Returns:
unsigned long long - data size

Return a list of project on the active volume.

First do a projects scan, find out all projects, then return all projects found on the active volume as a project list

Returns:
a vector containing all projects
string Projects::pmGetRootPath ( ) const

Return the root path of projects.

Get the root path of projects, for example "/xcube"

Returns:
string - path of root of projects.
int Projects::pmGetStreamFiles ( STREAM const &  stream,
vector< string > &  streamFiles 
)

Return a collection of stream files for a given STREAM

Parameters:
streamThe Stream to search for files
[out]streamFilesa reference to a vector where the stream filenames will be stored.
Returns:
0 if successful, -1 otherwise
int Projects::pmGetStreams ( vector< STREAM > &  streamList)

Return all streams belonging to the active project.

Search all streams belonging to the opened project and return them

Parameters:
streamList- streams belong to the opened project (will be written in)
Returns:
0 - success
-1 - no project opened
-2 - fail to open data directory of the project
unsigned long long Projects::pmGetStreamSize ( STREAM const &  stream) [protected]

Get stream size.

Return total data size of a stream, sum up all data files on all disks

Parameters:
stream- the stream to get size
Returns:
unsigned long long - data size
unsigned long long Projects::pmGetStreamSizeDeepSearch ( STREAM const &  stream) [protected]

Return total data size of a stream, sum up all data files on all disks A search for all stream files is done starting from the mount point

Parameters:
stream- the stream to get size
Returns:
unsigned long long - data size

Close an opened project.

Close an opened project, if no project opened, return error code

Returns:
0 -success
-1 - no project opened error
bool Projects::pmIsDirectory ( string  path) [protected]

Whether path is a regular file or directory.

Boolean function to check whether path is a regular file or directory

Parameters:
path- the path to test
Returns:
true - path is a directory
false - path is not a directory

Whether a project is opened.

Tell whether there is any project opened there

Returns:
true - there is an opened project
false - no project is opened

Indicate whether a project is created and alive now.

Boolean function to check whether there is a project created and alive in the system

Returns:
true - there is a project alive now
false - no project alive
void Projects::pmParseStreamName ( STREAM stream) [protected]

Parse the name of a stream.

Parse the name of stream into stream enum, stream type and stream run

Parameters:
stream- the stream to parse
int Projects::pmRemoveDirectory ( string  path) [protected]

Remove a directory indicated by path, this function is designed for "pmDeleteProject" to delete the project directory on the disks

Parameters:
path- path of the directory to remove
Returns:
0 - success
-1 - fail to delete
int Projects::pmScanProjects ( ) [protected]

Scan all projects on the active volume.

Scan all projects created on the active volumes, it will search "/mnt/disk0" for all projects.

Returns:
0 - success
-1 - fail
int Projects::pmScanStreams ( PROJECT proj) [protected]

Scan all streams of a specific project.

Scan all streams of a specific project and fill in the stream list information

Parameters:
proj- the project to be scaned
Returns:
-1 - project pointer is null
-2 - fail to open the data directory
void Projects::pmSetCurrentProject ( string  projectName)

Set current project.

Parameters:
projectName- name of current project
void Projects::pmSetDiskCount ( int  numOfDisks)

Set the number of disks.

Set the number of disks

Returns:
unsigned - number of disks

Member Data Documentation

opened project pointer

points to the opened project if any, or NULL if there is no project opened

UINT32 Projects::mDiskCount [protected]

number of disks

total number of disks of the active volumes

string Projects::mMntBasePnt [protected]

path of the base mount point

for example, "/mnt/disk"

const int Projects::MntBasePntNo = MNT_POINT_BASE_NUMBER [static, protected]

base mount point number

is initialize to MNT_POINT_BASE_NUMBER, which is 0

project created flag

when a project is created, it will be marked as true, when the project is done, will be marked back as false

vector<PROJECT> Projects::mProjects [protected]

project list

A vector containing all projects belong to the active volumes

string Projects::mRootPath [protected]

path of the root of projects,

for example: "/xcube" completes the path "/mnt/disk#/xcube"


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Friends Defines