GCC Code Coverage Report


Directory: ./
File: src/constraint-set.cc
Date: 2025-03-07 11:10:46
Exec Total Coverage
Lines: 12 29 41.4%
Branches: 3 22 13.6%

Line Branch Exec Source
1 // Copyright (c) 2015, Joseph Mirabel
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // 1. Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28
29 #include "hpp/manipulation/constraint-set.hh"
30
31 #include <hpp/util/serialization.hh>
32
33 #include "hpp/manipulation/device.hh"
34 #include "hpp/manipulation/graph/edge.hh"
35 #include "hpp/manipulation/serialization.hh"
36
37 namespace hpp {
38 namespace manipulation {
39 20 ConstraintSetPtr_t ConstraintSet::create(const DevicePtr_t& robot,
40 const std::string& name) {
41
1/2
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 ConstraintSet* ptr = new ConstraintSet(robot, name);
42 20 ConstraintSetPtr_t shPtr(ptr);
43
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 ptr->init(shPtr);
44 20 return shPtr;
45 }
46
47 ConstraintSetPtr_t ConstraintSet::createCopy(const ConstraintSetPtr_t& cs) {
48 ConstraintSet* ptr = new ConstraintSet(*cs);
49 ConstraintSetPtr_t shPtr(ptr);
50 ptr->init(shPtr);
51 return shPtr;
52 }
53
54 ConstraintPtr_t ConstraintSet::copy() const { return createCopy(weak_.lock()); }
55
56 16 void ConstraintSet::edge(graph::EdgePtr_t edge) { edge_ = edge; }
57
58 graph::EdgePtr_t ConstraintSet::edge() const { return edge_; }
59
60 20 ConstraintSet::ConstraintSet(const DevicePtr_t& robot, const std::string& name)
61
1/2
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 : Parent_t(robot, name), edge_() {}
62
63 ConstraintSet::ConstraintSet(const ConstraintSet& other)
64 : Parent_t(other), edge_(other.edge()) {}
65
66 20 void ConstraintSet::init(const ConstraintSetPtr_t& self) {
67 20 Parent_t::init(self);
68 20 weak_ = self;
69 20 }
70
71 std::ostream& ConstraintSet::print(std::ostream& os) const {
72 Parent_t::print(os);
73 if (edge_) os << iendl << "Built by edge " << edge_->name();
74 return os;
75 }
76
77 template <class Archive>
78 void ConstraintSet::serialize(Archive& ar, const unsigned int version) {
79 using namespace boost::serialization;
80 (void)version;
81 ar& make_nvp("base", base_object<core::ConstraintSet>(*this));
82 ar& BOOST_SERIALIZATION_NVP(edge_);
83 ar& BOOST_SERIALIZATION_NVP(weak_);
84 }
85
86 HPP_SERIALIZATION_IMPLEMENT(ConstraintSet);
87 } // namespace manipulation
88 } // namespace hpp
89
90 BOOST_CLASS_EXPORT_IMPLEMENT(hpp::manipulation::ConstraintSet)
91