cheshirekow  v0.1.0
result.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of mpblocks.
5  *
6  * mpblocks is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * mpblocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with mpblocks. If not, see <http://www.gnu.org/licenses/>.
18  */
27 #ifndef MPBLOCKS_DUBINS_CURVES_RESULT_H_
28 #define MPBLOCKS_DUBINS_CURVES_RESULT_H_
29 
30 #ifndef __host__
31 #define __host__
32 #endif
33 
34 #ifndef __device__
35 #define __device__
36 #endif
37 
38 namespace mpblocks {
39 namespace dubins {
40 
43 template <typename Format_t>
44 struct Result {
45  Format_t d;
46  bool f;
47 
50  Result() : d(0), f(false) {}
51 
54  Result(Format_t d, bool f = true) : d(d), f(f) {}
55 
58  operator Format_t() const { return d; }
59 
61  operator bool() const { return f; }
62 
64  Result<Format_t>& operator=(Format_t d_in) {
65  d = d_in;
66  f = true;
67  return *this;
68  }
69 
72  const Result<Format_t>& other) {
73  d = other.d;
74  f = other.f;
75  return *this;
76  }
77 };
78 
81 template <typename Format_t>
82 struct DistanceAndId {
83  Format_t d;
84  int id;
85 
87  DistanceAndId() : d(0), id(INVALID) {}
88 
90  DistanceAndId(Format_t d, SolutionId id) : d(d), id(id) {}
91 
94  operator bool() const { return (id != INVALID); }
95 
98  void set(Format_t d_in, int id_in) {
99  d = d_in;
100  id = id_in;
101  }
102 
105  const Result<Format_t>& other) {
106  id = other.id;
107  d = other.d;
108  return *this;
109  }
110 };
111 
112 } // dubins
113 } // mpblocks
114 
115 #endif // MPBLOCKS_DUBINS_CURVES_RESULT_H_
__device__ __host__ Result< Format_t > & operator=(const Result< Format_t > &other)
Definition: result.h:71
Format_t d
distance
Definition: result.h:45
Format_t d
distance
Definition: result.h:83
__device__ __host__ Result< Format_t > & operator=(const Result< Format_t > &other)
Definition: result.h:104
__device__ __host__ Result()
the default constructor is for infeasible
Definition: result.h:50
__device__ __host__ DistanceAndId()
Definition: result.h:87
#define __device__
Definition: result.h:35
#define __host__
Definition: result.h:31
bool f
is feasible
Definition: result.h:46
__device__ __host__ Result(Format_t d, bool f=true)
we only use this constructor when it's feasible
Definition: result.h:54
Encapsulates the solution distance along with a feasibility bit for a particular primitive solution...
Definition: result.h:44
BinaryKey other(const BinaryKey &key)
Definition: BinaryKey.h:44
__device__ __host__ DistanceAndId(Format_t d, SolutionId id)
Definition: result.h:90
__device__ __host__ Result< Format_t > & operator=(Format_t d_in)
Definition: result.h:64
SolutionId
enumerates solution types
Definition: types.h:49
__device__ __host__ void set(Format_t d_in, int id_in)
set the storage and make the flag true
Definition: result.h:98
Encapsulates a solution distance along with the id of the path type, identifying the nature of the th...
Definition: result.h:82