Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
kome::core::MsppManager Class Reference

Mass++ manager class. More...

#include <MsppManager.h>

Collaboration diagram for kome::core::MsppManager:
Collaboration graph
[legend]

Public Member Functions

const char * getAppName ()
 gets the application name More...
 
const char * getPlatformName ()
 gets the platform name More...
 
const char * getRegName ()
 gets the registory name More...
 
const char * getVersion ()
 gets Mass++ version More...
 
std::vector< std::string > getPluginDir ()
 get mspp plugin dir More...
 
const char * getMsppDir ()
 gets Mass++ directory More...
 
const char * getConfDir ()
 gets config directory More...
 
const char * getTmpDir ()
 gets temporary file directory name More...
 
std::string getTmpFileName (const char *prefix, const char *suffix, const char *dir=NULL)
 gets temporary file name More...
 
void setIniFile (IniFile *ini)
 sets ini file More...
 
IniFilegetIniFile ()
 gets ini file More...
 
void setParameters (IniFile *params)
 sets parameters file More...
 
IniFilegetParameters ()
 gets parameters More...
 
unsigned int getPid ()
 gets the process ID More...
 
bool isInitializedMATLAB (void)
 gets MATLAB's initialized flag value More...
 
void setInitializedMATLAB (void)
 sets initialized flag value
 
void resetInitializedMATLAB (void)
 resets initialized flag value
 

Static Public Member Functions

static MsppManagergetInstance ()
 gets MsppManager object (This is the only object.) More...
 

Protected Member Functions

 MsppManager ()
 constructor More...
 
virtual ~MsppManager ()
 destructor
 
void setPath ()
 sets file path
 
void deleteTmpFiles ()
 deletes temporary files
 
void setPluginDir ()
 set mspp plugin dir
 

Protected Attributes

std::string m_app
 
std::string m_reg
 
std::string m_version
 
std::string m_msppDir
 
std::string m_confDir
 
std::string m_tmpDir
 
std::string m_pidTmpDir
 
IniFilem_ini
 
IniFilem_params
 
unsigned long m_pid
 
std::vector< std::string > m_pluginPaths
 
std::string m_platform
 
bool m_bInitializedMATLAB
 

Detailed Description

Mass++ manager class.

Definition at line 28 of file MsppManager.h.

Constructor & Destructor Documentation

kome::core::MsppManager::MsppManager ( )
protected

constructor

process ID

Definition at line 41 of file MsppManager.cpp.

41  {
42  // initialize
43  m_ini = NULL;
44  m_params = NULL;
45 
46  // set path
47  setPath();
48 
49  // set mspp plugin dir
50  setPluginDir();
51 
52  // delete tmp files
54 
55  // version
56  m_app = APP_NAME;
57  m_reg = REG_NAME;
58  m_version = MSPP_VERSION;
59 
60 #if defined(_WIN64) || defined(__amd64__)
61  m_platform = "64-bit";
62 #else
63  m_platform = "32-bit";
64 #endif // _WIN64 || __amd64__
65 
67  m_pid = getprocessid();
68 
69  m_bInitializedMATLAB = false; // @Date:2013/08/08 <Add> A.Ozaki
70 }
std::string m_platform
Definition: MsppManager.h:77
#define NULL
Definition: CoreMacros.h:18
void deleteTmpFiles()
deletes temporary files
unsigned long m_pid
Definition: MsppManager.h:71
unsigned int getprocessid()
gets procsess ID
void setPath()
sets file path
Definition: MsppManager.cpp:97
void setPluginDir()
set mspp plugin dir

Here is the call graph for this function:

Member Function Documentation

const char * kome::core::MsppManager::getAppName ( )

gets the application name

Returns
application name

Definition at line 77 of file MsppManager.cpp.

77  {
78  return m_app.c_str();
79 }
const char * kome::core::MsppManager::getConfDir ( )

gets config directory

Returns
config directory

Definition at line 176 of file MsppManager.cpp.

176  {
177  return m_confDir.c_str();
178 }
IniFile * kome::core::MsppManager::getIniFile ( )

gets ini file

Returns
ini file object

Definition at line 272 of file MsppManager.cpp.

272  {
273  return m_ini;
274 }
static MsppManager & kome::core::MsppManager::getInstance ( )
static

gets MsppManager object (This is the only object.)

Returns
MsppManager object

Definition at line 292 of file MsppManager.cpp.

292  {
293  // create object (This is the only object.)
294  static MsppManager mgr;
295 
296  return mgr;
297 }
Mass++ manager class.
Definition: MsppManager.h:28
const char * kome::core::MsppManager::getMsppDir ( )

gets Mass++ directory

Returns
Mass++ directory

Definition at line 171 of file MsppManager.cpp.

171  {
172  return m_msppDir.c_str();
173 }
IniFile * kome::core::MsppManager::getParameters ( void  )

gets parameters

Returns
parameters file object

Definition at line 282 of file MsppManager.cpp.

282  {
283  return m_params;
284 }
unsigned int kome::core::MsppManager::getPid ( )

gets the process ID

Returns
process ID

Definition at line 287 of file MsppManager.cpp.

287  {
288  return m_pid;
289 }
unsigned long m_pid
Definition: MsppManager.h:71
const char * kome::core::MsppManager::getPlatformName ( )

gets the platform name

Returns
platform name

Definition at line 82 of file MsppManager.cpp.

82  {
83  return m_platform.c_str();
84 }
std::string m_platform
Definition: MsppManager.h:77
std::vector< std::string > kome::core::MsppManager::getPluginDir ( )

get mspp plugin dir

Returns
plugins path

Definition at line 307 of file MsppManager.cpp.

307  {
308  return m_pluginPaths;
309 }
std::vector< std::string > m_pluginPaths
Definition: MsppManager.h:74
const char * kome::core::MsppManager::getRegName ( )

gets the registory name

Returns
gegistory name

Definition at line 87 of file MsppManager.cpp.

87  {
88  return m_reg.c_str();
89 }
const char * kome::core::MsppManager::getTmpDir ( )

gets temporary file directory name

Returns
temporary file directory name

Definition at line 181 of file MsppManager.cpp.

181  {
182  // check the member
183  if( m_pidTmpDir.empty() ) {
184  std::string pidStr = FMT( "%04x", m_pid );
185  m_pidTmpDir = getpath( m_tmpDir.c_str(), pidStr.c_str() );
186 
187  // make directory
188  if( !fileexists( m_pidTmpDir.c_str() ) ) {
189  makedirs( m_pidTmpDir.c_str() );
190  }
191  }
192 
193  return m_pidTmpDir.c_str();
194 }
bool makedirs(const char *path)
make directories
bool fileexists(const char *path)
judge whether file exists
unsigned long m_pid
Definition: MsppManager.h:71
std::string m_pidTmpDir
Definition: MsppManager.h:62
std::string getpath(const char *dir, const char *file)
get file path

Here is the call graph for this function:

std::string kome::core::MsppManager::getTmpFileName ( const char *  prefix,
const char *  suffix,
const char *  dir = NULL 
)

gets temporary file name

Parameters
[in]prefixprefix of temporary file name
[in]suffixsuffix of temporary file name
[in]dirdirectory name
Returns
temporary file name

Definition at line 197 of file MsppManager.cpp.

197  {
198  // file path
199  std::string path;
200  std::string fileName;
201  std::string d = NVL( dir, "" );
202 
203  // check directory
204  std::string tmpDir = getTmpDir();
205  if( tmpDir.empty() ) {
206  return path;
207  }
208 
209  // check directory
210  if( d.empty() ) {
211  d = tmpDir;
212  }
213  else if( !isabsolutepath( d.c_str() ) ) {
214  d = getpath( tmpDir.c_str(), d.c_str() );
215  makedirs( d.c_str() );
216  }
217 
218  // date
219  struct tm date;
220  time_t now;
221 
222  time( &now );
223 
224 #ifdef _MSC_VER
225  localtime_s( &date, &now );
226 #else
227  date = *( localtime( &now ) );
228 #endif
229 
230  // tempolary file path
231  long count = 0;
232  while( path.empty() && count >= 0 ) {
233  // file
234  fileName = FMT(
235  "%s%02d%02d%02d%04x%s",
236  prefix,
237  date.tm_mon + 1,
238  date.tm_mday,
239  date.tm_year % 100,
240  count,
241  suffix
242  );
243  for( unsigned int i = 0; i < fileName.length(); i++ ) {
244  char c = fileName[ i ];
245  if( c == '/' || c == '\\' || c == ':' || c == '?'
246  || c == '>' || c == '<' || c == '|' || c == ' '
247  || c == '\r' || c == '\t' || c == '\n' || c == ',' ) {
248  fileName[ i ] = '_';
249  }
250  }
251  std::string p = getabsolutepath( d.c_str(), fileName.c_str() );
252 
253  // check file
254  if( !fileexists( p.c_str() ) ) {
255  path = p;
256  }
257 
258  count++;
259  }
260 
261  LOG_TRACE( FMT( "Temporary File [%s]", path.c_str() ) );
262 
263  return fileName;
264 }
bool isabsolutepath(const char *file)
judges whether the specified file path is absolute file path or not.
bool makedirs(const char *path)
make directories
bool fileexists(const char *path)
judge whether file exists
std::string getabsolutepath(const char *dir, const char *file)
get absolute path
const char * getTmpDir()
gets temporary file directory name
#define NVL(checkVal, replaceVal)
Definition: CoreMacros.h:99
std::string getpath(const char *dir, const char *file)
get file path

Here is the call graph for this function:

const char * kome::core::MsppManager::getVersion ( )

gets Mass++ version

Returns
Mass++ version

Definition at line 92 of file MsppManager.cpp.

92  {
93  return m_version.c_str();
94 }
bool kome::core::MsppManager::isInitializedMATLAB ( void  )

gets MATLAB's initialized flag value

Returns
MATLAB's initialized flag value (true:already initialized,false:Uninitailize)

Definition at line 315 of file MsppManager.cpp.

316 {
317  return m_bInitializedMATLAB;
318 }
void kome::core::MsppManager::setIniFile ( IniFile ini)

sets ini file

Parameters
[in]iniini file

Definition at line 267 of file MsppManager.cpp.

267  {
268  m_ini = ini;
269 }
void kome::core::MsppManager::setParameters ( IniFile params)

sets parameters file

Parameters
[in]paramsparameters file

Definition at line 277 of file MsppManager.cpp.

277  {
278  m_params = params;
279 }

Member Data Documentation

std::string kome::core::MsppManager::m_app
protected

application name

Definition at line 44 of file MsppManager.h.

bool kome::core::MsppManager::m_bInitializedMATLAB
protected

initialized flag of MATLAB application

Definition at line 82 of file MsppManager.h.

std::string kome::core::MsppManager::m_confDir
protected

config directory

Definition at line 56 of file MsppManager.h.

IniFile* kome::core::MsppManager::m_ini
protected

ini file

Definition at line 65 of file MsppManager.h.

std::string kome::core::MsppManager::m_msppDir
protected

Mass++ directory

Definition at line 53 of file MsppManager.h.

IniFile* kome::core::MsppManager::m_params
protected

parameters file

Definition at line 68 of file MsppManager.h.

unsigned long kome::core::MsppManager::m_pid
protected

process

Definition at line 71 of file MsppManager.h.

std::string kome::core::MsppManager::m_pidTmpDir
protected

process temporary file directory

Definition at line 62 of file MsppManager.h.

std::string kome::core::MsppManager::m_platform
protected

platform name

Definition at line 77 of file MsppManager.h.

std::vector< std::string > kome::core::MsppManager::m_pluginPaths
protected

mspp plugin path

Definition at line 74 of file MsppManager.h.

std::string kome::core::MsppManager::m_reg
protected

registory name

Definition at line 47 of file MsppManager.h.

std::string kome::core::MsppManager::m_tmpDir
protected

temporary file directory

Definition at line 59 of file MsppManager.h.

std::string kome::core::MsppManager::m_version
protected

version

Definition at line 50 of file MsppManager.h.


The documentation for this class was generated from the following files: