FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTLookup.h
Go to the documentation of this file.
1/*
2Copyright (c) 2019 Gouvernement du Québec
3
4SPDX-License-Identifier: LiLiQ-R-1.1
5License-Filename: LICENSES/EN/LiLiQ-R11unicode.txt
6*/
7
8#ifndef FMTlookup_Hm_included
9#define FMTlookup_Hm_included
10
11//#include "FMTDevelopment.h"
12#include <boost/functional/hash.hpp>
13
14namespace Core
15{
16 // DocString: FMTLookup
22 template<class inmemory,class pointer>
24 {
25 public:
26 inmemory memoryobject;
27 const pointer* pointerobject;
28 // DocString: FMTLookup()
32 FMTLookup() = default;
33 // DocString: ~FMTLookup()
37 ~FMTLookup() = default;
38 //For looking
39 // DocString: FMTLookup(const pointer&)
44 FMTLookup(const pointer& ptr) :
46 {
47
48 }
49 //For keeping
50 // DocString: FMTLookup(const inmemory&, const pointer&)
56 FMTLookup(const inmemory& des, const pointer& dev) :
57 memoryobject(des), pointerobject(&dev)
58 {
59
60 }
61 // DocString: FMTLookup(const FMTLookup&)
66 FMTLookup(const FMTLookup& rhs) :
68 {
69
70 }
71 // DocString: FMTLookup::operator=
78 {
79 if (this != &rhs)
80 {
83 }
84 return *this;
85 }
86 // DocString: FMTLookup::operator<
92 bool operator < (const FMTLookup& rhs) const
93 {
94 //strict ordering
95 if (pointerobject == nullptr)
96 return true;
97 if (rhs.pointerobject == nullptr)
98 return false;
99 if ((*pointerobject) < (*rhs.pointerobject))
100 return true;
101 if ((*rhs.pointerobject) < (*pointerobject))
102 return false;
103 return false;
104 }
105
106 // DocString: FMTLookup::operator==
112 bool operator == (const FMTLookup& rhs) const
113 {
114 return (pointerobject != nullptr && rhs.pointerobject != nullptr && (*pointerobject) == (*rhs.pointerobject));
115 }
116
117 };
118}
119
120namespace boost
121{
122
123 template<class inmemory, class pointer>
124 struct hash<Core::FMTLookup<inmemory,pointer>>
125 {
126 std::size_t operator()(const Core::FMTLookup<inmemory, pointer>& lookup) const
127 {
128 return lookup.pointerobject->hash();
129 }
130 };
131
132 template<> inline std::size_t hash<Core::FMTLookup<std::vector<size_t>, std::string>>::operator()(const Core::FMTLookup<std::vector<size_t>, std::string>& lookup) const
133 {
134 return boost::hash<std::string>()(*lookup.pointerobject);
135 }
136
137
138}
139
140/*
141namespace Graph
142{
143 template<class tdescriptor>
144 class FMTVertexLookup
145 {
146 public:
147 tdescriptor descriptor;
148 const Core::FMTDevelopment* development;
149 FMTVertexLookup() = default;
150 ~FMTVertexLookup() = default;
151 //For looking
152 FMTVertexLookup(const Core::FMTDevelopment& dev) :
153 descriptor(), development(&dev)
154 {
155
156 }
157 //For keeping
158 FMTVertexLookup(const tdescriptor& des, const Core::FMTDevelopment& dev) :
159 descriptor(des), development(&dev)
160 {
161
162 }
163 FMTVertexLookup(const FMTVertexLookup& rhs) :
164 descriptor(rhs.descriptor), development(rhs.development)
165 {
166
167 }
168 FMTVertexLookup& operator = (const FMTVertexLookup& rhs)
169 {
170 if (*this!=&rhs)
171 {
172 descriptor = rhs.descriptor;
173 development = rhs.development;
174 }
175 return *this;
176 }
177 bool operator == (const FMTVertexLookup& rhs) const
178 {
179 return (development != nullptr && rhs.development != nullptr && (*development) == (*rhs.development));
180 }
181
182 };
183}
184
185namespace boost
186{
187
188 template<class tdescriptor>
189 struct hash<Graph::FMTVertexLookup<tdescriptor>>
190 {
191 std::size_t operator()(const Graph::FMTVertexLookup<tdescriptor>& lookup) const
192 {
193 return lookup.development->hash();
194 }
195 };
196
197
198}*/
199
200#endif
Lookup helper holding an in-memory object and a pointer to a keyed object, used for hashing and compa...
Definition: FMTLookup.h:24
const pointer * pointerobject
Definition: FMTLookup.h:27
bool operator==(const FMTLookup &rhs) const
Equality comparison operator of FMTLookup.
Definition: FMTLookup.h:112
FMTLookup()=default
Default constructor for FMTLookup.
bool operator<(const FMTLookup &rhs) const
Less than comparison operator of FMTLookup.
Definition: FMTLookup.h:92
FMTLookup(const inmemory &des, const pointer &dev)
Construct a lookup for keeping from an in-memory object and a pointer.
Definition: FMTLookup.h:56
FMTLookup(const FMTLookup &rhs)
Copy constructor for FMTLookup.
Definition: FMTLookup.h:66
inmemory memoryobject
Definition: FMTLookup.h:26
FMTLookup(const pointer &ptr)
Construct a lookup for searching from a pointer.
Definition: FMTLookup.h:44
FMTLookup & operator=(const FMTLookup &rhs)
Copy assignment operator for FMTLookup.
Definition: FMTLookup.h:77
~FMTLookup()=default
Default destructor for FMTLookup.
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
Definition: FMTAction.h:463
std::size_t operator()(const Core::FMTLookup< inmemory, pointer > &lookup) const
Definition: FMTLookup.h:126