FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTlookup.hpp
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_H_INCLUDED
9#define FMTlookup_H_INCLUDED
10
11//#include "FMTdevelopment.hpp"
12#include <boost/functional/hash.hpp>
13
14namespace Core
15{
16 template<class inmemory,class pointer>
18 {
19 public:
20 inmemory memoryobject;
21 const pointer* pointerobject;
22 FMTlookup() = default;
23 ~FMTlookup() = default;
24 //For looking
25 FMTlookup(const pointer& ptr) :
27 {
28
29 }
30 //For keeping
31 FMTlookup(const inmemory& des, const pointer& dev) :
32 memoryobject(des), pointerobject(&dev)
33 {
34
35 }
36 FMTlookup(const FMTlookup& rhs) :
38 {
39
40 }
42 {
43 if (this != &rhs)
44 {
47 }
48 return *this;
49 }
50 bool operator < (const FMTlookup& rhs) const
51 {
52 //strict ordering
53 if (pointerobject == nullptr)
54 return true;
55 if (rhs.pointerobject == nullptr)
56 return false;
57 if ((*pointerobject) < (*rhs.pointerobject))
58 return true;
59 if ((*rhs.pointerobject) < (*pointerobject))
60 return false;
61 return false;
62 }
63
64 bool operator == (const FMTlookup& rhs) const
65 {
66 return (pointerobject != nullptr && rhs.pointerobject != nullptr && (*pointerobject) == (*rhs.pointerobject));
67 }
68
69 };
70}
71
72namespace boost
73{
74
75 template<class inmemory, class pointer>
76 struct hash<Core::FMTlookup<inmemory,pointer>>
77 {
78 std::size_t operator()(const Core::FMTlookup<inmemory, pointer>& lookup) const
79 {
80 return lookup.pointerobject->hash();
81 }
82 };
83
84 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
85 {
86 return boost::hash<std::string>()(*lookup.pointerobject);
87 }
88
89
90}
91
92/*
93namespace Graph
94{
95 template<class tdescriptor>
96 class FMTvertexlookup
97 {
98 public:
99 tdescriptor descriptor;
100 const Core::FMTdevelopment* development;
101 FMTvertexlookup() = default;
102 ~FMTvertexlookup() = default;
103 //For looking
104 FMTvertexlookup(const Core::FMTdevelopment& dev) :
105 descriptor(), development(&dev)
106 {
107
108 }
109 //For keeping
110 FMTvertexlookup(const tdescriptor& des, const Core::FMTdevelopment& dev) :
111 descriptor(des), development(&dev)
112 {
113
114 }
115 FMTvertexlookup(const FMTvertexlookup& rhs) :
116 descriptor(rhs.descriptor), development(rhs.development)
117 {
118
119 }
120 FMTvertexlookup& operator = (const FMTvertexlookup& rhs)
121 {
122 if (*this!=&rhs)
123 {
124 descriptor = rhs.descriptor;
125 development = rhs.development;
126 }
127 return *this;
128 }
129 bool operator == (const FMTvertexlookup& rhs) const
130 {
131 return (development != nullptr && rhs.development != nullptr && (*development) == (*rhs.development));
132 }
133
134 };
135}
136
137namespace boost
138{
139
140 template<class tdescriptor>
141 struct hash<Graph::FMTvertexlookup<tdescriptor>>
142 {
143 std::size_t operator()(const Graph::FMTvertexlookup<tdescriptor>& lookup) const
144 {
145 return lookup.development->hash();
146 }
147 };
148
149
150}*/
151
152#endif
Definition: FMTlookup.hpp:18
FMTlookup(const pointer &ptr)
Definition: FMTlookup.hpp:25
FMTlookup(const FMTlookup &rhs)
Definition: FMTlookup.hpp:36
const pointer * pointerobject
Definition: FMTlookup.hpp:21
bool operator==(const FMTlookup &rhs) const
Definition: FMTlookup.hpp:64
FMTlookup()=default
FMTlookup(const inmemory &des, const pointer &dev)
Definition: FMTlookup.hpp:31
~FMTlookup()=default
inmemory memoryobject
Definition: FMTlookup.hpp:20
FMTlookup & operator=(const FMTlookup &rhs)
Definition: FMTlookup.hpp:41
bool operator<(const FMTlookup &rhs) const
Definition: FMTlookup.hpp:50
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
Definition: FMTaction.hpp:364
std::size_t operator()(const Core::FMTlookup< inmemory, pointer > &lookup) const
Definition: FMTlookup.hpp:78