Nemo  2.3.46
BinaryDataSaver Class Reference

A class to handle simulation data saving in binary format. More...

#include <binarydatasaver.h>

+ Inheritance diagram for BinaryDataSaver:
+ Collaboration diagram for BinaryDataSaver:

Public Member Functions

 BinaryDataSaver ()
 
 ~BinaryDataSaver ()
 
virtual bool setParameters ()
 
virtual void execute ()
 
virtual BinaryDataSaverclone ()
 
virtual void FHwrite ()
 
virtual void FHread (string &filename)
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual age_t removeAgeClass ()
 
virtual age_t addAgeClass ()
 
virtual age_t requiredAgeClass ()
 
- Public Member Functions inherited from LifeCycleEvent
 LifeCycleEvent (const char *name, const char *trait_link)
 Cstor. More...
 
virtual ~LifeCycleEvent ()
 
virtual void init (Metapop *popPtr)
 Sets the pointer to the current Metapop and the trait link if applicable. More...
 
virtual bool attach_trait (string trait)
 
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 
virtual void set_event_name (std::string &name)
 Set the name of the event (name of the ParamSet) and add the corresponding parameter to the set. More...
 
virtual void set_event_name (const char *name)
 
virtual string & get_event_name ()
 Accessor to the LCE's name. More...
 
virtual int get_rank ()
 Accessor to the LCE rank in the life cycle. More...
 
virtual void set_pop_ptr (Metapop *popPtr)
 Accessors for the population pointer. More...
 
virtual Metapopget_pop_ptr ()
 
- Public Member Functions inherited from SimComponent
 SimComponent ()
 
virtual ~SimComponent ()
 
virtual void loadUpdaters (UpdaterServices *loader)
 Loads the parameters and component updater onto the updater manager. More...
 
virtual void set_paramset (ParamSet *paramset)
 Sets the ParamSet member. More...
 
virtual void set_paramsetFromCopy (const ParamSet &PSet)
 Reset the set of parameters from a another set. More...
 
virtual ParamSetget_paramset ()
 ParamSet accessor. More...
 
virtual void add_parameter (Param *param)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater)
 Interface to add a parameter and its updater to the set. More...
 
virtual Paramget_parameter (std::string name)
 Param getter. More...
 
virtual double get_parameter_value (std::string name)
 Param value getter. More...
 
virtual string get_name ()
 Returnd the name of the ParamSet, i.e. More...
 
- Public Member Functions inherited from FileHandler
 FileHandler (const char *ext)
 
virtual ~FileHandler ()
 
virtual void init ()
 Called by notifier during simulation setup, performs file checking. More...
 
virtual bool ifExist ()
 Checks if any file associated with the current file name already exists on disk. More...
 
virtual void set (bool rpl_per, bool gen_per, int rpl_occ, int gen_occ, int rank, string path)
 Sets the hanlder parameters. More...
 
virtual void set_multi (bool rpl_per, bool gen_per, int rpl_occ, TMatrix *Occ, string path)
 
virtual void update ()
 Updates the inner replicate and generation counters and calls FHwrite if needed by the the periodicity of the file. More...
 
Metapopget_pop_ptr ()
 Returns the pointer to the current metapop through the FileServices interface. More...
 
void set_pop_ptr (Metapop *pop_ptr)
 
FileServicesget_service ()
 Returns pointer to the FileServices. More...
 
void set_service (FileServices *srv)
 
std::string & get_path ()
 
void set_path ()
 
std::string & get_extension ()
 
void set_extension (const char *ext)
 
std::string & get_filename ()
 Builds and returns the current file name depending on the periodicity of the file. More...
 
bool get_isInputHandler ()
 
void set_isInputHandler (bool val)
 
bool get_isReplicatePeriodic ()
 
void set_isReplicatePeriodic (bool val)
 
unsigned int get_ReplicateOccurrence ()
 
void set_ReplicateOccurrence (unsigned int val)
 
bool get_isGenerationPeriodic ()
 
void set_isGenerationPeriodic (bool val)
 
unsigned int get_GenerationOccurrence ()
 
void set_GenerationOccurrence (unsigned int val)
 
unsigned int get_ExecRank ()
 unused yet... More...
 
void set_ExecRank (int val)
 
TMatrixget_OccMatrix ()
 
void set_OccMatrix (TMatrix *occ)
 
bool get_isMasterExec ()
 
void set_isMasterExec (bool is)
 
- Public Member Functions inherited from Handler
virtual ~Handler ()
 

Static Public Attributes

static pid_t PID = 0
 

Private Member Functions

void printHeader ()
 
void printData ()
 
void storeData ()
 
void finish ()
 

Private Attributes

BinaryStorageBuffer _buff
 
std::string _comp_cmd
 
std::string _comp_ext
 
std::string _uncomp_cmd
 
std::string _tar_cmd
 
std::string _tar_ext
 
std::string _dir
 
bool _isPeriodic
 
unsigned int _generation
 
std::map< unsigned int,
unsigned int
_offset_table
 

Additional Inherited Members

- Protected Attributes inherited from LifeCycleEvent
std::string _event_name
 The param name to be read in the init file. More...
 
Metapop_popPtr
 The ptr to the current Metapop. More...
 
std::string _LCELinkedTraitType
 The name of the linked trait. More...
 
int _LCELinkedTraitIndex
 The index in the individual's trait table of the linked trait. More...
 
- Protected Attributes inherited from SimComponent
ParamSet_paramSet
 The parameters container. More...
 
- Protected Attributes inherited from FileHandler
Metapop_pop
 Pointer to the current metapop, set during initialization within the init function. More...
 

Detailed Description

A class to handle simulation data saving in binary format.

It is both an LCE and a FileHandler but the writing is executed through the LCE interface (i.e. LifeCycleEvent::execute()). Its inheritance from the FileHandler class is used to access the basic file services (i.e. basename and current replicate filename, etc.).

Constructor & Destructor Documentation

BinaryDataSaver::BinaryDataSaver ( )

References SimComponent::add_parameter(), BOOL, INT, setParameters(), and STR.

Referenced by clone().

54 : LifeCycleEvent("store",""), FileHandler(".bin"), _isPeriodic(0)
55 {
58 
59  add_parameter("store_generation",INT,true,false,0,0,updater);
60  add_parameter("store_recursive",BOOL,false,false,0,0,updater);
61  add_parameter("store_dir",STR,false,false,0,0,updater);
62  add_parameter("store_nocompress",BOOL,false,false,0,0,updater);
63  add_parameter("store_noarchive",BOOL,false,false,0,0,updater);
64  add_parameter("store_compress_cmde",STR,false,false,0,0,updater);
65  add_parameter("store_compress_extension",STR,false,false,0,0,updater);
66  add_parameter("store_uncompress_cmde",STR,false,false,0,0,updater);
67  add_parameter("store_archive_cmde",STR,false,false,0,0,updater);
68  add_parameter("store_archive_extension",STR,false,false,0,0,updater);
69 }
Implementation of the ParamUpdaterBase interface.
Definition: param.h:348
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:98
bool _isPeriodic
Definition: binarydatasaver.h:51
FileHandler(const char *ext)
Definition: filehandler.h:107
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
virtual bool setParameters()
Definition: binarydatasaver.cc:73
Definition: types.h:78
Definition: types.h:78
Definition: types.h:78
BinaryDataSaver::~BinaryDataSaver ( )
inline
64 {}

Member Function Documentation

virtual age_t BinaryDataSaver::addAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

79 {return 0;}
virtual BinaryDataSaver* BinaryDataSaver::clone ( )
inlinevirtual

Implements LifeCycleEvent.

References BinaryDataSaver().

71 {return new BinaryDataSaver();}
BinaryDataSaver()
Definition: binarydatasaver.cc:53
void BinaryDataSaver::execute ( )
virtual

Implements LifeCycleEvent.

References _buff, _generation, _isPeriodic, LifeCycleEvent::_popPtr, finish(), Metapop::getCurrentGeneration(), Metapop::getGenerations(), printData(), printHeader(), BinaryStorageBuffer::set_buff(), and storeData().

141 {
142  //set the buffer ready to be filled
143  if(_popPtr->getCurrentGeneration() == 1)
144  _buff.set_buff();
145 
146  //if the generation to store is > than the total nbr of generations, correct this and store the last one
148  storeData();
149  } else
150  //if periodic, and generation match, store the data in the buffer
152  storeData();
153  }
154 
155  //if reached last generation, write data to file,
156  //this empties the storage buffer with a call to printData() within FHwrite()
157  //thus prevents further calls to FHwrite to rewrite data to disc
159  //make sure the last generation is always stored before writing data to disc:
160  //catch if tot num gene is not a multiple of _generation
162  //catch if tot num gen is a multiple but _generation < num gen and non periodic
165  {
166  storeData();
167  }
168  printHeader();
169  printData(); //this calls _buff.clear()
170  finish();
171  }
172 }
void printHeader()
Definition: binarydatasaver.cc:199
bool _isPeriodic
Definition: binarydatasaver.h:51
void finish()
Definition: binarydatasaver.cc:303
unsigned int _generation
Definition: binarydatasaver.h:52
unsigned int getCurrentGeneration()
Definition: metapop.h:286
void printData()
Definition: binarydatasaver.cc:250
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
unsigned int getGenerations()
Definition: metapop.h:267
void storeData()
Definition: binarydatasaver.cc:223
void set_buff()
Definition: binarystoragebuffer.h:63
BinaryStorageBuffer _buff
Definition: binarydatasaver.h:48
virtual void BinaryDataSaver::FHread ( string &  filename)
inlinevirtual

Implements FileHandler.

74 {}
void BinaryDataSaver::FHwrite ( )
virtual

Implements FileHandler.

References _buff, finish(), LifeCycleEvent::get_rank(), BinaryStorageBuffer::getByteLength(), SIMenv::getCurrentRankInLifeCycle(), printData(), and printHeader().

177 {
178  //need to make sure data is saved even though last generation has not been reached
179  //in case of population extinction, the file manager issues a notify() call after
180  //the simulation exited from the generations loop, we try to catch this call here
181 
182  //keep in mind that this function is always called at the last generation
183 
184  //if data is already written to disc, the data buffer is empty
185  //if the 'store' LCE is after the 'save_files' LCE in the life cycle, we don't write
186  //--> issues two calls to printData, this one would be before storing last generation
187  //if 'store' is before 'save_files', the data buffer should be empty by now
188 
190  printHeader();
191  printData(); //this calls _buff.clear()
192  finish();
193  }
194 
195 }
void printHeader()
Definition: binarydatasaver.cc:199
void finish()
Definition: binarydatasaver.cc:303
void printData()
Definition: binarydatasaver.cc:250
static int getCurrentRankInLifeCycle()
Definition: simenv.h:64
unsigned int getByteLength() const
Definition: binarystoragebuffer.h:52
virtual int get_rank()
Accessor to the LCE rank in the life cycle.
Definition: lifecycleevent.h:166
BinaryStorageBuffer _buff
Definition: binarydatasaver.h:48
void BinaryDataSaver::finish ( )
private

References _comp_cmd, _comp_ext, LifeCycleEvent::_popPtr, _tar_cmd, _tar_ext, error(), FileHandler::get_filename(), FileHandler::get_path(), FileHandler::get_service(), FileServices::getBaseFileName(), Metapop::getCurrentReplicate(), MPIenv::isMaster(), PID, and MPIenv::slaveRank().

Referenced by execute(), and FHwrite().

304 {
305  bool doComp = (_comp_cmd.size() > 0), doTar = (_tar_cmd.size() > 0),
306  first = (_popPtr->getCurrentReplicate()
307  == max((unsigned)1,_myenv->slaveRank()));
308 
309  if (!(doComp || doTar)) return;
310 
311  stringstream sysCmd;
312 
313  if (doComp)
314  sysCmd << _comp_cmd << " " << get_filename() << ";";
315 
316  if (doTar) {
317  sysCmd << _tar_cmd;
318  if (first) sysCmd << " c"; //first replicate, create the tar archive:
319  else sysCmd << " r"; //next replicates, append files to it:
320  sysCmd << "f " << get_path() << get_service()->getBaseFileName();
321  if (!_myenv->isMaster()) sysCmd << _myenv->slaveRank();
322  sysCmd << _tar_ext << " --remove-files " << get_filename() << _comp_ext;
323  }
324 
325 
326  //wait for last child:
327  if (!first) waitpid(PID,NULL,0);
328 
329  pid_t tPID = fork();
330 
331  if (tPID == 0) {
332 
333  if (system(sysCmd.str().c_str()) < 0)
334  error("BinaryDataSaver::finish system cmd \"%s\" failed: %s\n",
335  sysCmd.str().c_str(),strerror(errno));
336 
337  _exit(EXIT_FAILURE);
338 
339  } else if (tPID < 0) //fork failed :
340  error("BinaryDataSaver::finish::could not fork new process: %s\n",
341  strerror(errno));
342 
343  PID = tPID;
344 }
std::string _comp_ext
Definition: binarydatasaver.h:50
FileServices * get_service()
Returns pointer to the FileServices.
Definition: filehandler.h:135
std::string & get_filename()
Builds and returns the current file name depending on the periodicity of the file.
Definition: filehandler.cc:148
MPIenv * _myenv
Definition: simulation.cc:47
unsigned int slaveRank() const
Definition: MPImanager.h:129
static pid_t PID
Definition: binarydatasaver.h:66
int error(const char *str,...)
Definition: output.cc:73
unsigned int getCurrentReplicate()
Definition: metapop.h:285
std::string _tar_cmd
Definition: binarydatasaver.h:50
string & getBaseFileName()
Accessor to the base file name of the simulation.
Definition: fileservices.cc:226
std::string _tar_ext
Definition: binarydatasaver.h:50
std::string & get_path()
Definition: filehandler.h:139
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
std::string _comp_cmd
Definition: binarydatasaver.h:50
bool isMaster() const
Definition: MPImanager.h:127
virtual void BinaryDataSaver::loadFileServices ( FileServices loader)
inlinevirtual

Implements SimComponent.

References FileServices::attach().

76 {loader->attach(this);}
virtual void attach(Handler *FH)
Attaches the FileHandler to the current list (_writers) of the FileServices.
Definition: fileservices.cc:57
virtual void BinaryDataSaver::loadStatServices ( StatServices loader)
inlinevirtual

Implements SimComponent.

77 {}
void BinaryDataSaver::printData ( )
private

References _buff, _offset_table, BinaryStorageBuffer::clear(), error(), fatal(), FileHandler::get_filename(), BinaryStorageBuffer::getBuffer(), BinaryStorageBuffer::getByteLength(), message(), and BinaryStorageBuffer::store().

Referenced by execute(), and FHwrite().

251 {
252 
253  mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
254  int flag = O_WRONLY | O_APPEND;
255  //open in write and append mode with permission flag set to rw-r--r--
256  int fdesc = open(get_filename().c_str(), flag, mode);
257 
258  if(fdesc == -1) fatal("BinaryDataSaver::printData::open %s:%s\n",get_filename().c_str(),strerror(errno));
259  //get the offset position of the EOF, will be the nbr of bytes to add to the generation offsets
260  off_t pos = lseek(fdesc,0,SEEK_END);
261 
262  if(pos == -1) fatal("BinaryDataSaver::printData::lseek %s\n",strerror(errno));
263 
264  //offset of the offset table:
265  int off_table = _buff.getByteLength() + (int)pos;
266  //add the offset info at the end of the _buff:
267  unsigned char separator[3] = {'@','O','T'};
268  _buff.store(&separator, 3);
269 
270  std::map<unsigned int, unsigned int>::iterator IT = _offset_table.begin();
271  while(IT != _offset_table.end()) {
272  IT->second += (int)pos;
273  _buff.store((int*)&IT->first, sizeof(int));
274  _buff.store((int*)&IT->second, sizeof(int));
275  IT++;
276  }
277  //finally, record the number of generations recorded and the offset of start of the offset table
278  int nb_recgen = _offset_table.size();
279  _buff.store(&nb_recgen, sizeof(int));
280  _buff.store(&off_table, sizeof(int));
281 
282  //now write the data to the file:
283 #ifdef _DEBUG_
284  message("BinaryDataSaver::printData:writing %ikB of data ",_buff.getByteLength()/1024);
285 #endif
286 
287  if((write(fdesc,_buff.getBuffer(),_buff.getByteLength())) == -1)
288  fatal("BinaryDataSaver::printData::write %s\n",strerror(errno));
289 
290  if((close(fdesc)) == -1)
291  error("BinaryDataSaver::printData::close %s\n",strerror(errno));
292 
293  //empty the buffer, get ready for next record
294  _buff.clear();
295 
296 #ifdef _DEBUG_
297  message(" [ok]\n");
298 #endif
299 }
void message(const char *message,...)
Definition: output.cc:40
void clear()
Definition: binarystoragebuffer.h:54
std::string & get_filename()
Builds and returns the current file name depending on the periodicity of the file.
Definition: filehandler.cc:148
void fatal(const char *str,...)
Definition: output.cc:90
int error(const char *str,...)
Definition: output.cc:73
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:130
char * getBuffer() const
Definition: binarystoragebuffer.h:51
std::map< unsigned int, unsigned int > _offset_table
Definition: binarydatasaver.h:54
unsigned int getByteLength() const
Definition: binarystoragebuffer.h:52
BinaryStorageBuffer _buff
Definition: binarydatasaver.h:48
void BinaryDataSaver::printHeader ( )
private

References fatal(), FileHandler::get_filename(), FileServices::get_params(), FileHandler::get_service(), MAIN_VERSION, message(), MINOR_VERSION, RELEASE, REVISION, and VERSION_DATE.

Referenced by execute(), and FHwrite().

200 {
201  //first, record the parameters in text mode:
202  ofstream FILE (get_filename().c_str(), ios::out);
203 
204  if(!FILE) fatal("could not open Binary output file!!\n");
205 
206  list< ParamSet* > current_params = get_service()->get_params();
207  list< ParamSet* >::iterator Pit = current_params.begin();
208 
209  FILE<<"#NEMO "<<MAIN_VERSION<<" "<<MINOR_VERSION<<" "<<REVISION<<" "<<RELEASE<<" "<<VERSION_DATE<<endl;
210 
211 #ifdef _DEBUG_
212  message("BinaryDataSaver::printHeader:storing parameters\n");
213 #endif
214  while(Pit != current_params.end()) {
215  (*Pit)->print(FILE);
216  Pit++;
217  }
218  FILE.close();
219 }
#define REVISION
Definition: version.h:29
void message(const char *message,...)
Definition: output.cc:40
list< ParamSet * > & get_params()
Accessor to the list of the current parameters of the simulation.
Definition: fileservices.h:125
#define RELEASE
Definition: version.h:30
#define MINOR_VERSION
Definition: version.h:28
FileServices * get_service()
Returns pointer to the FileServices.
Definition: filehandler.h:135
#define MAIN_VERSION
Definition: version.h:27
std::string & get_filename()
Builds and returns the current file name depending on the periodicity of the file.
Definition: filehandler.cc:148
void fatal(const char *str,...)
Definition: output.cc:90
#define VERSION_DATE
Definition: version.h:31
virtual age_t BinaryDataSaver::removeAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

78 {return 0;}
virtual age_t BinaryDataSaver::requiredAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

80 {return 0;}
bool BinaryDataSaver::setParameters ( )
virtual

Implements SimComponent.

References _comp_cmd, _comp_ext, _dir, _generation, _isPeriodic, _offset_table, LifeCycleEvent::_popPtr, _tar_cmd, _tar_ext, _uncomp_cmd, SimComponent::get_parameter(), SimComponent::get_parameter_value(), LifeCycleEvent::get_rank(), Param::getArg(), Metapop::getGenerations(), Param::isSet(), and FileHandler::set().

Referenced by BinaryDataSaver().

74 {
75  Param* param;
76 
77  _generation = (unsigned int)get_parameter_value("store_generation");
78 
79  //make sure we at least save the last generation:
81 
82  param = get_parameter("store_dir");
83  if(param->isSet())
84  _dir = param->getArg();
85  else
86  _dir = "";
87 
88  param = get_parameter("store_recursive");
89  if(param->isSet())
90  _isPeriodic = true;
91  else
92  _isPeriodic = false;
93 
94  param = get_parameter("store_compress_cmde");
95  if(param->isSet())
96  _comp_cmd = param->getArg();
97  else
98  _comp_cmd = "bzip2"; //default compressor used
99 
100  param = get_parameter("store_compress_extension");
101  if(param->isSet())
102  _comp_ext = param->getArg();
103  else
104  _comp_ext = ".bz2"; //default
105 
106  param = get_parameter("store_uncompress_cmde");
107  if(param->isSet())
108  _uncomp_cmd = param->getArg();
109  else
110  _uncomp_cmd = "unbzip2"; //default
111 
112  param = get_parameter("store_archive_cmde");
113  if(param->isSet())
114  _tar_cmd = param->getArg();
115  else
116  _tar_cmd = "tar"; //default
117 
118  param = get_parameter("store_archive_extension");
119  if(param->isSet())
120  _tar_ext = param->getArg();
121  else
122  _tar_ext = ".tar"; //default
123 
124  param = get_parameter("store_nocompress");
125  if(param->isSet()) {_comp_cmd = ""; _comp_ext ="";} //compression process desabled
126 
127  param = get_parameter("store_noarchive");
128  if(param->isSet()) {_tar_cmd = ""; _tar_ext = "";} //archiving processed desabled
129 
130  //set the file handler, will be called by FileServices, will output data at last gen
131  FileHandler::set(true, false, 1, _popPtr->getGenerations(), get_rank(), _dir);
132 
133  _offset_table.clear();
134 
135  return true;
136 }
std::string _comp_ext
Definition: binarydatasaver.h:50
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
bool _isPeriodic
Definition: binarydatasaver.h:51
unsigned int _generation
Definition: binarydatasaver.h:52
std::string _tar_cmd
Definition: binarydatasaver.h:50
This structure stores one parameter, its definition and its string argument.
Definition: param.h:53
std::string _dir
Definition: binarydatasaver.h:50
string getArg()
Definition: param.h:136
virtual void set(bool rpl_per, bool gen_per, int rpl_occ, int gen_occ, int rank, string path)
Sets the hanlder parameters.
Definition: filehandler.h:193
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
std::string _tar_ext
Definition: binarydatasaver.h:50
std::string _uncomp_cmd
Definition: binarydatasaver.h:50
std::map< unsigned int, unsigned int > _offset_table
Definition: binarydatasaver.h:54
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
std::string _comp_cmd
Definition: binarydatasaver.h:50
unsigned int getGenerations()
Definition: metapop.h:267
virtual int get_rank()
Accessor to the LCE rank in the life cycle.
Definition: lifecycleevent.h:166
bool isSet()
Definition: param.h:138
void BinaryDataSaver::storeData ( )
private

References _buff, _offset_table, LifeCycleEvent::_popPtr, BinaryStorageBuffer::getByteLength(), Metapop::getCurrentGeneration(), message(), BinaryStorageBuffer::store(), and Metapop::store_data().

Referenced by execute().

224 {
225 #ifdef _DEBUG_
226  message("BinaryDataSaver::storeData\n");
227  unsigned int byte_count = _buff.getByteLength();
228 #endif
229  unsigned int generation = _popPtr->getCurrentGeneration();
230  unsigned char separator[2] = {'@','G'}; //generation separator = '@G'
231  //store the position in the buffer to the offset table:
232  _offset_table[generation] = _buff.getByteLength();
233  //store the data, begin with generation separator and number:
234  _buff.store(&separator, 2 * sizeof(unsigned char));
235 
236  _buff.store(&generation, sizeof(unsigned int));
237 
238  //Metapop is a StorableComponent, call store_data:
239  //stores all individual info, including trait sequences
241 
242 #ifdef _DEBUG_
243  message("BinaryDataSaver::storeData::stored %ikB\n",(_buff.getByteLength()-byte_count)/1024);
244  byte_count = _buff.getByteLength();
245 #endif
246 }
void message(const char *message,...)
Definition: output.cc:40
unsigned int getCurrentGeneration()
Definition: metapop.h:286
virtual void store_data(BinaryStorageBuffer *saver)
Definition: metapop.cc:427
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:130
std::map< unsigned int, unsigned int > _offset_table
Definition: binarydatasaver.h:54
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
unsigned int getByteLength() const
Definition: binarystoragebuffer.h:52
BinaryStorageBuffer _buff
Definition: binarydatasaver.h:48

Member Data Documentation

BinaryStorageBuffer BinaryDataSaver::_buff
private

Referenced by execute(), FHwrite(), printData(), and storeData().

std::string BinaryDataSaver::_comp_cmd
private

Referenced by finish(), and setParameters().

std::string BinaryDataSaver::_comp_ext
private

Referenced by finish(), and setParameters().

std::string BinaryDataSaver::_dir
private

Referenced by setParameters().

unsigned int BinaryDataSaver::_generation
private

Referenced by execute(), and setParameters().

bool BinaryDataSaver::_isPeriodic
private

Referenced by execute(), and setParameters().

std::map<unsigned int, unsigned int> BinaryDataSaver::_offset_table
private

Referenced by printData(), setParameters(), and storeData().

std::string BinaryDataSaver::_tar_cmd
private

Referenced by finish(), and setParameters().

std::string BinaryDataSaver::_tar_ext
private

Referenced by finish(), and setParameters().

std::string BinaryDataSaver::_uncomp_cmd
private

Referenced by setParameters().

pid_t BinaryDataSaver::PID = 0
static

Referenced by finish().


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

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR