Swarm-NG  1.1
swarm::snapshot Namespace Reference

Static class containing methods to load/save ensembles to file. More...

Classes

struct  header
 Data structure used in binary files. This is meant to be found at offset 0 of the file. More...
 
struct  sys
 Data structure used in binary files. parameters for a system. This comes right after the header and is followed by nbod number of body structs. More...
 
struct  body
 Data structure used in binary files. parameters for each body. nbod instances of this struct follows after each sys data structure. More...
 
struct  readfileexception
 Raised when an error encountered reading a text or binary file. Used in load and load_text. More...
 
struct  writefileexception
 Raised when an error encountered writing to a text or binary file. Used in save and save_text. More...
 

Functions

defaultEnsemble load (const string &filename) throw (readfileexception)
 Load binary snapshot file.
 
defaultEnsemble load_text (const string &filename) throw (readfileexception)
 Loads textual snapshot file.
 
void save (defaultEnsemble &ens, const string &filename) throw (writefileexception)
 Save the ensemble to a binary file.
 
void save_text (defaultEnsemble &ens, const string &filename) throw (writefileexception)
 Save the ensemble as a text file.
 

Detailed Description

Static class containing methods to load/save ensembles to file.

This class supports load and save in text and binary formats. For binary format use:

  • ens = load(filename)
  • save(ens,filename)

For text format use:

  • ens = load_text(filename)
  • save_text(ens,filename)

Binary file format: HEADER | SYS | BODY | BODY | BODY | SYS | BODY | BODY | BODY | SYS | BODY | BODY | BODY | ...

The example above is for an ensemble with 3 bodies per system. HEADER, SYS and BODY are structs defined inside the snapshot class.(refer to header, sys, body).

header containts number of systems and numebr of bodies. It also contains the number of attributes per system and number of attributes per body. Since the number of attributes are set at compile time the number of attributes in the file should be less than or equal to the number of the attributes that library supports.

For text format refere to Text Formats