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

operation management class More...

#include <OperationManager.h>

Classes

struct  OperationInfo
 operation information More...
 

Public Member Functions

void addOperation (Operation *operation)
 add managed operation More...
 
void removeOperation (Operation *operation)
 remove managed operation More...
 
unsigned int getNumberOfOperations ()
 gets the number of managed operation More...
 
OperationgetOperation (const unsigned int index)
 gets the managed operation More...
 
int getNumberOfFinishedOperations ()
 gets the number of finished operations More...
 
OperationgetFinishedOperation (int i)
 gets the finished operation. More...
 
int getNumberOfCanceledOperations ()
 gets the number of canceled operations More...
 
OperationgetCanceledOperation (int i)
 gets the canceled operation More...
 
const char * getUpdateDataFilePath (Operation *operation)
 the file path to save the update status More...
 
const char * getPreviousDataFilePath (Operation *operation)
 gets the file path to save the previous status More...
 
void moveToFinished (Operation *operation)
 moves the operation to the finished queue. More...
 
void movetoCanseled (Operation *operation)
 move the operation to the canceled queue. More...
 
void clearCanceledOperation ()
 clears canceled operations
 
void setState (const unsigned int index, int state)
 sets the operation stateus More...
 
int getState (const unsigned int index)
 gets the operation status More...
 
void setSaveCount (int count)
 set the save count More...
 
int getSaveCount ()
 get the save count More...
 
void setSaveCountFlg (const bool bSave)
 set the save count flag More...
 
bool getSaveCountFlg ()
 get the save count flag More...
 
void setSaveCancelFlg (const bool bCancel)
 set the save cancel flag More...
 
bool getSaveCancelFlg ()
 get the save cancel flag More...
 

Static Public Member Functions

static OperationManagergetInstance ()
 get operation manager object (This is the only object.) More...
 

Protected Types

enum  OperationState { TYPE_NONE = 5, TYPE_FINISH = 0, TYPE_CANCEL = 1 }
 the operation state type of array
 

Protected Member Functions

 OperationManager ()
 constructor
 
virtual ~OperationManager ()
 destructor
 

Protected Attributes

std::string m_updateFilePath
 
std::string m_prevFilePath
 
std::vector< OperationInfom_operations
 
int m_saveCount
 
bool m_saveFlg
 
bool m_cancelFlg
 

Detailed Description

operation management class

Definition at line 28 of file OperationManager.h.

Member Function Documentation

void kome::operation::OperationManager::addOperation ( Operation operation)

add managed operation

Parameters
[in]operationOperation object

Definition at line 45 of file OperationManager.cpp.

45  {
46  if( operation == NULL ){
47  return;
48  }
49 
50  for( unsigned int i=0; i < m_operations.size(); i++ ){
51  if( m_operations[i].operation == operation ){
52  return;
53  }
54  }
55  // operation info
56  OperationInfo optInf;
57  optInf.operation = operation;
58  optInf.iState = TYPE_NONE;
59 
60  m_operations.push_back( optInf );
61 }
#define NULL
Definition: CoreMacros.h:18
std::vector< OperationInfo > m_operations
Operation * kome::operation::OperationManager::getCanceledOperation ( int  i)

gets the canceled operation

Parameters
[in]icanceled operation index
Returns
canceled operation

Definition at line 129 of file OperationManager.cpp.

129  {
130  std::vector<Operation*> opt;
131  for( unsigned int i=0; i < m_operations.size(); i++ ){
132  if( m_operations[i].iState == TYPE_CANCEL ){ // cansel
133  opt.push_back( m_operations[i].operation );
134  }
135  }
136 
137  if( index > (int)opt.size() || index <= -1 ){
138  return NULL;
139  }
140  return opt[index];
141 }
#define NULL
Definition: CoreMacros.h:18
std::vector< OperationInfo > m_operations
Operation * kome::operation::OperationManager::getFinishedOperation ( int  i)

gets the finished operation.

Parameters
[in]ifinished operation index
Returns
finished operation

Definition at line 103 of file OperationManager.cpp.

103  {
104  std::vector<Operation*> opt;
105  for( unsigned i=0; i < m_operations.size(); i++ ){
106  if( m_operations[i].iState == TYPE_FINISH ){ // finish
107  opt.push_back( m_operations[i].operation );
108  }
109  }
110 
111  if( index > (int)opt.size() || index <= -1 ){
112  return NULL;
113  }
114  return opt[index];
115 }
#define NULL
Definition: CoreMacros.h:18
std::vector< OperationInfo > m_operations
static OperationManager & kome::operation::OperationManager::getInstance ( )
static

get operation manager object (This is the only object.)

Returns
operation manager object

Definition at line 289 of file OperationManager.cpp.

289  {
290  // create the only object
291  static OperationManager plgMgr;
292 
293  return plgMgr;
294 }
operation management class
int kome::operation::OperationManager::getNumberOfCanceledOperations ( )

gets the number of canceled operations

Returns
the number of canceled operations

Definition at line 118 of file OperationManager.cpp.

118  {
119  int inum = 0;
120  for( unsigned int i=0; i < m_operations.size(); i++ ){
121  if( m_operations[i].iState == TYPE_CANCEL ){ // cansel
122  inum++;
123  }
124  }
125  return inum;
126 }
std::vector< OperationInfo > m_operations
int kome::operation::OperationManager::getNumberOfFinishedOperations ( )

gets the number of finished operations

Returns
the number of finished operations

Definition at line 92 of file OperationManager.cpp.

92  {
93  int inum = 0;
94  for( unsigned int i=0; i < m_operations.size(); i++ ){
95  if( m_operations[i].iState == TYPE_FINISH ){ // finish
96  inum++;
97  }
98  }
99  return inum;
100 }
std::vector< OperationInfo > m_operations
unsigned int kome::operation::OperationManager::getNumberOfOperations ( )

gets the number of managed operation

Returns
the number of operations

Definition at line 79 of file OperationManager.cpp.

79  {
80  return m_operations.size();
81 }
std::vector< OperationInfo > m_operations
Operation * kome::operation::OperationManager::getOperation ( const unsigned int  index)

gets the managed operation

Parameters
[in]indexmanaged operation index
Returns
managed operation

Definition at line 84 of file OperationManager.cpp.

84  {
85  if( i >= m_operations.size() ){
86  return NULL;
87  }
88  return m_operations[i].operation;
89 }
#define NULL
Definition: CoreMacros.h:18
std::vector< OperationInfo > m_operations
const char * kome::operation::OperationManager::getPreviousDataFilePath ( Operation operation)

gets the file path to save the previous status

Parameters
[in]operationoperation
Returns
the file path to save the previous status

Definition at line 170 of file OperationManager.cpp.

170  {
171  // Manager
173 
174  // Operation Folder
175  std::string folderName = "Operation";
176  std::string operatFolder = getpath( msppMgr.getTmpDir(), folderName.c_str() );
177 
178  if( !fileexists( operatFolder.c_str() ) ){
179  makedirectory( operatFolder.c_str() );
180  }
181 
182  m_prevFilePath = operation->getPrevFilePath();
183  // 一致するファイルがない場合は新規作成
184  if( !fileexists( m_prevFilePath.c_str()) ){
185  // file name ( not path )
186  std::string strName = operation->getOperationName();
187  strName = "PrevPath" + strName ;
188 
189  std::string datFile = msppMgr.getTmpFileName( strName.c_str(), ".dat", folderName.c_str() );
190  m_prevFilePath = getpath( operatFolder.c_str(), datFile.c_str() );
191  }
192 
193  return m_prevFilePath.c_str();
194 }
static MsppManager & getInstance()
gets MsppManager object (This is the only object.)
Mass++ manager class.
Definition: MsppManager.h:28
std::string getPrevFilePath()
gets previouse data file path
Definition: Operation.cpp:175
bool fileexists(const char *path)
judge whether file exists
const char * getTmpDir()
gets temporary file directory name
bool makedirectory(const char *path)
creates directory
const char * getOperationName()
gets operation name
Definition: Operation.cpp:53
std::string getTmpFileName(const char *prefix, const char *suffix, const char *dir=NULL)
gets temporary file name
std::string getpath(const char *dir, const char *file)
get file path

Here is the call graph for this function:

bool kome::operation::OperationManager::getSaveCancelFlg ( )
inline

get the save cancel flag

Returns
cancel flag

Definition at line 238 of file OperationManager.h.

int kome::operation::OperationManager::getSaveCount ( )
inline

get the save count

Returns
save count

Definition at line 210 of file OperationManager.h.

bool kome::operation::OperationManager::getSaveCountFlg ( )
inline

get the save count flag

Returns
save flag

Definition at line 224 of file OperationManager.h.

int kome::operation::OperationManager::getState ( const unsigned int  index)

gets the operation status

Parameters
[in]index
Returns
operation status

Definition at line 281 of file OperationManager.cpp.

281  {
282  if( index >= m_operations.size() ){
283  return -1;
284  }
285  return m_operations[index].iState;
286 }
std::vector< OperationInfo > m_operations
const char * kome::operation::OperationManager::getUpdateDataFilePath ( Operation operation)

the file path to save the update status

Parameters
[in]operationoperation
Returns
file path to save the update status

Definition at line 144 of file OperationManager.cpp.

144  {
145  // Manager
147 
148  // Operation Folder
149  std::string folderName = "Operation";
150  std::string operatFolder = getpath( msppMgr.getTmpDir(), folderName.c_str() );
151 
152  if( !fileexists( operatFolder.c_str() ) ){
153  makedirectory( operatFolder.c_str() );
154  }
155 
156  m_updateFilePath = operation->getUpdateFilePath();
157  if( !fileexists( m_updateFilePath.c_str() ) ){
158  // file name ( not path )
159  std::string strName = operation->getOperationName();
160  strName = "UpdatePath" + strName ;
161 
162  std::string datFile = msppMgr.getTmpFileName( strName.c_str(), ".dat", folderName.c_str() );
163  m_updateFilePath = getpath( operatFolder.c_str(), datFile.c_str() );
164  }
165 
166  return m_updateFilePath.c_str();
167 }
static MsppManager & getInstance()
gets MsppManager object (This is the only object.)
Mass++ manager class.
Definition: MsppManager.h:28
bool fileexists(const char *path)
judge whether file exists
const char * getTmpDir()
gets temporary file directory name
std::string getUpdateFilePath()
gets udate data file path
Definition: Operation.cpp:185
bool makedirectory(const char *path)
creates directory
const char * getOperationName()
gets operation name
Definition: Operation.cpp:53
std::string getTmpFileName(const char *prefix, const char *suffix, const char *dir=NULL)
gets temporary file name
std::string getpath(const char *dir, const char *file)
get file path

Here is the call graph for this function:

void kome::operation::OperationManager::movetoCanseled ( Operation operation)

move the operation to the canceled queue.

Parameters
[in]operationoperation to be moved.

Definition at line 220 of file OperationManager.cpp.

220  {
221  for( unsigned int i=0; i < m_operations.size(); i++ ){
222  if( m_operations[i].operation == operation ){
223  m_operations[i].iState = TYPE_CANCEL;
224 
225  SendStatusToList();
226 
227  return;
228  }
229  }
230 
231  // operation inofo
232  OperationInfo optInf;
233  optInf.iState = TYPE_CANCEL;
234  optInf.operation = operation;
235 
236  m_operations.push_back( optInf );
237 
238  // リストの更新処理
239  SendStatusToList();
240 }
std::vector< OperationInfo > m_operations
void kome::operation::OperationManager::moveToFinished ( Operation operation)

moves the operation to the finished queue.

Parameters
[in]operationoperation to be moved

Definition at line 197 of file OperationManager.cpp.

197  {
198  for( unsigned int i=0; i < m_operations.size(); i++ ){
199  if( m_operations[i].operation == operation ){
200  m_operations[i].iState = TYPE_FINISH;
201 
202  SendStatusToList();
203 
204  return;
205  }
206  }
207 
208  // operation info
209  OperationInfo optInf;
210  optInf.iState = TYPE_FINISH;
211  optInf.operation = operation;
212 
213  m_operations.push_back( optInf );
214 
215  // リストの更新処理
216  SendStatusToList();
217 }
std::vector< OperationInfo > m_operations
void kome::operation::OperationManager::removeOperation ( Operation operation)

remove managed operation

Parameters
[in]operationoperation object

Definition at line 64 of file OperationManager.cpp.

64  {
65  int i = m_operations.size()-1;
66  while( i > -1 ){
67  Operation* opt = m_operations[i].operation;
68  if( opt == operation ){
69  m_operations.erase( m_operations.begin() + i );
70  // リストの更新処理
71  SendStatusToList();
72  return;
73  }
74  i--;
75  }
76 }
Operation information class.
Definition: Operation.h:22
std::vector< OperationInfo > m_operations
void kome::operation::OperationManager::setSaveCancelFlg ( const bool  bCancel)
inline

set the save cancel flag

Parameters
bCancelcancel flag

Definition at line 231 of file OperationManager.h.

void kome::operation::OperationManager::setSaveCount ( int  count)
inline

set the save count

Parameters
count

Definition at line 203 of file OperationManager.h.

void kome::operation::OperationManager::setSaveCountFlg ( const bool  bSave)
inline

set the save count flag

Parameters
bSave

Definition at line 217 of file OperationManager.h.

void kome::operation::OperationManager::setState ( const unsigned int  index,
int  state 
)

sets the operation stateus

Parameters
[in]index
[in]stateoperation status

Definition at line 272 of file OperationManager.cpp.

272  {
273  if( index >= m_operations.size() ){
274  return;
275  }
276 
277  m_operations[index].iState = state;
278 }
std::vector< OperationInfo > m_operations

Member Data Documentation

bool kome::operation::OperationManager::m_cancelFlg
protected

cancel flg

Definition at line 78 of file OperationManager.h.

std::vector<OperationInfo> kome::operation::OperationManager::m_operations
protected

operation infomation array

Definition at line 69 of file OperationManager.h.

std::string kome::operation::OperationManager::m_prevFilePath
protected

previous file path

Definition at line 47 of file OperationManager.h.

int kome::operation::OperationManager::m_saveCount
protected

save count

Definition at line 72 of file OperationManager.h.

bool kome::operation::OperationManager::m_saveFlg
protected

save count flg

Definition at line 75 of file OperationManager.h.

std::string kome::operation::OperationManager::m_updateFilePath
protected

update file path

Definition at line 44 of file OperationManager.h.


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