GCC Code Coverage Report


Directory: ./
File: include/pinocchio/algorithm/constraints/constraint-data-generic.hpp
Date: 2025-02-12 21:03:38
Exec Total Coverage
Lines: 14 14 100.0%
Branches: 1 2 50.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> class ConstraintCollectionTpl>
20 struct traits<ConstraintDataTpl<_Scalar, _Options, ConstraintCollectionTpl>>
21 {
22 typedef _Scalar Scalar;
23 enum
24 {
25 Options = _Options
26 };
27 typedef ConstraintModelTpl<Scalar, Options, ConstraintCollectionTpl> ConstraintModel;
28 };
29
30 template<
31 typename _Scalar,
32 int _Options,
33 template<typename S, int O> class ConstraintCollectionTpl>
34 struct ConstraintDataTpl
35 : ConstraintDataBase<ConstraintDataTpl<_Scalar, _Options, ConstraintCollectionTpl>>
36 , ConstraintCollectionTpl<_Scalar, _Options>::ConstraintDataVariant
37 {
38 typedef ConstraintDataBase<ConstraintModelTpl<_Scalar, _Options, ConstraintCollectionTpl>> Base;
39 typedef _Scalar Scalar;
40 enum
41 {
42 Options = _Options
43 };
44
45 typedef ConstraintCollectionTpl<Scalar, Options> ConstraintCollection;
46 typedef typename ConstraintCollection::ConstraintDataVariant ConstraintDataVariant;
47 typedef typename ConstraintCollection::ConstraintModelVariant ConstraintModelVariant;
48
49 ConstraintDataTpl()
50 : ConstraintDataVariant()
51 {
52 }
53
54 1 ConstraintDataTpl(const ConstraintDataVariant & cdata_variant)
55 1 : ConstraintDataVariant(cdata_variant)
56 {
57 1 }
58
59 template<typename ContraintDataDerived>
60 7 ConstraintDataTpl(const ConstraintDataBase<ContraintDataDerived> & cdata)
61 7 : ConstraintDataVariant((ConstraintDataVariant)cdata.derived())
62 {
63 BOOST_MPL_ASSERT(
64 (boost::mpl::contains<typename ConstraintDataVariant::types, ContraintDataDerived>));
65 7 }
66
67 ConstraintDataVariant & toVariant()
68 {
69 return static_cast<ConstraintDataVariant &>(*this);
70 }
71
72 6 const ConstraintDataVariant & toVariant() const
73 {
74 6 return static_cast<const ConstraintDataVariant &>(*this);
75 }
76
77 template<typename ConstraintDataDerived>
78 bool isEqual(const ConstraintDataBase<ConstraintDataDerived> & other) const
79 {
80 return ::pinocchio::isEqual(*this, other.derived());
81 }
82
83 3 bool isEqual(const ConstraintDataTpl & other) const
84 {
85 3 return /*Base::isEqual(other) &&*/ toVariant() == other.toVariant();
86 }
87
88 3 bool operator==(const ConstraintDataTpl & other) const
89 {
90 3 return isEqual(other);
91 }
92
93 bool operator!=(const ConstraintDataTpl & other) const
94 {
95 return !(*this == other);
96 }
97 };
98
99 template<
100 typename ConstraintDataDerived,
101 typename Scalar,
102 int Options,
103 template<typename S, int O> class ConstraintCollectionTpl>
104 1 bool operator==(
105 const ConstraintDataBase<ConstraintDataDerived> & data1,
106 const ConstraintDataTpl<Scalar, Options, ConstraintCollectionTpl> & data2)
107 {
108
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 return data2 == data1.derived();
109 }
110
111 } // namespace pinocchio
112
113 #endif // ifndef __pinocchio_algorithm_constraint_data_generic_hpp__
114