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

alignment class More...

#include <BatchAnalysis.h>

Public Member Functions

 BatchAnalysis (const char *analysisName)
 constructor More...
 
virtual ~BatchAnalysis ()
 destructor
 
void clearFileProperties ()
 clears file propertyes
 
int addFileProperty (const char *prop)
 adds file property More...
 
unsigned int getNumberOfFileProperties ()
 gets the number of file properties More...
 
const char * getFileProperty (const unsigned int idx)
 gets the file property More...
 
kome::plugin::SettingsPage * getFilesPage ()
 gets the files page More...
 
void getFiles (kome::objects::SettingParameterValues *settings, std::vector< std::pair< std::string, kome::core::Properties > > &files)
 gets files More...
 
kome::plugin::SettingsPage * getParametersPage ()
 gets the parameters page More...
 
void analyze (std::vector< std::string > &paths, kome::core::Progress &progress)
 analyzes More...
 
void showResult ()
 shows analysis result
 

Protected Member Functions

virtual void onCreateFilesPage (kome::plugin::ParameterSettings &params, kome::plugin::SettingsPage &page)
 creates files page More...
 
virtual void onGetFiles (kome::objects::SettingParameterValues *settings, std::vector< std::pair< std::string, kome::core::Properties > > &files)
 This method is called form the getFiles method. More...
 
virtual void onCreateParametersPage (kome::plugin::ParameterSettings &params, kome::plugin::SettingsPage &page)
 creates parameters More...
 
virtual void onPrepareAnalysis (std::vector< std::string > &paths, kome::core::Progress &progress)=0
 on prepares analysis More...
 
virtual void onAnalyze (const char *path, kome::core::Progress &progress)=0
 on analyze More...
 
virtual void onFinishAnalysis (kome::core::Progress &progress)=0
 on finish analysis More...
 
virtual void onShowResult ()=0
 shows analysis result
 

Static Protected Member Functions

static void getFiles (const char *dir, std::vector< std::pair< std::string, kome::core::Properties > > &files)
 gets files More...
 

Protected Attributes

std::string m_name
 
std::vector< std::string > m_fileProperties
 
kome::plugin::ParameterSettings m_params
 
kome::plugin::SettingsPage * m_filesPage
 
kome::plugin::SettingsPage * m_parametersPage
 

Static Protected Attributes

static const char * FILE_NAME_PROP_NAME = "File Name"
 
static const char * DIR_PARAM_NAME = "dir"
 

Detailed Description

alignment class

Definition at line 24 of file BatchAnalysis.h.

Constructor & Destructor Documentation

kome::operation::BatchAnalysis::BatchAnalysis ( const char *  analysisName)

constructor

Parameters
[in]analysisNameanalysis name

Definition at line 36 of file BatchAnalysis.cpp.

36  : m_params( NULL, false ) {
37  // initialize
38  m_name = NVL( analysisName, "" );
39  m_filesPage = NULL;
41 
42  // add file name property
44 }
int addFileProperty(const char *prop)
adds file property
kome::plugin::SettingsPage * m_parametersPage
Definition: BatchAnalysis.h:53
kome::plugin::SettingsPage * m_filesPage
Definition: BatchAnalysis.h:50
#define NVL(checkVal, replaceVal)
Definition: CoreMacros.h:99
#define NULL
Definition: CoreMacros.h:18
static const char * FILE_NAME_PROP_NAME
Definition: BatchAnalysis.h:57
kome::plugin::ParameterSettings m_params
Definition: BatchAnalysis.h:47

Here is the call graph for this function:

Member Function Documentation

int kome::operation::BatchAnalysis::addFileProperty ( const char *  prop)

adds file property

Parameters
[in]propfile property
Returns
file property index

Definition at line 56 of file BatchAnalysis.cpp.

56  {
57  int idx = (int)m_fileProperties.size();
58  m_fileProperties.push_back( NVL( prop, "" ) );
59  return idx;
60 }
#define NVL(checkVal, replaceVal)
Definition: CoreMacros.h:99
std::vector< std::string > m_fileProperties
Definition: BatchAnalysis.h:44
void kome::operation::BatchAnalysis::analyze ( std::vector< std::string > &  paths,
kome::core::Progress Progress 
)

analyzes

Parameters
[in]pathsfile paths
[out]progressthe object to show progress

Definition at line 135 of file BatchAnalysis.cpp.

135  {
136  // subprogresses
137  progress.createSubProgresses( paths.size() + 2 );
138 
139  // preparation
140  int progressIdx = 0;
141  kome::core::Progress* subProgress = progress.getSubProgress( progressIdx );
142  progressIdx++;
143  progress.setStatus( "Preparation..." );
144  onPrepareAnalysis( paths, *subProgress );
145  if( progress.isStopped() ) {
146  return;
147  }
148  subProgress->fill();
149 
150  // analyze each file
151  for( unsigned int i = 0; i < paths.size() && !progress.isStopped(); i++ ) { // each file
152  // progress
153  std::string message = FMT( "Analyzing ... [%d/%d]", ( i + 1 ), paths.size() );
154  progress.setStatus( message.c_str() );
155  subProgress = progress.getSubProgress( progressIdx );
156  progressIdx++;
157 
158  // analyze
159  onAnalyze( paths[ i ].c_str(), *subProgress );
160  subProgress->fill();
161  }
162  if( progress.isStopped() ) {
163  return;
164  }
165 
166  // post analysis
167  subProgress = progress.getSubProgress( progressIdx );
168  progress.setStatus( "Finalizing..." );
169  onFinishAnalysis( *subProgress );
170 
171  if( !progress.isStopped() ) {
172  progress.fill();
173  }
174 }
virtual void onFinishAnalysis(kome::core::Progress &progress)=0
on finish analysis
void fill()
sets end position
Definition: Progress.cpp:206
Progress * getSubProgress(const unsigned int idx)
gets subprogress
Definition: Progress.cpp:331
virtual void onAnalyze(const char *path, kome::core::Progress &progress)=0
on analyze
progress display abstract class
Definition: Progress.h:31
virtual void onPrepareAnalysis(std::vector< std::string > &paths, kome::core::Progress &progress)=0
on prepares analysis
void setStatus(const char *status, const bool bForced=false)
sets status
Definition: Progress.cpp:160

Here is the call graph for this function:

const char * kome::operation::BatchAnalysis::getFileProperty ( const unsigned int  idx)

gets the file property

Parameters
[in]propertyindex
Returns
file property

Definition at line 68 of file BatchAnalysis.cpp.

68  {
69  if( idx < 0 || idx >= (int)m_fileProperties.size() ) {
70  return NULL;
71  }
72  return m_fileProperties[ idx ].c_str();
73 }
#define NULL
Definition: CoreMacros.h:18
std::vector< std::string > m_fileProperties
Definition: BatchAnalysis.h:44
void kome::operation::BatchAnalysis::getFiles ( kome::objects::SettingParameterValues settings,
std::vector< std::pair< std::string, kome::core::Properties > > &  files 
)

gets files

Parameters
[in]settingsparameters
[out]pathsthe array to store file paths.

Definition at line 87 of file BatchAnalysis.cpp.

87  {
88  onGetFiles( settings, files );
89 }
virtual void onGetFiles(kome::objects::SettingParameterValues *settings, std::vector< std::pair< std::string, kome::core::Properties > > &files)
This method is called form the getFiles method.

Here is the call graph for this function:

static void kome::operation::BatchAnalysis::getFiles ( const char *  dir,
std::vector< std::pair< std::string, kome::core::Properties > > &  files 
)
staticprotected

gets files

Parameters
[in]dirdirectory
[out]filesthe array to store file informations

Definition at line 187 of file BatchAnalysis.cpp.

187  {
188  // path
189  boost::filesystem::path p( dir, boost::filesystem::native );
190 
191  // store
192  if( boost::filesystem::is_directory( p ) ) { // directory
193  boost::filesystem::directory_iterator end;
194  for( boost::filesystem::directory_iterator it( p ); it != end; it++ ) { // each child
195  boost::filesystem::path child = (*it);
196  getFiles( boost::filesystem::absolute( child ).string().c_str(), files );
197  }
198  }
199  else { // file
200  files.resize( files.size() + 1 );
201  files.back().first = boost::filesystem::absolute( p ).string();
202  files.back().second.setValue( FILE_NAME_PROP_NAME, p.leaf().string().c_str() );
203  }
204 }
void getFiles(kome::objects::SettingParameterValues *settings, std::vector< std::pair< std::string, kome::core::Properties > > &files)
gets files
static const char * FILE_NAME_PROP_NAME
Definition: BatchAnalysis.h:57

Here is the call graph for this function:

kome::plugin::SettingsPage * kome::operation::BatchAnalysis::getFilesPage ( )

gets the files page

Returns
files page

Definition at line 76 of file BatchAnalysis.cpp.

76  {
77  // create page
78  if( m_filesPage == NULL ) {
79  m_filesPage = new kome::plugin::SettingsPage( m_params );
81  }
82 
83  return m_filesPage;
84 }
virtual void onCreateFilesPage(kome::plugin::ParameterSettings &params, kome::plugin::SettingsPage &page)
creates files page
kome::plugin::SettingsPage * m_filesPage
Definition: BatchAnalysis.h:50
#define NULL
Definition: CoreMacros.h:18
kome::plugin::ParameterSettings m_params
Definition: BatchAnalysis.h:47

Here is the call graph for this function:

unsigned int kome::operation::BatchAnalysis::getNumberOfFileProperties ( )

gets the number of file properties

Returns
the number of file properties

Definition at line 63 of file BatchAnalysis.cpp.

63  {
64  return m_fileProperties.size();
65 }
std::vector< std::string > m_fileProperties
Definition: BatchAnalysis.h:44
kome::plugin::SettingsPage * kome::operation::BatchAnalysis::getParametersPage ( )

gets the parameters page

Returns
parameters page

Definition at line 92 of file BatchAnalysis.cpp.

92  {
93  // create page
94  if( m_parametersPage == NULL ) {
95  m_parametersPage = new kome::plugin::SettingsPage( m_params );
97  }
98 
99  return m_parametersPage;
100 }
kome::plugin::SettingsPage * m_parametersPage
Definition: BatchAnalysis.h:53
#define NULL
Definition: CoreMacros.h:18
virtual void onCreateParametersPage(kome::plugin::ParameterSettings &params, kome::plugin::SettingsPage &page)
creates parameters
kome::plugin::ParameterSettings m_params
Definition: BatchAnalysis.h:47

Here is the call graph for this function:

void kome::operation::BatchAnalysis::onAnalyze ( const char *  path,
kome::core::Progress progress 
)
protectedpure virtual

on analyze

Parameters
[in]pathfile path
[out]progressthe object to show the progress
void kome::operation::BatchAnalysis::onCreateFilesPage ( kome::plugin::ParameterSettings &  params,
kome::plugin::SettingsPage &  page 
)
protectedvirtual

creates files page

Parameters
[out]paramsparameters information
[out]pagepage

Definition at line 103 of file BatchAnalysis.cpp.

103  {
104  // value
105  kome::plugin::SettingsValue* value = params.addValue();
106  value->setType( kome::plugin::SettingsValue::TYPE_DIR );
107  value->setRequired( true );
108 
109  // parameter
110  kome::plugin::SettingsParam* param = params.addParam();
111  param->setSection( FMT( "Batch Analysis (%s)", m_name.c_str() ).c_str() );
112  param->setKey( "DIR" );
113  param->setName( DIR_PARAM_NAME );
114 
115  // form
116  kome::plugin::SettingsForm* form = page.addForm();
117  form->setTitle( "Directory" );
118  form->setParam( param );
119  form->setDesc( "Select the data folder." );
120 }
static const char * DIR_PARAM_NAME
Definition: BatchAnalysis.h:60
void kome::operation::BatchAnalysis::onCreateParametersPage ( kome::plugin::ParameterSettings &  params,
kome::plugin::SettingsPage &  page 
)
protectedvirtual

creates parameters

Parameters
[out]paramsparameters information
[out]pagepage

Definition at line 182 of file BatchAnalysis.cpp.

182  {
183  LOG_WARN( FMT( "This method is underconstruction. Please implement onCreateParametersPage method in the subclass of BatchAnalysis." ) );
184 }
void kome::operation::BatchAnalysis::onFinishAnalysis ( kome::core::Progress progress)
protectedpure virtual

on finish analysis

Parameters
[out]progressthe object to show the progress
void kome::operation::BatchAnalysis::onGetFiles ( kome::objects::SettingParameterValues settings,
std::vector< std::pair< std::string, kome::core::Properties > > &  files 
)
protectedvirtual

This method is called form the getFiles method.

Parameters
[in]settingsparameters
[out]filesthe array to store file informations

Definition at line 123 of file BatchAnalysis.cpp.

123  {
124  // directory
125  std::string dir = settings->getParameterValue( DIR_PARAM_NAME );
126  if( dir.empty() ) {
127  return;
128  }
129 
130  // get files
131  getFiles( dir.c_str(), files );
132 }
static const char * DIR_PARAM_NAME
Definition: BatchAnalysis.h:60
void getFiles(kome::objects::SettingParameterValues *settings, std::vector< std::pair< std::string, kome::core::Properties > > &files)
gets files
const char * getParameterValue(const unsigned int index)
gets parameter value

Here is the call graph for this function:

void kome::operation::BatchAnalysis::onPrepareAnalysis ( std::vector< std::string > &  paths,
kome::core::Progress progress 
)
protectedpure virtual

on prepares analysis

Parameters
[in]pathsanalysis files
[out]progressthe object to show the progress

Member Data Documentation

const char * BatchAnalysis::DIR_PARAM_NAME = "dir"
staticprotected

directory parameter name

Definition at line 60 of file BatchAnalysis.h.

const char * BatchAnalysis::FILE_NAME_PROP_NAME = "File Name"
staticprotected

file name property name

Definition at line 57 of file BatchAnalysis.h.

std::vector< std::string > kome::operation::BatchAnalysis::m_fileProperties
protected

file properties

Definition at line 44 of file BatchAnalysis.h.

kome::plugin::SettingsPage* kome::operation::BatchAnalysis::m_filesPage
protected

files page

Definition at line 50 of file BatchAnalysis.h.

std::string kome::operation::BatchAnalysis::m_name
protected

name

Definition at line 41 of file BatchAnalysis.h.

kome::plugin::SettingsPage* kome::operation::BatchAnalysis::m_parametersPage
protected

parameter page

Definition at line 53 of file BatchAnalysis.h.

kome::plugin::ParameterSettings kome::operation::BatchAnalysis::m_params
protected

parameters

Definition at line 47 of file BatchAnalysis.h.


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