GCC Code Coverage Report


Directory: ./
File: src/basic-server.hh
Date: 2024-09-11 11:37:19
Exec Total Coverage
Lines: 22 23 95.7%
Branches: 24 48 50.0%

Line Branch Exec Source
1 // Copyright (C) 2019 CNRS-LAAS
2 // Author: Joseph Mirabel
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 #ifndef HPP_CORBASERVER_BASIC_SERVER_HH
30 #define HPP_CORBASERVER_BASIC_SERVER_HH
31
32 #include <hpp/corba/template/server.hh>
33 #include <hpp/corbaserver/server-plugin.hh>
34 #include <hpp/util/exception.hh>
35 #include <stdexcept>
36
37 #include "obstacle.impl.hh"
38 #include "problem.impl.hh"
39 #include "robot.impl.hh"
40
41 namespace hpp {
42 namespace corbaServer {
43 namespace impl {
44 class Obstacle;
45 class Problem;
46 class Robot;
47 } // namespace impl
48
49 class HPP_CORBASERVER_LOCAL BasicServer : public ServerPlugin {
50 public:
51 BasicServer(Server* parent);
52
53 ~BasicServer();
54
55 /// Start corba server
56 void startCorbaServer(const std::string& contextId,
57 const std::string& contextKind);
58
59 ::CORBA::Object_ptr servant(const std::string& name) const;
60
61 std::string name() const;
62
63 private:
64 corba::Server<impl::Obstacle>* obstacleImpl_;
65 corba::Server<impl::Problem>* problemImpl_;
66 corba::Server<impl::Robot>* robotImpl_;
67 }; // class ServerPlugin
68
69 8 BasicServer::BasicServer(Server* parent)
70 : ServerPlugin(parent),
71 8 obstacleImpl_(NULL),
72 8 problemImpl_(NULL),
73 8 robotImpl_(NULL) {}
74
75 32 BasicServer::~BasicServer() {
76
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
16 if (obstacleImpl_) delete obstacleImpl_;
77
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
16 if (problemImpl_) delete problemImpl_;
78
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
16 if (robotImpl_) delete robotImpl_;
79 32 }
80
81
1/2
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 std::string BasicServer::name() const { return "basic"; }
82
83 /// Start corba server
84 8 void BasicServer::startCorbaServer(const std::string& contextId,
85 const std::string& contextKind) {
86
3/6
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
8 initializeTplServer(obstacleImpl_, contextId, contextKind, name(),
87 "obstacle");
88
3/6
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
8 initializeTplServer(problemImpl_, contextId, contextKind, name(), "problem");
89
3/6
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
8 initializeTplServer(robotImpl_, contextId, contextKind, name(), "robot");
90
91 8 obstacleImpl_->implementation().setServer(this);
92 8 problemImpl_->implementation().setServer(this);
93 8 robotImpl_->implementation().setServer(this);
94 8 }
95
96 27 ::CORBA::Object_ptr BasicServer::servant(const std::string& name) const {
97
3/4
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 18 times.
✓ Branch 5 taken 9 times.
✗ Branch 6 not taken.
27 if (name == "obstacle") return obstacleImpl_->implementation()._this();
98
3/4
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 5 taken 9 times.
✗ Branch 6 not taken.
18 if (name == "problem") return problemImpl_->implementation()._this();
99
2/4
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 9 times.
✗ Branch 6 not taken.
9 if (name == "robot") return robotImpl_->implementation()._this();
100 throw std::invalid_argument("No servant " + name);
101 }
102 } // namespace corbaServer
103 } // namespace hpp
104
105 #endif // HPP_CORBASERVER_SERVER_PLUGIN_HH
106