fpmas 1.6
graph_builder.h
Go to the documentation of this file.
1#ifndef FPMAS_SPATIAL_GRAPH_BUILDER_H
2#define FPMAS_SPATIAL_GRAPH_BUILDER_H
3
11#include "fpmas/model/model.h"
12
13namespace fpmas { namespace model {
14
18 static const api::model::GroupId GRAPH_CELL_GROUP_ID = -2;
19
29 template<typename CellType>
31 : public api::model::CellNetworkBuilder<CellType>{
32 private:
34 graph_builder;
35 std::size_t cell_count;
36
37 std::function<CellType*()> cell_allocator;
38 std::function<CellType*()> distant_cell_allocator;
39
40 public:
56 std::size_t cell_count,
57 std::function<CellType*()> cell_allocator,
58 std::function<CellType*()> distant_cell_allocator) :
59 graph_builder(graph_builder), cell_count(cell_count),
60 cell_allocator(cell_allocator),
61 distant_cell_allocator(distant_cell_allocator) {
62 }
63
77 std::size_t cell_count,
78 std::function<CellType*()> cell_allocator)
80 graph_builder, cell_count, cell_allocator, cell_allocator) {
81 }
82
97 std::size_t cell_count)
98 : CellNetworkBuilder(graph_builder, cell_count, [] () {return new CellType;}) {
99 }
100
101 std::vector<CellType*> build(
102 api::model::SpatialModel<CellType>& model) const override {
103 return this->build(model, {});
104 }
105
106 std::vector<CellType*> build(
108 api::model::GroupList groups) const override;
109 };
110
111 template<typename CellType>
114 api::model::GroupList groups) const {
115 groups.push_back(model.cellGroup());
117 groups, cell_count, cell_allocator, distant_cell_allocator,
118 model.getMpiCommunicator()
119 );
120
121 graph_builder.build(
122 node_builder, api::model::CELL_SUCCESSOR, model.graph()
123 );
124
125 return model.cells();
126 }
127}}
128
129#endif
Definition: graph_builder.h:154
virtual std::vector< api::graph::DistributedNode< T > * > build(DistributedNodeBuilder< T > &node_builder, LayerId layer, DistributedGraph< T > &graph)=0
Definition: spatial_model.h:568
virtual api::communication::MpiCommunicator & getMpiCommunicator()=0
virtual AgentGraph & graph()=0
virtual AgentGroup & cellGroup()=0
virtual std::vector< CellType * > cells()=0
Definition: graph_builder.h:31
CellNetworkBuilder(api::graph::DistributedGraphBuilder< model::AgentPtr > &graph_builder, std::size_t cell_count)
Definition: graph_builder.h:95
std::vector< CellType * > build(api::model::SpatialModel< CellType > &model) const override
Definition: graph_builder.h:101
CellNetworkBuilder(api::graph::DistributedGraphBuilder< model::AgentPtr > &graph_builder, std::size_t cell_count, std::function< CellType *()> cell_allocator)
Definition: graph_builder.h:75
CellNetworkBuilder(api::graph::DistributedGraphBuilder< model::AgentPtr > &graph_builder, std::size_t cell_count, std::function< CellType *()> cell_allocator, std::function< CellType *()> distant_cell_allocator)
Definition: graph_builder.h:54
int GroupId
Definition: model.h:78
std::vector< std::reference_wrapper< AgentGroup > > GroupList
Definition: model.h:833
Definition: fpmas.cpp:3