Brion  1.5.0
The Blue Brain C++ I/O library
types.h
1 /* Copyright (c) 2013-2015, 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/algorithm/string.hpp>
26 #include <boost/multi_array.hpp>
27 #include <boost/shared_ptr.hpp>
28 #include <lunchbox/types.h>
29 #include <set>
30 #include <map>
31 
32 #define VMMLIB_CUSTOM_CONFIG
33 #ifndef NDEBUG
34 # define VMMLIB_SAFE_ACCESSORS
35 #endif
36 #undef VMMLIB_ALIGN
37 #define VMMLIB_ALIGN( var ) var
38 #pragma warning(push)
39 #pragma warning(disable : 4996)
40 # include <vmmlib/vmmlib.hpp>
41 #pragma warning(pop)
42 
43 namespace brion
44 {
45 
46 using namespace enums;
47 class BlueConfig;
48 class Circuit;
49 class CompartmentReport;
50 class CompartmentReportPlugin;
51 class Mesh;
52 class Morphology;
53 class SpikeReport;
54 class SpikeReportPlugin;
55 
56 class Synapse;
57 class SynapseSummary;
58 class Target;
59 
60 typedef vmml::vector< 2, int32_t > Vector2i;
61 typedef vmml::vector< 3, float > Vector3f;
62 typedef vmml::vector< 4, float > Vector4f;
63 typedef vmml::vector< 3, double > Vector3d;
64 typedef vmml::vector< 4, double > Vector4d;
65 
66 typedef std::vector< size_t > size_ts;
67 typedef std::vector< int32_t > int32_ts;
68 typedef std::vector< uint16_t > uint16_ts;
69 typedef std::vector< uint32_t > uint32_ts;
70 typedef std::vector< uint64_t > uint64_ts;
71 typedef std::vector< float > floats;
72 typedef std::vector< Vector2i > Vector2is;
73 typedef std::vector< Vector3f > Vector3fs;
74 typedef std::vector< Vector4f > Vector4fs;
75 typedef std::vector< Vector3d > Vector3ds;
76 typedef std::vector< Vector4d > Vector4ds;
77 typedef std::vector< SectionType > SectionTypes;
78 
79 typedef boost::shared_ptr< int32_ts > int32_tsPtr;
80 typedef boost::shared_ptr< uint16_ts > uint16_tsPtr;
81 typedef boost::shared_ptr< uint32_ts > uint32_tsPtr;
82 typedef boost::shared_ptr< floats > floatsPtr;
83 typedef boost::shared_ptr< Vector2is > Vector2isPtr;
84 typedef boost::shared_ptr< Vector3fs > Vector3fsPtr;
85 typedef boost::shared_ptr< Vector4fs > Vector4fsPtr;
86 typedef boost::shared_ptr< Vector3ds > Vector3dsPtr;
87 typedef boost::shared_ptr< Vector4ds > Vector4dsPtr;
88 typedef boost::shared_ptr< SectionTypes > SectionTypesPtr;
89 
91 typedef std::set< uint32_t > GIDSet;
92 
93 typedef GIDSet::const_iterator GIDSetCIter;
94 typedef GIDSet::iterator GIDSetIter;
95 
99 typedef std::vector< uint64_ts > SectionOffsets;
100 
102 typedef std::vector< uint16_ts > CompartmentCounts;
103 
105 typedef boost::multi_array< std::string, 2 > NeuronMatrix;
106 
108 typedef boost::multi_array< float, 2 > SynapseMatrix;
109 
111 typedef boost::multi_array< uint32_t, 2 > SynapseSummaryMatrix;
112 
114 typedef std::multimap< float, uint32_t > Spikes;
115 
117 typedef std::pair< float, uint32_t > Spike;
118 
121 const float UNDEFINED_TIMESTAMP = std::numeric_limits< float >::max();
122 const float RESTING_VOLTAGE = -67.;
123 
124 using lunchbox::Strings;
125 using lunchbox::URI;
126 }
127 
128 // if you have a type T in namespace N, the operator << for T needs to be in
129 // namespace N too
130 namespace boost
131 {
132 template< typename T >
133 inline std::ostream& operator << ( std::ostream& os,
134  const boost::multi_array< T, 2 >& data )
135 {
136  for( size_t i = 0; i < data.shape()[0]; ++i )
137  {
138  for( size_t j = 0; j < data.shape()[1]; ++j )
139  os << data[i][j] << " ";
140  os << std::endl;
141  }
142  return os;
143 }
144 }
145 
146 namespace std
147 {
148 template< class T, class U > inline
149 std::ostream& operator << ( std::ostream& os, const std::pair< T, U >& pair )
150 {
151  return os << "[ " << pair.first << ", " << pair.second << " ]";
152 }
153 }
154 
155 #endif
STL namespace.