24 const std::string & db_subdirectory,
25 const Report & report)
27 dispatcher_.reset(
new ReportStatisticsDispatcher(
28 db_directory, db_subdirectory, report));
33 void setArchiveMetadata(
const app::NamedExtensions & metadata) {
34 dispatcher_->setArchiveMetadata(metadata);
39 dispatcher_->configureBinaryArchive(
this);
43 std::shared_ptr<RootArchiveNode> getRoot()
const {
44 return dispatcher_->getRoot();
50 dispatcher_->dispatch();
71 void saveTo(
const std::string & db_directory) {
73 const auto & sinks = dispatcher_->getSinks();
74 for (
const auto & sink : sinks) {
75 copyArchiveToDirectory_(*sink, db_directory);
87 ReportStatisticsDispatcher(
const std::string & db_directory,
88 const std::string & db_subdirectory,
89 const Report & report) :
90 db_directory_(db_directory),
91 db_subdirectory_(db_subdirectory)
93 std::unique_ptr<ReportStatisticsAggregator> source(
97 root_ = source->getRoot();
98 setStatisticsSource(std::move(source));
101 void setArchiveMetadata(
const app::NamedExtensions & metadata) {
102 root_->setMetadata(metadata);
111 if (!root_->tryGetMetadataValue<app::TriggerKeyValues>(
"trigger")) {
112 app::TriggerKeyValues no_triggers;
113 root_->setMetadataValue(
"trigger", no_triggers);
122 std::shared_ptr<ArchiveController> controller(
125 root_->setArchiveController(controller);
131 const std::string & time_stamp = ArchiveDispatcher::getSimulationTimeStamp_();
134 sink->setPath(db_directory_ +
"/" + time_stamp);
135 sink->setSubpath(db_subdirectory_);
136 sink->setRoot(root_);
138 addStatisticsSink(std::move(sink));
141 std::shared_ptr<RootArchiveNode> getRoot() {
146 const std::string db_directory_;
147 const std::string db_subdirectory_;
148 std::shared_ptr<RootArchiveNode> root_;
155 void copyArchiveToDirectory_(
const ArchiveSink & original_sink,
156 const std::string & destination_dir)
const
159 binary_source.setPath(original_sink.getPath());
160 binary_source.setSubpath(original_sink.getSubpath());
161 binary_source.initialize();
164 copied_sink.setPath(destination_dir);
165 copied_sink.setSubpath(original_sink.getSubpath());
166 copied_sink.initialize();
169 const std::vector<double> & binary_data = binary_source.readFromSource();
170 if (binary_data.empty()) {
173 copied_sink.sendToSink(binary_data);
176 copied_sink.copyMetadataFrom(&original_sink);
179 std::unique_ptr<ReportStatisticsDispatcher> dispatcher_;