Main MRPT website > C++ reference for MRPT 1.4.0
CProbabilityParticle.h
Go to the documentation of this file.
1/* +---------------------------------------------------------------------------+
2 | Mobile Robot Programming Toolkit (MRPT) |
3 | http://www.mrpt.org/ |
4 | |
5 | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6 | See: http://www.mrpt.org/Authors - All rights reserved. |
7 | Released under BSD License. See details in http://www.mrpt.org/License |
8 +---------------------------------------------------------------------------+ */
9#ifndef CPROBABILITYPARTICLE_H
10#define CPROBABILITYPARTICLE_H
11
12namespace mrpt
13{
14namespace bayes
15{
16 /** A template class for holding a the data and the weight of a particle.
17 * Particles are composed of two parts:
18 * - A state vector descritor, which in this case can be any user defined CSerializable class
19 * - A (logarithmic) weight value.
20 *
21 * This structure is used within CParticleFilterData, see that class for more information.
22 * \ingroup mrpt_base_grp
23 */
24 template <class T>
26 {
27 public:
28 /** The data associated with this particle.
29 */
30 T *d;
31
32 /** The (logarithmic) weight value for this particle.
33 */
34 double log_w;
35
36 /** Default constructor:
37 */
39 {
40 }
41
42 /** Copy constructor:
43 */
45 {
46 if (o.d)
47 {
48 // Copy
49 d = new T(*o.d);
50 }
51 }
52
53 /** Copy operator
54 */
56 {
57 if (this == &o) return *this;
58 log_w = o.log_w;
59 if (o.d)
60 {
61 // Copy semantic:
62 if (d)
63 *d = *o.d; // Copy using the object "operator =".
64 else d = new T(*o.d); // Create a new object from the copy constructor
65 }
66 else
67 {
68 if (d)
69 {
70 delete d;
71 d = NULL;
72 }
73 }
74 return *this;
75 }
76 };
77
78 } // end namespace
79} // end namespace
80#endif
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A template class for holding a the data and the weight of a particle.
T * d
The data associated with this particle.
CProbabilityParticle(const CProbabilityParticle &o)
Copy constructor:
CProbabilityParticle()
Default constructor:
CProbabilityParticle< T > & operator=(const CProbabilityParticle &o)
Copy operator.
double log_w
The (logarithmic) weight value for this particle.



Page generated by Doxygen 1.9.5 for MRPT 1.4.0 SVN: at Sun Nov 27 02:56:26 UTC 2022