Brion  2.0.0
The Blue Brain C++ I/O library
brion/types.h
1 /* Copyright (c) 2013-2017, EPFL/Blue Brain Project
2  * Daniel Nachbaur <daniel.nachbaur@epfl.ch>
3  *
4  * This file is part of Brion <https://github.com/BlueBrain/Brion>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 3.0 as published
8  * by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef BRION_TYPES
21 #define BRION_TYPES
22 
23 #include <brion/enums.h>
24 
25 #include <boost/multi_array.hpp>
26 #include <map>
27 #include <servus/uri.h>
28 #include <set>
29 
30 #pragma warning(push)
31 #pragma warning(disable : 4996)
32 #include <vmmlib/types.hpp>
33 #pragma warning(pop)
34 
35 #ifdef __GNUC__
36 #define BRION_UNUSED __attribute__((unused))
37 #else
38 #define BRION_UNUSED
39 #endif
40 
42 namespace brion
43 {
44 using namespace enums;
45 class BlueConfig;
46 class Circuit;
47 class CompartmentReport;
48 class CompartmentReportPlugin;
49 class Mesh;
50 class Morphology;
51 class SpikeReport;
52 class SpikeReportPlugin;
53 class Synapse;
54 class SynapseSummary;
55 class Target;
56 
57 using vmml::Vector2i;
58 using vmml::Vector3f;
59 using vmml::Vector4f;
60 using vmml::Vector3d;
61 using vmml::Vector4d;
62 
63 typedef std::vector<size_t> size_ts;
64 typedef std::vector<int32_t> int32_ts;
65 typedef std::vector<uint16_t> uint16_ts;
66 typedef std::vector<uint32_t> uint32_ts;
67 typedef std::vector<uint64_t> uint64_ts;
68 typedef std::vector<float> floats;
69 typedef std::vector<double> doubles;
70 typedef std::vector<Vector2i> Vector2is;
71 typedef std::vector<Vector3f> Vector3fs;
72 typedef std::vector<Vector4f> Vector4fs;
73 typedef std::vector<Vector3d> Vector3ds;
74 typedef std::vector<Vector4d> Vector4ds;
75 typedef std::vector<SectionType> SectionTypes;
76 typedef std::vector<Target> Targets;
77 typedef std::shared_ptr<int32_ts> int32_tsPtr;
78 typedef std::shared_ptr<uint16_ts> uint16_tsPtr;
79 typedef std::shared_ptr<uint32_ts> uint32_tsPtr;
80 typedef std::shared_ptr<floats> floatsPtr;
81 typedef std::shared_ptr<doubles> doublesPtr;
82 typedef std::shared_ptr<Vector2is> Vector2isPtr;
83 typedef std::shared_ptr<Vector3fs> Vector3fsPtr;
84 typedef std::shared_ptr<Vector4fs> Vector4fsPtr;
85 typedef std::shared_ptr<Vector3ds> Vector3dsPtr;
86 typedef std::shared_ptr<Vector4ds> Vector4dsPtr;
87 typedef std::shared_ptr<SectionTypes> SectionTypesPtr;
88 
90 typedef std::set<uint32_t> GIDSet;
91 
92 typedef GIDSet::const_iterator GIDSetCIter;
93 typedef GIDSet::iterator GIDSetIter;
94 
98 typedef std::vector<uint64_ts> SectionOffsets;
99 
101 typedef std::vector<uint16_ts> CompartmentCounts;
102 
104 typedef boost::multi_array<std::string, 2> NeuronMatrix;
105 
107 typedef boost::multi_array<float, 2> SynapseMatrix;
108 
110 typedef boost::multi_array<uint32_t, 2> SynapseSummaryMatrix;
111 
113 typedef std::pair<float, uint32_t> Spike;
114 typedef std::vector<Spike> Spikes;
115 
117 typedef std::multimap<float, uint32_t> SpikeMap;
118 
119 struct Frame
120 {
121  double timestamp;
122  floatsPtr data;
123 };
124 
125 struct Frames
126 {
127  doublesPtr timeStamps;
132  floatsPtr data;
133 };
134 
137 const float UNDEFINED_TIMESTAMP BRION_UNUSED =
138  std::numeric_limits<float>::max();
139 const float RESTING_VOLTAGE BRION_UNUSED = -67.;
140 
141 const float MINIMUM_VOLTAGE BRION_UNUSED = -80.;
142 
143 typedef std::vector<std::string> Strings;
144 
145 using servus::URI;
146 
147 typedef std::vector<URI> URIs;
148 }
149 
150 // if you have a type T in namespace N, the operator << for T needs to be in
151 // namespace N too
152 namespace boost
153 {
154 template <typename T>
155 inline std::ostream& operator<<(std::ostream& os,
156  const boost::multi_array<T, 2>& data)
157 {
158  for (size_t i = 0; i < data.shape()[0]; ++i)
159  {
160  for (size_t j = 0; j < data.shape()[1]; ++j)
161  os << data[i][j] << " ";
162  os << std::endl;
163  }
164  return os;
165 }
166 }
167 
168 namespace std
169 {
170 template <class T, class U>
171 inline std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& pair)
172 {
173  return os << "[ " << pair.first << ", " << pair.second << " ]";
174 }
175 }
176 
177 #endif
std::vector< uint64_ts > SectionOffsets
The offset for the voltage per section for each neuron, uin64_t max for sections with no compartments...
Definition: brion/types.h:98
STL namespace.
std::multimap< float, uint32_t > SpikeMap
A list of Spikes events per cell gid, indexed by spikes times.
Definition: brion/types.h:117
std::pair< float, uint32_t > Spike
A spike.
Definition: brion/types.h:113
std::set< uint32_t > GIDSet
Ordered set of GIDs of neurons.
Definition: brion/types.h:90
const float UNDEFINED_TIMESTAMP BRION_UNUSED
A value for undefined timestamps.
Definition: brion/types.h:137
boost::multi_array< std::string, 2 > NeuronMatrix
Data matrix storing NeuronAttributes for each neuron.
Definition: brion/types.h:104
std::ostream & operator<<(std::ostream &, const BlueConfig &)
Stream out content of BlueConfig or CircuitConfig file.
boost::multi_array< uint32_t, 2 > SynapseSummaryMatrix
Data matrix storing GID, numEfferent, numAfferent for each neuron.
Definition: brion/types.h:110
std::vector< uint16_ts > CompartmentCounts
The number of compartments per section for each neuron.
Definition: brion/types.h:101
Blue Brain File IO classes.
Definition: blueConfig.h:29
Enumerations used in Brion.
boost::multi_array< float, 2 > SynapseMatrix
Data matrix storing SynapseAttributes for each neuron.
Definition: brion/types.h:107
floatsPtr data
The data of multiple compartment frames in a flat array.
Definition: brion/types.h:132