GCC Code Coverage Report


Directory: ./
File: include/pinocchio/algorithm/constraints/constraint-data-generic.hpp
Date: 2024-08-27 18:20:05
Exec Total Coverage
Lines: 0 12 0.0%
Branches: 0 2 0.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2023 INRIA
3 //
4
5 #ifndef __pinocchio_algorithm_constraint_data_generic_hpp__
6 #define __pinocchio_algorithm_constraint_data_generic_hpp__
7
8 #include "pinocchio/algorithm/constraints/fwd.hpp"
9 #include "pinocchio/algorithm/constraints/constraint-model-base.hpp"
10 #include "pinocchio/algorithm/constraints/constraint-data-base.hpp"
11 #include "pinocchio/algorithm/constraints/visitors/constraint-model-visitor.hpp"
12
13 namespace pinocchio
14 {
15
16 template<
17 typename _Scalar,
18 int _Options,
19 template<typename S, int O>
20 class ConstraintCollectionTpl>
21 struct traits<ConstraintDataTpl<_Scalar, _Options, ConstraintCollectionTpl>>
22 {
23 typedef _Scalar Scalar;
24 enum
25 {
26 Options = _Options
27 };
28 typedef ConstraintModelTpl<Scalar, Options, ConstraintCollectionTpl> ConstraintModel;
29 };
30
31 template<
32 typename _Scalar,
33 int _Options,
34 template<typename S, int O>
35 class ConstraintCollectionTpl>
36 struct ConstraintDataTpl
37 : ConstraintDataBase<ConstraintDataTpl<_Scalar, _Options, ConstraintCollectionTpl>>
38 , ConstraintCollectionTpl<_Scalar, _Options>::ConstraintDataVariant
39 {
40 typedef ConstraintDataBase<ConstraintModelTpl<_Scalar, _Options, ConstraintCollectionTpl>> Base;
41 typedef _Scalar Scalar;
42 enum
43 {
44 Options = _Options
45 };
46
47 typedef ConstraintCollectionTpl<Scalar, Options> ConstraintCollection;
48 typedef typename ConstraintCollection::ConstraintDataVariant ConstraintDataVariant;
49 typedef typename ConstraintCollection::ConstraintModelVariant ConstraintModelVariant;
50
51 ConstraintDataTpl()
52 : ConstraintDataVariant()
53 {
54 }
55
56 ConstraintDataTpl(const ConstraintDataVariant & cdata_variant)
57 : ConstraintDataVariant(cdata_variant)
58 {
59 }
60
61 template<typename ContraintDataDerived>
62 ConstraintDataTpl(const ConstraintDataBase<ContraintDataDerived> & cdata)
63 : ConstraintDataVariant((ConstraintDataVariant)cdata.derived())
64 {
65 BOOST_MPL_ASSERT(
66 (boost::mpl::contains<typename ConstraintDataVariant::types, ContraintDataDerived>));
67 }
68
69 ConstraintDataVariant & toVariant()
70 {
71 return static_cast<ConstraintDataVariant &>(*this);
72 }
73
74 const ConstraintDataVariant & toVariant() const
75 {
76 return static_cast<const ConstraintDataVariant &>(*this);
77 }
78
79 template<typename ConstraintDataDerived>
80 bool isEqual(const ConstraintDataBase<ConstraintDataDerived> & other) const
81 {
82 return ::pinocchio::isEqual(*this, other.derived());
83 }
84
85 bool isEqual(const ConstraintDataTpl & other) const
86 {
87 return /*Base::isEqual(other) &&*/ toVariant() == other.toVariant();
88 }
89
90 bool operator==(const ConstraintDataTpl & other) const
91 {
92 return isEqual(other);
93 }
94
95 bool operator!=(const ConstraintDataTpl & other) const
96 {
97 return !(*this == other);
98 }
99 };
100
101 template<
102 typename ConstraintDataDerived,
103 typename Scalar,
104 int Options,
105 template<typename S, int O>
106 class ConstraintCollectionTpl>
107 bool operator==(
108 const ConstraintDataBase<ConstraintDataDerived> & data1,
109 const ConstraintDataTpl<Scalar, Options, ConstraintCollectionTpl> & data2)
110 {
111 return data2 == data1.derived();
112 }
113
114 } // namespace pinocchio
115
116 #endif // ifndef __pinocchio_algorithm_constraint_data_generic_hpp__
117