RepastHPC  2.3.1
SVDataSet.h
1 /*
2  * Repast for High Performance Computing (Repast HPC)
3  *
4  * Copyright (c) 2010 Argonne National Laboratory
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with
8  * or without modification, are permitted provided that the following
9  * conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * Neither the name of the Argonne National Laboratory nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OR
26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  *
35  * DataSet.h
36  *
37  * Created on: Aug 23, 2010
38  * Author: nick
39  */
40 
41 #ifndef SVDATASET_H_
42 #define SVDATASET_H_
43 
44 #include <fstream>
45 #include <vector>
46 
47 #include "Schedule.h"
48 #include "Variable.h"
49 #include "SVDataSource.h"
50 #include "DataSet.h"
51 
52 namespace repast {
53 
54 class SVDataSetBuilder;
55 
62 class SVDataSet: public DataSet {
63 
64 private:
65  friend class SVDataSetBuilder;
66 
67  std::string _separator;
68  std::vector<SVDataSource*> dataSources;
69  std::vector<double> ticks;
70  std::vector<Variable*> vars;
71  const Schedule* _schedule;
72 
73  std::ofstream out;
74  bool open;
75  int rank;
76 
77  void init();
78 
83  // private so only SVDataSetBuilder can create it
84  SVDataSet(const std::string& file, const std::string& separator, const Schedule* schedule);
85 
86 public:
87 
88  ~SVDataSet();
89 
93  void record();
94 
98  void write();
99 
103  void close();
104 };
105 
106 }
107 
108 #endif /* DATASET_H_ */
repast::SVDataSet::write
void write()
Writes any recorded data to a file.
Definition: SVDataSet.cpp:123
repast::Schedule
The simulation schedule queue.
Definition: Schedule.h:173
repast::SVDataSet
Encapsulates data recording to a single plain text file, separating the recorded values using a speci...
Definition: SVDataSet.h:62
repast::SVDataSet::close
void close()
Closes the data set.
Definition: SVDataSet.cpp:77
repast::SVDataSet::record
void record()
Records data from any added data sources.
Definition: SVDataSet.cpp:113
repast::DataSet
Interface for recording and writing data.
Definition: DataSet.h:49
repast::SVDataSetBuilder
Used to build SVDataSets to record data in plain text tabular format.
Definition: SVDataSetBuilder.h:103