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

Operation information class. More...

#include <Operation.h>

Collaboration diagram for kome::operation::Operation:
Collaboration graph
[legend]

Public Types

enum  OperationType {
  TYPE_STANDARD = 0, TYPE_GUI = 1, TYPE_INPUT = 2, TYPE_OUTPUT = 4,
  TYPE_AUTO = 8
}
 operation type
 

Public Member Functions

 Operation ()
 constructor
 
virtual ~Operation ()
 destructor
 
void setOperationName (const char *operationName)
 sets operation name More...
 
const char * getOperationName ()
 gets operation name More...
 
void setShortName (const char *shortName)
 sets short name More...
 
const char * getShortName ()
 gets short name More...
 
void setOperationType (int type)
 sets operation type More...
 
int getOperationType ()
 gets operation type More...
 
void setDescription (const char *description)
 sets description More...
 
const char * getDescription ()
 gets description More...
 
void setTargetSample (kome::objects::Sample *sample)
 sets target sample objects More...
 
kome::objects::SamplegetTargetSample ()
 gets target sample objects More...
 
void setParametersString (const char *parameter)
 sets parameters string More...
 
const char * getParametersString ()
 gets operaton parameters string More...
 
void loadCondition (boost::function< int(void *, int) > readFun)
 load the saved state with operations More...
 
void saveCondition (boost::function< int(void *, int) > writeFun)
 save the current state with engine operations More...
 
bool execute ()
 execute operation More...
 
std::string getPrevFilePath ()
 gets previouse data file path More...
 
void setPrevFilePath (const char *strPath)
 sets previouse data file path More...
 
std::string getUpdateFilePath ()
 gets udate data file path More...
 
void setUpdateFilePath (const char *strPath)
 sets udate data file path More...
 
void removeOperation (Operation *opt)
 remove operation More...
 

Protected Member Functions

virtual std::string onGetDescription ()=0
 get discription More...
 
virtual std::string onGetParametersString ()=0
 get parameters string More...
 
virtual void onSetParametersString (const char *strParam)=0
 set parameters string More...
 
virtual void onLoadCondition (boost::function< int(void *, int) > readFun)=0
 load the saved state with respect to to search engine operations More...
 
virtual void onSaveCondition (boost::function< int(void *, int) > writeFun)=0
 save the current state with respect to search engine operations More...
 
virtual bool onExecute ()=0
 execute operation More...
 

Protected Attributes

std::string m_operatName
 
std::string m_shortName
 
int m_type
 
std::string m_descript
 
kome::objects::Samplem_targetSample
 
std::string m_paramString
 
std::string m_prevPath
 
std::string m_updatePath
 

Detailed Description

Operation information class.

Definition at line 22 of file Operation.h.

Member Function Documentation

bool kome::operation::Operation::execute ( )

execute operation

Returns
If true, it succeeded to perform search.

Definition at line 126 of file Operation.cpp.

126  {
127  bool ret = false;
128 
130  if( getOperationType() == Operation::TYPE_INPUT ||
131  getOperationType() == Operation::TYPE_OUTPUT ){
132 
133  // execute
134  ret = onExecute();
135  }else{
136  // -----
137  // Undo
138  // -----
139  m_prevPath = optMgr.getPreviousDataFilePath( this );
140  FILE* prevfp = fileopen( m_prevPath.c_str(), "wb" );
141 
142  kome::core::FileAccessor prev_acc( prevfp );
143  saveCondition( boost::bind( &kome::core::DataAccessor::write, &prev_acc, _1, _2 ) );
144 
145  fclose( prevfp );
146 
147  // Previous Data File Path
148  setPrevFilePath( m_prevPath.c_str() );
149 
150  // execute
151  ret = onExecute();
152 
153  // -----
154  // Redo
155  // -----
156  m_updatePath = optMgr.getUpdateDataFilePath( this );
157  FILE* updatefp = fileopen( m_updatePath.c_str(), "wb" );
158 
159  kome::core::FileAccessor update_acc( updatefp );
160  saveCondition( boost::bind( &kome::core::DataAccessor::write, &update_acc, _1, _2 ) );
161 
162  fclose( updatefp );
163 
164  // Update Data File Path
165  setUpdateFilePath( m_updatePath.c_str() );
166  }
167  if( ret ){
168  // Finished
169  optMgr.moveToFinished( this );
170  }
171  return ret;
172 }
file accessor class
Definition: FileAccessor.h:26
void moveToFinished(Operation *operation)
moves the operation to the finished queue.
static OperationManager & getInstance()
get operation manager object (This is the only object.)
const char * getPreviousDataFilePath(Operation *operation)
gets the file path to save the previous status
virtual bool onExecute()=0
execute operation
int getOperationType()
gets operation type
Definition: Operation.cpp:73
void setPrevFilePath(const char *strPath)
sets previouse data file path
Definition: Operation.cpp:180
void saveCondition(boost::function< int(void *, int) > writeFun)
save the current state with engine operations
Definition: Operation.cpp:121
std::string m_updatePath
Definition: Operation.h:59
FILE * fileopen(const char *path, const char *mode)
opens file
virtual int write(void *addr, int size)=0
writes data (abstract method)
void setUpdateFilePath(const char *strPath)
sets udate data file path
Definition: Operation.cpp:190
const char * getUpdateDataFilePath(Operation *operation)
the file path to save the update status
operation management class

Here is the call graph for this function:

const char * kome::operation::Operation::getDescription ( )

gets description

Returns
operaton description

Definition at line 83 of file Operation.cpp.

83  {
84  if( m_descript.empty() ){ // @date 2013.09.17 <Mod> M.Izumi
86  }
87  return m_descript.c_str();
88 }
virtual std::string onGetDescription()=0
get discription

Here is the call graph for this function:

const char * kome::operation::Operation::getOperationName ( )

gets operation name

Returns
operation name

Definition at line 53 of file Operation.cpp.

53  {
54  return m_operatName.c_str();
55 }
std::string m_operatName
Definition: Operation.h:38
int kome::operation::Operation::getOperationType ( )

gets operation type

Returns
operaton type

Definition at line 73 of file Operation.cpp.

73  {
74  return m_type;
75 }
const char * kome::operation::Operation::getParametersString ( )

gets operaton parameters string

Returns
operaton parameters string

Definition at line 106 of file Operation.cpp.

106  {
107  m_paramString = "";
108  m_paramString = "\"";
110  m_paramString +="\"";
111 
112  return m_paramString.c_str();
113 }
virtual std::string onGetParametersString()=0
get parameters string
std::string m_paramString
Definition: Operation.h:53

Here is the call graph for this function:

std::string kome::operation::Operation::getPrevFilePath ( )

gets previouse data file path

Returns
previouse data file path

Definition at line 175 of file Operation.cpp.

175  {
176  return m_prevPath;
177 }
const char * kome::operation::Operation::getShortName ( )

gets short name

Returns
short name

Definition at line 63 of file Operation.cpp.

63  {
64  return m_shortName.c_str();
65 }
kome::objects::Sample * kome::operation::Operation::getTargetSample ( )

gets target sample objects

Returns
target sample objects

Definition at line 96 of file Operation.cpp.

96  {
97  return m_targetSample;
98 }
kome::objects::Sample * m_targetSample
Definition: Operation.h:50
std::string kome::operation::Operation::getUpdateFilePath ( )

gets udate data file path

Returns
udate data file path

Definition at line 185 of file Operation.cpp.

185  {
186  return m_updatePath;
187 }
std::string m_updatePath
Definition: Operation.h:59
void kome::operation::Operation::loadCondition ( boost::function< int(void *, int) >  readFun)

load the saved state with operations

Parameters
[in]readFunfunction to read saved state

Definition at line 116 of file Operation.cpp.

116  {
117  onLoadCondition( readFun );
118 }
virtual void onLoadCondition(boost::function< int(void *, int) > readFun)=0
load the saved state with respect to to search engine operations

Here is the call graph for this function:

bool kome::operation::Operation::onExecute ( )
protectedpure virtual

execute operation

Returns
If true, it succeeded to perform search.
std::string kome::operation::Operation::onGetDescription ( )
protectedpure virtual

get discription

Returns
discription
std::string kome::operation::Operation::onGetParametersString ( )
protectedpure virtual

get parameters string

Returns
parameters string
void kome::operation::Operation::onLoadCondition ( boost::function< int(void *, int) >  readFun)
protectedpure virtual

load the saved state with respect to to search engine operations

Parameters
[in]readFunfunction to read saved state
void kome::operation::Operation::onSaveCondition ( boost::function< int(void *, int) >  writeFun)
protectedpure virtual

save the current state with respect to search engine operations

Parameters
[in]writeFunfunction to save state
void kome::operation::Operation::onSetParametersString ( const char *  strParam)
protectedpure virtual

set parameters string

Parameters
[in]strParamparameters string
void kome::operation::Operation::removeOperation ( Operation opt)

remove operation

Parameters
[in]optdelete operation
void kome::operation::Operation::saveCondition ( boost::function< int(void *, int) >  writeFun)

save the current state with engine operations

Parameters
[in]writeFunfunction to save state

Definition at line 121 of file Operation.cpp.

121  {
122  onSaveCondition( writeFun );
123 }
virtual void onSaveCondition(boost::function< int(void *, int) > writeFun)=0
save the current state with respect to search engine operations

Here is the call graph for this function:

void kome::operation::Operation::setDescription ( const char *  description)

sets description

Parameters
[in]descriptionoperaton description

Definition at line 78 of file Operation.cpp.

78  {
79  m_descript = description;
80 }
void kome::operation::Operation::setOperationName ( const char *  operationName)

sets operation name

Parameters
[in]operationNameoperation name

Definition at line 48 of file Operation.cpp.

48  {
49  m_operatName = operationName;
50 }
std::string m_operatName
Definition: Operation.h:38
void kome::operation::Operation::setOperationType ( int  type)

sets operation type

Parameters
[in]typeoperaton type

Definition at line 68 of file Operation.cpp.

68  {
69  m_type = type;
70 }
void kome::operation::Operation::setParametersString ( const char *  parameter)

sets parameters string

Parameters
[in]parameterparameters string

Definition at line 101 of file Operation.cpp.

101  {
102  onSetParametersString( parameter );
103 }
virtual void onSetParametersString(const char *strParam)=0
set parameters string

Here is the call graph for this function:

void kome::operation::Operation::setPrevFilePath ( const char *  strPath)

sets previouse data file path

Parameters
[in]strPathpreviouse data file path

Definition at line 180 of file Operation.cpp.

180  {
181  m_prevPath = strPath;
182 }
void kome::operation::Operation::setShortName ( const char *  shortName)

sets short name

Parameters
[in]shortNameshort name

Definition at line 58 of file Operation.cpp.

58  {
59  m_shortName = shortName;
60 }
void kome::operation::Operation::setTargetSample ( kome::objects::Sample sample)

sets target sample objects

Parameters
[in]sampletarget sample objects

Definition at line 91 of file Operation.cpp.

91  {
92  m_targetSample = sample;
93 }
kome::objects::Sample * m_targetSample
Definition: Operation.h:50
void kome::operation::Operation::setUpdateFilePath ( const char *  strPath)

sets udate data file path

Parameters
[in]strPathupdate data file path

Definition at line 190 of file Operation.cpp.

190  {
191  m_updatePath = strPath;
192 }
std::string m_updatePath
Definition: Operation.h:59

Member Data Documentation

std::string kome::operation::Operation::m_descript
protected

descript

Definition at line 47 of file Operation.h.

std::string kome::operation::Operation::m_operatName
protected

operation name

Definition at line 38 of file Operation.h.

std::string kome::operation::Operation::m_paramString
protected

parameter string

Definition at line 53 of file Operation.h.

std::string kome::operation::Operation::m_prevPath
protected

previouse data file path

Definition at line 56 of file Operation.h.

std::string kome::operation::Operation::m_shortName
protected

short name

Definition at line 41 of file Operation.h.

kome::objects::Sample* kome::operation::Operation::m_targetSample
protected

target sample

Definition at line 50 of file Operation.h.

int kome::operation::Operation::m_type
protected

operation type

Definition at line 44 of file Operation.h.

std::string kome::operation::Operation::m_updatePath
protected

update data file path

Definition at line 59 of file Operation.h.


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