PopReader

The class PopReader is used to write the population data as a subgroup of the populations group in a qdf file.

The information of found populations is stored in a vector of popinfo structures:

typedef struct {
    std::string m_sClassName;
    std::string m_sSpeciesName;
    int  m_iNumCells;
} popinfo;

typedef std::vector<popinfo> popinfolist;
Code:

Public Methods

create

static PopReader *create(const std::string sFileName);
static PopReader *create(hid_t hFile):

Create a PopReader object for the specified file.

sFileName

Name of qdf file to be read.

hFile

HDF handle for the open file.

Returns a pointer to the PopReader object.

destructor

~PopReader();

Closes open HDF handles.

open

int open(const std::string sFilename);
int open(hid_t hFile);

Open the “Populations” group, and collects the names and attributes of all population subgroups.

sFileName

Name of file in which to search for populations.

hFile

HDF handle for file in which to search for populations.

Returns 0 on success, or -1 on error.

getPopList

const popinfolist &getPopList();

Returns the vector of popinfo structs.

read

int read(PopBase *pPopBase, const std::string sSpeciesName,
         int iNumCells,     bool bRestore);

Reads the data from the AgentDataSet of the population group with the given name into the agent array of the population object.

pPopBase

Pointer to a population object. The user of PopReader must provide a pointer of the correct type.

sSpeciesName

Name of the species for which to load the data.

iNumCells

Number of grid cells. Must have the same value as the NumCells attribute in the populatin group. If the numbers don’t match the positions of the agents will most certainly be wrong.

bRestore

If set to true, do a restore, if false, read normally

Returns 0 on success, or a begative value on error.