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::objects::ActiveObjectsManager Class Reference

active object management class More...

#include <ActiveObjectsManager.h>

Inheritance diagram for kome::objects::ActiveObjectsManager:
Inheritance graph
[legend]
Collaboration diagram for kome::objects::ActiveObjectsManager:
Collaboration graph
[legend]

Public Member Functions

unsigned int getNumberOfOpenedSamples ()
 gets the number of opened samples More...
 
SamplegetOpenedSample (const unsigned int idx)
 gets opened sample More...
 
std::vector< Spectrum * > getOpenSpectra ()
 
void addOpenSpectra (Spectrum *spec)
 Get Open spectra. More...
 
void removeOpenSpectra (Spectrum *spec)
 on closed spectrum canvas ( remove spectrum ) More...
 
void setActiveSample (Sample *sample)
 sets the active sample More...
 
SamplegetActiveSample ()
 gets the active sample More...
 
DataSetgetFilteredDataSet (Sample *sample)
 gets filtered data set More...
 
void clearFileHistory ()
 clears file history
 
void addHistoryFile (const char *path)
 adds history file More...
 
void removeHistoryFile (const char *path)
 removes history file More...
 
unsigned int getNumberOfHistoryFiles ()
 gets the number of history files More...
 
const char * getHistoryFile (const unsigned int idx)
 gets history file More...
 
void addTabSample (Sample *sample)
 adds opened sample More...
 
void delTabSample (Sample *sample)
 deletes opened sample More...
 
std::vector< Sample * > getTabSamples ()
 gets the array of opened samples More...
 
void setSampleTagName (Sample *sample, const char *name)
 sets the sample tag name More...
 
const char * getSampleTagName (Sample *sample)
 gets the sample tag name More...
 

Static Public Member Functions

static ActiveObjectsManagergetInstance ()
 get active object manager object (This is the only object.) More...
 
- Static Public Member Functions inherited from kome::objects::DataManager
static void openSample (Sample *sample)
 This method is called when a sample is opened. More...
 
static void closeSample (Sample *sample, const bool deleting)
 This method is called when a sample is closed. More...
 
static void openSpectrum (Spectrum *spec)
 This method is called when a spectrum is opened. More...
 
static void closeSpectrum (Spectrum *spec, const bool deleting)
 This method is called when a spectrum is closed. More...
 
static void openChromatogram (Chromatogram *chrom)
 This method is called when a chromaogram is opened. More...
 
static void closeChromatogram (Chromatogram *chrom, const bool deleting)
 This method is called when a chromatogram is closed. More...
 
static void openDataMap (DataMapInfo *dataMap)
 This method is called when a data map is opened. More...
 
static void closeDataMap (DataMapInfo *dataMap, const bool deleting)
 This method is called when a data map is closed. More...
 

Protected Member Functions

 ActiveObjectsManager ()
 constructor
 
virtual ~ActiveObjectsManager ()
 destructor
 
int searchSample (Sample *sample)
 searchs sample from array More...
 
void readHistoryFromIni ()
 reads history files from ini file
 
virtual void onOpenSample (Sample *sample)
 This method is called when a sample is opened. (override method) More...
 
virtual void onCloseSample (Sample *sample, const bool deleting)
 This method is called when a sample is closed. (override method) More...
 
void setTabSample ()
 initializes the array of opened samples
 
- Protected Member Functions inherited from kome::objects::DefaultDataManager
 DefaultDataManager ()
 constructor
 
virtual ~DefaultDataManager ()
 destructor
 
virtual void onOpenSpectrum (Spectrum *spec)
 This method is called when a spectrum is opened. (override method) More...
 
virtual void onCloseSpectrum (Spectrum *spec, const bool deleting)
 This method is called when a spectrum is closed. (override method) More...
 
virtual void onOpenChromatogram (Chromatogram *chrom)
 This method is called when a chromatogram is opened. (override method) More...
 
virtual void onCloseChromatogram (Chromatogram *chrom, const bool deleting)
 This method is called when a chromatogram is closed. (override method) More...
 
virtual void onOpenDataMap (DataMapInfo *dataMap)
 This method is called when a data map is opened. (override method) More...
 
virtual void onCloseDataMap (DataMapInfo *dataMap, const bool deleting)
 This method is called when a data map is closed. (override method) More...
 
- Protected Member Functions inherited from kome::objects::DataManager
 DataManager ()
 constructor
 
virtual ~DataManager ()
 destructor
 

Protected Attributes

std::map< Sample *, DataSet * > m_filteredDataSetMap
 
DataSet m_dataSet
 
std::vector< Sample * > m_samples
 
std::vector< std::string > m_fileHistory
 
Samplem_acSample
 
std::vector< Sample * > m_tmpSamples
 
std::vector< Spectrum * > m_openSpectra
 
std::map< Sample *, std::string > m_tagNameMap
 
- Protected Attributes inherited from kome::objects::DataManager
int m_order
 

Additional Inherited Members

- Static Protected Member Functions inherited from kome::objects::DataManager
static bool lessManager (DataManager *dm0, DataManager *dm1)
 conmapred data managers to sort More...
 
static void sortDataManagers ()
 sorts data managers
 
- Static Protected Attributes inherited from kome::objects::DataManager
static std::vector< DataManager * > m_dataMgrs
 
static bool m_sorted = true
 

Detailed Description

active object management class

Definition at line 37 of file ActiveObjectsManager.h.

Member Function Documentation

void kome::objects::ActiveObjectsManager::addHistoryFile ( const char *  path)

adds history file

Parameters
[in]pathfile path

Definition at line 134 of file ActiveObjectsManager.cpp.

134  {
135  // ini
137  kome::core::IniFile* ini = msppMgr.getIniFile();
138 
139  // get history
140  if( m_fileHistory.size() == 0 ) {
142  }
143 
144  // absolutepath
145  std::string p = absolutepath( path );
146 
147  // search
148  int idx = -1;
149  for( unsigned int i = 0; i < m_fileHistory.size() && idx < 0; i++ ) {
150  if( m_fileHistory[ i ].compare( p ) == 0 ) {
151  idx = (int)i;
152  }
153  }
154 
155  if( idx >= 0 ) {
156  m_fileHistory.erase( m_fileHistory.begin() + idx );
157  }
158 
159  // add
160  m_fileHistory.insert( m_fileHistory.begin(), p );
161 
162  // remove
163  while( m_fileHistory.size() > HISTORY_COUNT ) {
164  m_fileHistory.erase( m_fileHistory.begin() + (int)( m_fileHistory.size() - 1 ) );
165  }
166 
167  // ini
168  if( ini != NULL ) {
169  for( unsigned int i = 0; i < m_fileHistory.size(); i++ ) {
170  std::string name = FMT( "File%d", ( i + 1 ) );
171  ini->setString( MRU_SECTION, name.c_str(), m_fileHistory[ i ].c_str() );
172  }
173  }
174 }
static MsppManager & getInstance()
gets MsppManager object (This is the only object.)
Mass++ manager class.
Definition: MsppManager.h:28
IniFile * getIniFile()
gets ini file
void readHistoryFromIni()
reads history files from ini file
#define NULL
Definition: CoreMacros.h:18
std::vector< std::string > m_fileHistory
std::string absolutepath(const char *path)
get absolute path
ini file management class
Definition: IniFile.h:30
void setString(const char *section, const char *key, const char *value)
sets string value
Definition: IniFile.cpp:64

Here is the call graph for this function:

void kome::objects::ActiveObjectsManager::addOpenSpectra ( Spectrum spec)

Get Open spectra.

Parameters
specspectrum object

Definition at line 364 of file ActiveObjectsManager.cpp.

364  {
365  if( spec != NULL ){
366  for( unsigned int i=0; i < m_openSpectra.size(); i++ ){
367  if( spec == m_openSpectra[i] ){
368  return;
369  }
370  }
371  m_openSpectra.push_back( spec );
372 
373  }
374 }
#define NULL
Definition: CoreMacros.h:18
std::vector< Spectrum * > m_openSpectra
void kome::objects::ActiveObjectsManager::addTabSample ( Sample sample)

adds opened sample

Parameters
[in]samplesample object to be closed

Definition at line 305 of file ActiveObjectsManager.cpp.

305  {
306  setTabSample();
307  m_tmpSamples.push_back( sample );
308 }
void setTabSample()
initializes the array of opened samples

Here is the call graph for this function:

void kome::objects::ActiveObjectsManager::delTabSample ( Sample sample)

deletes opened sample

Parameters
[in]samplesample object to be closed

Definition at line 334 of file ActiveObjectsManager.cpp.

334  {
335  int i = m_tmpSamples.size()-1;
336  while( i > -1 ){
337  if( m_tmpSamples[i] == sample ){
338  m_tmpSamples.erase( m_tmpSamples.begin() + i );
339  }
340  i--;
341  }
342  setTabSample();
343 }
void setTabSample()
initializes the array of opened samples

Here is the call graph for this function:

Sample * kome::objects::ActiveObjectsManager::getActiveSample ( )

gets the active sample

Returns
active sample

Definition at line 73 of file ActiveObjectsManager.cpp.

73  {
74  return m_acSample;
75 }
DataSet * kome::objects::ActiveObjectsManager::getFilteredDataSet ( Sample sample)

gets filtered data set

Parameters
[in]samplesample
Returns
filtered data set

Definition at line 78 of file ActiveObjectsManager.cpp.

78  {
79  // get spectra
80  kome::objects::DataSet* dataSet = NULL;
81 
82  if( m_filteredDataSetMap.find( sample ) == m_filteredDataSetMap.end() ) { // new data set
83  dataSet = new DataSet( sample->getRootDataGroupNode() );
84  if( sample != NULL ) {
85  DataGroupNode* root = sample->getRootDataGroupNode();
86  root->getDataSet( dataSet );
87  }
88 
89  for( int i = (int)dataSet->getNumberOfChromatograms() - 1; i >= 0; i-- ) {
90  kome::objects::Chromatogram* chrom = dataSet->getChromatogram( i );
91  if( chrom->isAutoCreated() ) {
92  dataSet->removeChromatogram( chrom );
93  }
94  }
95 
96  m_filteredDataSetMap[ sample ] = dataSet;
97  }
98  else {
99  dataSet = m_filteredDataSetMap[ sample ];
100  }
101 
102  return dataSet;
103 }
group of spectrum management class
Definition: DataGroupNode.h:33
void getDataSet(DataSet *dataSet)
gets spectra that contains this group. (getSpectrum method cannot get spectra that belong to child gr...
virtual void removeChromatogram(Chromatogram *chrom)
removes chromatogram
Definition: DataSet.cpp:222
Chromatogram * getChromatogram(const unsigned int index)
gets chroamtogram
Definition: DataSet.cpp:146
#define NULL
Definition: CoreMacros.h:18
unsigned int getNumberOfChromatograms()
gets the number of chromatograms
Definition: DataSet.cpp:141
bool isAutoCreated()
gets auto created flag value
DataGroupNode * getRootDataGroupNode()
gets root spectrum group
Definition: Sample.cpp:219
std::map< Sample *, DataSet * > m_filteredDataSetMap
one or more spectra management class
Definition: DataSet.h:31
chromatogram information management class
Definition: Chromatogram.h:33

Here is the call graph for this function:

const char * kome::objects::ActiveObjectsManager::getHistoryFile ( const unsigned int  idx)

gets history file

Parameters
[in]idxhistory file index
Returns
history file path

Definition at line 214 of file ActiveObjectsManager.cpp.

214  {
215  // get history
216  if( m_fileHistory.size() == 0 ) {
218  }
219 
220  // path
221  if( idx >= m_fileHistory.size() ) {
222  return NULL;
223  }
224  return m_fileHistory[ idx ].c_str();
225 }
void readHistoryFromIni()
reads history files from ini file
#define NULL
Definition: CoreMacros.h:18
std::vector< std::string > m_fileHistory

Here is the call graph for this function:

static ActiveObjectsManager & kome::objects::ActiveObjectsManager::getInstance ( )
static

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

Returns
active manager object

Definition at line 294 of file ActiveObjectsManager.cpp.

294  {
295  // create object (This is the only object.)
296  static ActiveObjectsManager mgr;
297 
298  return mgr;
299 }
active object management class
unsigned int kome::objects::ActiveObjectsManager::getNumberOfHistoryFiles ( )

gets the number of history files

Returns
the number of history files

Definition at line 203 of file ActiveObjectsManager.cpp.

203  {
204  // get history
205  if( m_fileHistory.size() == 0 ) {
207  }
208 
209  // size
210  return m_fileHistory.size();
211 }
void readHistoryFromIni()
reads history files from ini file
std::vector< std::string > m_fileHistory

Here is the call graph for this function:

unsigned int kome::objects::ActiveObjectsManager::getNumberOfOpenedSamples ( )

gets the number of opened samples

Returns
the number of opened samples

Definition at line 55 of file ActiveObjectsManager.cpp.

55  {
56  return m_samples.size();
57 }
Sample * kome::objects::ActiveObjectsManager::getOpenedSample ( const unsigned int  idx)

gets opened sample

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

Definition at line 60 of file ActiveObjectsManager.cpp.

60  {
61  if( idx >= m_samples.size() ) {
62  return NULL;
63  }
64  return m_samples[ idx ];
65 }
#define NULL
Definition: CoreMacros.h:18
std::vector< Spectrum * > kome::objects::ActiveObjectsManager::getOpenSpectra ( )
Returns
opened Spectrra ( single mode )

Definition at line 359 of file ActiveObjectsManager.cpp.

359  {
360  return m_openSpectra;
361 }
std::vector< Spectrum * > m_openSpectra
const char * kome::objects::ActiveObjectsManager::getSampleTagName ( Sample sample)

gets the sample tag name

Parameters
[in]samplesample
Returns
tag name

Definition at line 326 of file ActiveObjectsManager.cpp.

326  {
327  if( m_tagNameMap.find( sample ) == m_tagNameMap.end() ) {
328  return NULL;
329  }
330  return m_tagNameMap[ sample ].c_str();
331 }
std::map< Sample *, std::string > m_tagNameMap
#define NULL
Definition: CoreMacros.h:18
std::vector< Sample * > kome::objects::ActiveObjectsManager::getTabSamples ( )

gets the array of opened samples

Returns
m_tmpSamples

Definition at line 311 of file ActiveObjectsManager.cpp.

311  {
312  return m_tmpSamples;
313 }
void kome::objects::ActiveObjectsManager::onCloseSample ( Sample sample,
const bool  deleting 
)
protectedvirtual

This method is called when a sample is closed. (override method)

Parameters
[in]samplesample object to be closed
[in]deletingIf true, the specified object is being deleted now.

Reimplemented from kome::objects::DefaultDataManager.

Definition at line 269 of file ActiveObjectsManager.cpp.

269  {
270  // delete filtered spectra
271  std::vector< DataGroupNode* > groups;
272  // @date 2012.04.23 <Mod> M.Izumi
273  for( std::map< Sample*, DataSet* >::iterator it = m_filteredDataSetMap.begin();
274  it != m_filteredDataSetMap.end(); it++ ) {
275  // @date 2012.04.23 <Mod> M.Izumi
276  if( sample != NULL && sample == (*it).first ){
277  delete (*it).second;
278 
279  groups.push_back( sample->getRootDataGroupNode() ); // @date 2012.04.23 <Mod> M.Izumi
280  }
281  }
282  for( int i = 0; i < (int)groups.size(); i++ ) {
283  m_filteredDataSetMap.erase( groups[ i ]->getSample() ); // @date 2012.04.23 <Mod> M.Izumi
284  }
285 
286  // delete sample from array
287  int idx = searchSample( sample );
288  if( idx >= 0 ) {
289  m_samples.erase( m_samples.begin() + idx );
290  }
291 }
#define NULL
Definition: CoreMacros.h:18
int searchSample(Sample *sample)
searchs sample from array
DataGroupNode * getRootDataGroupNode()
gets root spectrum group
Definition: Sample.cpp:219
std::map< Sample *, DataSet * > m_filteredDataSetMap

Here is the call graph for this function:

void kome::objects::ActiveObjectsManager::onOpenSample ( Sample sample)
protectedvirtual

This method is called when a sample is opened. (override method)

Parameters
[in]samplesample object to be opened

Reimplemented from kome::objects::DefaultDataManager.

Definition at line 255 of file ActiveObjectsManager.cpp.

255  {
256  // check
257  if( sample == NULL ) {
258  return;
259  }
260  int idx = searchSample( sample );
261  if( idx >= 0 ) {
262  return;
263  }
264 
265  m_samples.push_back( sample );
266 }
#define NULL
Definition: CoreMacros.h:18
int searchSample(Sample *sample)
searchs sample from array

Here is the call graph for this function:

void kome::objects::ActiveObjectsManager::removeHistoryFile ( const char *  path)

removes history file

Parameters
[in]pathfile path to be removed

Definition at line 177 of file ActiveObjectsManager.cpp.

177  {
178  // absolute path
179  std::string p = absolutepath( path );
180 
181  // copy the array
182  std::vector< std::string > history;
183  if( m_fileHistory.size() > 0 ) {
184  history.resize( m_fileHistory.size() );
185 
186  for( unsigned int i = 0; i < m_fileHistory.size(); i++ ) {
187  history[ i ] = m_fileHistory[ i ];
188  }
189  }
190 
191  // clear
193 
194  // add
195  for( unsigned int i = 0; i < history.size(); i++ ) {
196  if( history[ i ].compare( p ) != 0 ) {
197  addHistoryFile( history[ i ].c_str() );
198  }
199  }
200 }
void clearFileHistory()
clears file history
std::vector< std::string > m_fileHistory
std::string absolutepath(const char *path)
get absolute path
void addHistoryFile(const char *path)
adds history file

Here is the call graph for this function:

void kome::objects::ActiveObjectsManager::removeOpenSpectra ( Spectrum spec)

on closed spectrum canvas ( remove spectrum )

Parameters
specspectrum object

Definition at line 377 of file ActiveObjectsManager.cpp.

377  {
378  if( spec != NULL ){
379  int iSize = m_openSpectra.size()-1;
380  while( iSize >= 0 ){
381  if( spec == m_openSpectra[iSize] ){
382  m_openSpectra.erase( m_openSpectra.begin() + iSize );
383  return;
384  }
385  iSize--;
386  }
387  }
388 }
#define NULL
Definition: CoreMacros.h:18
std::vector< Spectrum * > m_openSpectra
int kome::objects::ActiveObjectsManager::searchSample ( Sample sample)
protected

searchs sample from array

Parameters
[in]samplesample object to be searched
Returns
sample index (If negative value, specified sample was not found.)

Definition at line 106 of file ActiveObjectsManager.cpp.

106  {
107  for( int i = 0; i < (int)m_samples.size(); i++ ) {
108  if( sample == m_samples[ i ] ) {
109  return i;
110  }
111  }
112  return -1;
113 }
void kome::objects::ActiveObjectsManager::setActiveSample ( Sample sample)

sets the active sample

Parameters
[in]sampleactive sample

Definition at line 68 of file ActiveObjectsManager.cpp.

68  {
69  m_acSample = sample;
70 }
void kome::objects::ActiveObjectsManager::setSampleTagName ( Sample sample,
const char *  name 
)

sets the sample tag name

Parameters
[in]samplesample
[in]nametag name

Definition at line 316 of file ActiveObjectsManager.cpp.

316  {
317  if( name == NULL ) {
318  m_tagNameMap.erase( sample );
319  }
320  else {
321  m_tagNameMap[ sample ] = name;
322  }
323 }
std::map< Sample *, std::string > m_tagNameMap
#define NULL
Definition: CoreMacros.h:18

Member Data Documentation

Sample* kome::objects::ActiveObjectsManager::m_acSample
protected

active sample

Definition at line 67 of file ActiveObjectsManager.h.

DataSet kome::objects::ActiveObjectsManager::m_dataSet
protected

data set

Definition at line 58 of file ActiveObjectsManager.h.

std::vector< std::string > kome::objects::ActiveObjectsManager::m_fileHistory
protected

file history

Definition at line 64 of file ActiveObjectsManager.h.

std::map< Sample*, DataSet* > kome::objects::ActiveObjectsManager::m_filteredDataSetMap
protected

filtered spectra map

Definition at line 55 of file ActiveObjectsManager.h.

std::vector< Spectrum* > kome::objects::ActiveObjectsManager::m_openSpectra
protected

open canvas spectrum (single mode)

Definition at line 73 of file ActiveObjectsManager.h.

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

opened samples

Definition at line 61 of file ActiveObjectsManager.h.

std::map< Sample*, std::string > kome::objects::ActiveObjectsManager::m_tagNameMap
protected

tagname map

Definition at line 76 of file ActiveObjectsManager.h.

std::vector< Sample* > kome::objects::ActiveObjectsManager::m_tmpSamples
protected

the array for closing samples

Definition at line 70 of file ActiveObjectsManager.h.


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