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 | Static Protected Attributes | List of all members
kome::objects::SampleSet Class Referenceabstract

sample set information management class More...

#include <SampleSet.h>

Collaboration diagram for kome::objects::SampleSet:
Collaboration graph
[legend]

Public Member Functions

 SampleSet ()
 constructor
 
virtual ~SampleSet ()
 destructor
 
int getSampleSetId ()
 gets the sample set ID More...
 
void setFilePath (const char *path)
 sets the file path More...
 
const char * getFilePath ()
 gets file path More...
 
const char * getFileName ()
 gets file name More...
 
bool isOpened ()
 judges whther this sample set file is opened or not More...
 
int getErrorCode (void)
 get error code of file access. More...
 
void setErrorCode (const int errorCode)
 set error code of file access. More...
 
void clearSamples ()
 clears samples
 
void addSample (Sample *sample)
 adds sample More...
 
unsigned int getNumberOfSamples ()
 gets the nubmer of samples More...
 
SamplegetSample (const unsigned int index)
 gets sample object More...
 
bool openFile (const char *path, kome::core::Progress *progress=NULL)
 opens file More...
 
bool closeFile ()
 closes file More...
 
virtual bool onOpenSample (Sample *sample, kome::core::Progress *progress=NULL)=0
 This method is called by openSample method. (abstract method) More...
 
virtual bool onCloseSample (Sample *sample)=0
 This method is called by closeSample method. (abstract method) More...
 

Static Public Member Functions

static void startLoadingTimer ()
 starts loading timer
 
static void stopLoadingTimer ()
 stops loading timer
 
static double getTotalLoadingTime ()
 gets total loading time More...
 
static int issueSampleSetId ()
 issues sample set ID More...
 

Protected Member Functions

virtual bool onOpenFile (const char *path, kome::core::Progress *progress=NULL)=0
 This method is called by openFile method. (abstract method) More...
 
virtual bool onCloseFile ()=0
 This method is called by closeFile method. (abstract method) More...
 

Protected Attributes

std::string m_filePath
 
std::string m_fileName
 
std::vector< Sample * > m_samples
 
bool m_opened
 
int m_errorCode
 
int m_sampleSetId
 

Static Protected Attributes

static kome::core::Timer m_loadingTimer
 
static int m_currentSampleSetId = 0
 

Detailed Description

sample set information management class

Definition at line 29 of file SampleSet.h.

Member Function Documentation

void kome::objects::SampleSet::addSample ( Sample sample)

adds sample

Parameters
[in]samplesample object to be added

Definition at line 99 of file SampleSet.cpp.

99  {
100  // check the parameter
101  if( sample == NULL ) {
102  return;
103  }
104  if( sample->getSampleSet() != this ) {
105  LOG_WARN( FMT( "Sample set is different." ) );
106  return;
107  }
108 
109  // add
110  sample->setSampleIndex( (int)m_samples.size() );
111  m_samples.push_back( sample );
112 }
SampleSet * getSampleSet()
gets sample set object
Definition: Sample.cpp:77
std::vector< Sample * > m_samples
Definition: SampleSet.h:51
#define NULL
Definition: CoreMacros.h:18
void setSampleIndex(const int index)
sets sample index
Definition: Sample.cpp:82

Here is the call graph for this function:

bool kome::objects::SampleSet::closeFile ( )

closes file

Returns
If true, it succeeded to close the file

Definition at line 165 of file SampleSet.cpp.

165  {
166  if( !m_opened ) {
167  return true;
168  }
169 
170  // close
171  for( unsigned int i = 0; i < m_samples.size(); i++ ) {
172  m_samples[ i ]->closeSample();
173  }
174  bool ret = onCloseFile();
175 
176  // clear
177  clearSamples();
178 
179  return ret;
180 }
std::vector< Sample * > m_samples
Definition: SampleSet.h:51
virtual bool onCloseFile()=0
This method is called by closeFile method. (abstract method)
void clearSamples()
clears samples
Definition: SampleSet.cpp:84

Here is the call graph for this function:

int kome::objects::SampleSet::getErrorCode ( void  )

get error code of file access.

Returns
error code.

Definition at line 207 of file SampleSet.cpp.

208 {
209  return m_errorCode;
210 }
const char * kome::objects::SampleSet::getFileName ( )

gets file name

Returns
file name

Definition at line 74 of file SampleSet.cpp.

74  {
75  return m_fileName.c_str();
76 }
std::string m_fileName
Definition: SampleSet.h:48
const char * kome::objects::SampleSet::getFilePath ( )

gets file path

Returns
file path

Definition at line 69 of file SampleSet.cpp.

69  {
70  return m_filePath.c_str();
71 }
std::string m_filePath
Definition: SampleSet.h:45
unsigned int kome::objects::SampleSet::getNumberOfSamples ( )

gets the nubmer of samples

Returns
the number of samples

Definition at line 115 of file SampleSet.cpp.

115  {
116  return m_samples.size();
117 }
std::vector< Sample * > m_samples
Definition: SampleSet.h:51
Sample * kome::objects::SampleSet::getSample ( const unsigned int  index)

gets sample object

Parameters
[in]indexsample index
Returns
sample object (If NULL, the index is illegal.)

Definition at line 120 of file SampleSet.cpp.

120  {
121  if( index >= m_samples.size() ) {
122  return NULL;
123  }
124  return m_samples[ index ];
125 }
std::vector< Sample * > m_samples
Definition: SampleSet.h:51
#define NULL
Definition: CoreMacros.h:18
int kome::objects::SampleSet::getSampleSetId ( )

gets the sample set ID

Returns
sample set ID

Definition at line 51 of file SampleSet.cpp.

51  {
52  return m_sampleSetId;
53 }
static double kome::objects::SampleSet::getTotalLoadingTime ( )
static

gets total loading time

Returns
total loading time

Definition at line 193 of file SampleSet.cpp.

193  {
194  return m_loadingTimer.getTotalTime();
195 }
static kome::core::Timer m_loadingTimer
Definition: SampleSet.h:57
double getTotalTime()
gets total time
Definition: Timer.cpp:83

Here is the call graph for this function:

bool kome::objects::SampleSet::isOpened ( )

judges whther this sample set file is opened or not

Returns
If true, this sample set file is opened.

Definition at line 79 of file SampleSet.cpp.

79  {
80  return m_opened;
81 }
static int kome::objects::SampleSet::issueSampleSetId ( )
static

issues sample set ID

Returns
sample set ID

Definition at line 198 of file SampleSet.cpp.

198  {
199  int sampleSetId = m_currentSampleSetId;
200  m_currentSampleSetId++;
201 
202  return sampleSetId;
203 }
bool kome::objects::SampleSet::onCloseFile ( )
protectedpure virtual

This method is called by closeFile method. (abstract method)

Returns
If true, it succeeded to close the file
bool kome::objects::SampleSet::onCloseSample ( Sample sample)
pure virtual

This method is called by closeSample method. (abstract method)

Parameters
[in,out]samplesample object to be closed (If NULL, closes all samples.)
Returns
If true, it succeeded to close the sample.
bool kome::objects::SampleSet::onOpenFile ( const char *  path,
kome::core::Progress progress = NULL 
)
protectedpure virtual

This method is called by openFile method. (abstract method)

Parameters
[in]pathfile path
[out]progressprogress bar dialog
Returns
If true, it succeeded to open the file
bool kome::objects::SampleSet::onOpenSample ( Sample sample,
kome::core::Progress progress = NULL 
)
pure virtual

This method is called by openSample method. (abstract method)

Parameters
[in,out]samplesample object to be opened (If NULL, opens all samples.)
[out]progressprogress bar dialog
Returns
If true, it succeeded to open the sample.
bool kome::objects::SampleSet::openFile ( const char *  path,
kome::core::Progress progress = NULL 
)

opens file

Parameters
[in]pathfile path
[out]progressprogress bar dialog
Returns
If true, it succeeded to open the file

Definition at line 128 of file SampleSet.cpp.

128  { // add param @date 2014.07.08 <Mod> M.Izumi
129  if( m_opened ) { // already opened
130  return true;
131  }
132 
133  // set file path
134  m_filePath = absolutepath( path );
135  m_fileName = getfilename( m_filePath.c_str() );
136 
137  // log
138  LOG_DEBUG( FMT( "Open the raw data. [%s]", m_filePath.c_str() ) );
139 
140  // open
142 
143  bool ret = false;
144  try {
145  ret = onOpenFile( m_filePath.c_str(), progress );// add param
146  }
147  catch( ... ) {
148  ret = false;
149  }
150 
152 
153  if( ret ) {
154  m_opened = true;
155  }
156  else {
157  clearSamples();
158  LOG_ERROR( FMT( "Failed to open the file.[%s]", m_filePath.c_str() ) );
159  }
160 
161  return ret;
162 }
std::string getfilename(const char *path)
get file name
std::string m_fileName
Definition: SampleSet.h:48
virtual bool onOpenFile(const char *path, kome::core::Progress *progress=NULL)=0
This method is called by openFile method. (abstract method)
std::string m_filePath
Definition: SampleSet.h:45
static void stopLoadingTimer()
stops loading timer
Definition: SampleSet.cpp:188
void clearSamples()
clears samples
Definition: SampleSet.cpp:84
std::string absolutepath(const char *path)
get absolute path
static void startLoadingTimer()
starts loading timer
Definition: SampleSet.cpp:183

Here is the call graph for this function:

int kome::objects::SampleSet::setErrorCode ( const int  errorCode)

set error code of file access.

Parameters
[in]errorCodeerror code

Definition at line 213 of file SampleSet.cpp.

214 {
215  m_errorCode = errorCode;
216 
217  return;
218 }
void kome::objects::SampleSet::setFilePath ( const char *  path)

sets the file path

Parameters
[in]pathfile path

Definition at line 56 of file SampleSet.cpp.

56  {
57  m_filePath = NVL( path, "" );
58 
59  for( unsigned int i = 0; i < m_samples.size(); i++ ) {
60  kome::objects::Sample* sample = m_samples[ i ];
62  if( root != NULL ) {
63  root->getProperties().setValue( "File Path", m_filePath.c_str() );
64  }
65  }
66 }
group of spectrum management class
Definition: DataGroupNode.h:33
sample information management class
Definition: Sample.h:34
std::vector< Sample * > m_samples
Definition: SampleSet.h:51
void setValue(const char *key, const char *value)
sets parameter value
Definition: Properties.cpp:39
std::string m_filePath
Definition: SampleSet.h:45
kome::core::Properties & getProperties()
gets properties
#define NVL(checkVal, replaceVal)
Definition: CoreMacros.h:99
#define NULL
Definition: CoreMacros.h:18
DataGroupNode * getRootDataGroupNode()
gets root spectrum group
Definition: Sample.cpp:219

Here is the call graph for this function:

Member Data Documentation

int kome::objects::SampleSet::m_errorCode
protected

error code of file access

Definition at line 61 of file SampleSet.h.

std::string kome::objects::SampleSet::m_fileName
protected

file name

Definition at line 48 of file SampleSet.h.

std::string kome::objects::SampleSet::m_filePath
protected

file path

Definition at line 45 of file SampleSet.h.

kome::core::Timer SampleSet::m_loadingTimer
staticprotected

loading timer

Definition at line 57 of file SampleSet.h.

bool kome::objects::SampleSet::m_opened
protected

opened flag

Definition at line 54 of file SampleSet.h.

std::vector< Sample* > kome::objects::SampleSet::m_samples
protected

samples

Definition at line 51 of file SampleSet.h.

int kome::objects::SampleSet::m_sampleSetId
protected

sample set ID

Definition at line 65 of file SampleSet.h.


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