ClientSideRemoteHandleControlBlock.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18* @package ArmarXCore
19* @author Raphael Grimm ( raphael dot grimm at kit dot edu)
20* @date 2016
21* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22* GNU General Public License
23*/
24#pragma once
25
26#include <memory>
27
28#include <ArmarXCore/interface/core/util/distributed/RemoteHandle/ClientSideRemoteHandleControlBlock.h>
29#include <ArmarXCore/interface/core/util/distributed/RemoteHandle/RemoteHandleControlBlock.h>
30
31namespace armarx
32{
35 std::shared_ptr<ClientSideRemoteHandleControlBlock>;
36
37 /**
38 * @brief The ClientSideRemoteHandleControlBlock is used at the client side for reference counting.
39 * It is send from the server to the client.
40 * Its dtor decrements the use count.
41 * If you get this class put it into a RemoteHandle!
42 * (for more info: \ref ArmarXCore-Tutorials-RemoteHandles "RemoteHandle tutorial")
43 *
44 * \ingroup Distributed
45 */
46 class ClientSideRemoteHandleControlBlock : public ClientSideRemoteHandleControlBlockBase
47 {
48 public:
49 ClientSideRemoteHandleControlBlock(const RemoteHandleControlBlockInterfacePrx& controlBlock,
50 const Ice::ObjectPrx& object);
53
55
58 template <class T>
60
61 void ice_postUnmarshal() override;
62 Ice::ObjectPrx getManagedObjectProxy(const Ice::Current& = Ice::emptyCurrent) override;
63
64 private:
65 template <class IceBaseClass, class DerivedClass>
66 friend class GenericFactory;
68 };
69
71 const RemoteHandleControlBlockInterfacePrx& controlBlock,
72 const Ice::ObjectPrx& object) :
73 ClientSideRemoteHandleControlBlockBase(controlBlock, object)
74 {
75 assert(managedObjectProxy);
76 assert(remoteHandleControlBlockProxy);
77 if (!managedObjectProxy || !remoteHandleControlBlockProxy)
78 {
79 throw std::invalid_argument{"Either the control block or the object proxy is null!"};
80 }
81 remoteHandleControlBlockProxy->incrementUseCount();
82 }
83
85 {
86 try
87 {
88 if (remoteHandleControlBlockProxy)
89 {
90 remoteHandleControlBlockProxy->decrementUseCount();
91 }
92 }
93 catch (...)
94 {
95 // never throw
96 }
97 }
98
99 inline void
101 {
102 remoteHandleControlBlockProxy->incrementUseCount();
103 }
104
105 inline Ice::ObjectPrx
107 {
108 return managedObjectProxy;
109 }
110} // namespace armarx
The ClientSideRemoteHandleControlBlock is used at the client side for reference counting.
ClientSideRemoteHandleControlBlock(ClientSideRemoteHandleControlBlock &&)=default
Ice::ObjectPrx getManagedObjectProxy(const Ice::Current &=Ice::emptyCurrent) override
ClientSideRemoteHandleControlBlock & operator=(T &&)=delete
ClientSideRemoteHandleControlBlock & operator=(ClientSideRemoteHandleControlBlock &&other)=default
ClientSideRemoteHandleControlBlock(const ClientSideRemoteHandleControlBlock &)=delete
ClientSideRemoteHandleControlBlock(const RemoteHandleControlBlockInterfacePrx &controlBlock, const Ice::ObjectPrx &object)
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< ClientSideRemoteHandleControlBlock > ClientSideRemoteHandleControlBlockPtr