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/RemoteHandleControlBlock.h>
29 #include <ArmarXCore/interface/core/util/distributed/RemoteHandle/ClientSideRemoteHandleControlBlock.h>
30 
31 namespace armarx
32 {
33  class ClientSideRemoteHandleControlBlock;
34  using ClientSideRemoteHandleControlBlockPtr = std::shared_ptr<ClientSideRemoteHandleControlBlock>;
35 
36  /**
37  * @brief The ClientSideRemoteHandleControlBlock is used at the client side for reference counting.
38  * It is send from the server to the client.
39  * Its dtor decrements the use count.
40  * If you get this class put it into a RemoteHandle!
41  * (for more info: \ref ArmarXCore-Tutorials-RemoteHandles "RemoteHandle tutorial")
42  *
43  * \ingroup Distributed
44  */
46  public ClientSideRemoteHandleControlBlockBase
47  {
48  public:
49  ClientSideRemoteHandleControlBlock(const RemoteHandleControlBlockInterfacePrx& controlBlock, const Ice::ObjectPrx& object);
52 
54 
56  template<class T>
58 
59  void ice_postUnmarshal() override;
60  Ice::ObjectPrx getManagedObjectProxy(const Ice::Current& = Ice::emptyCurrent) override;
61  private:
62  template <class IceBaseClass, class DerivedClass> friend class GenericFactory;
64  };
65 
66  inline ClientSideRemoteHandleControlBlock::ClientSideRemoteHandleControlBlock(const RemoteHandleControlBlockInterfacePrx& controlBlock, const Ice::ObjectPrx& object):
67  ClientSideRemoteHandleControlBlockBase(controlBlock, object)
68  {
69  assert(managedObjectProxy);
70  assert(remoteHandleControlBlockProxy);
71  if (!managedObjectProxy || !remoteHandleControlBlockProxy)
72  {
73  throw std::invalid_argument {"Either the control block or the object proxy is null!"};
74  }
75  remoteHandleControlBlockProxy->incrementUseCount();
76  }
77 
79  {
80  try
81  {
82  if (remoteHandleControlBlockProxy)
83  {
84  remoteHandleControlBlockProxy->decrementUseCount();
85  }
86  }
87  catch (...)
88  {
89  // never throw
90  }
91  }
92 
94  {
95  remoteHandleControlBlockProxy->incrementUseCount();
96  }
97 
98  inline Ice::ObjectPrx ClientSideRemoteHandleControlBlock::getManagedObjectProxy(const Ice::Current&)
99  {
100  return managedObjectProxy;
101  }
102 }
armarx::ClientSideRemoteHandleControlBlock::operator=
ClientSideRemoteHandleControlBlock & operator=(ClientSideRemoteHandleControlBlock &&other)=default
armarx::ClientSideRemoteHandleControlBlock::~ClientSideRemoteHandleControlBlock
~ClientSideRemoteHandleControlBlock() override
Definition: ClientSideRemoteHandleControlBlock.h:78
armarx::ClientSideRemoteHandleControlBlock::getManagedObjectProxy
Ice::ObjectPrx getManagedObjectProxy(const Ice::Current &=Ice::emptyCurrent) override
Definition: ClientSideRemoteHandleControlBlock.h:98
armarx::ClientSideRemoteHandleControlBlock::ice_postUnmarshal
void ice_postUnmarshal() override
Definition: ClientSideRemoteHandleControlBlock.h:93
armarx::ClientSideRemoteHandleControlBlock
The ClientSideRemoteHandleControlBlock is used at the client side for reference counting.
Definition: ClientSideRemoteHandleControlBlock.h:45
armarx::GenericFactory
Definition: FactoryCollectionBase.h:51
T
float T
Definition: UnscentedKalmanFilterTest.cpp:35
armarx::ClientSideRemoteHandleControlBlockPtr
std::shared_ptr< ClientSideRemoteHandleControlBlock > ClientSideRemoteHandleControlBlockPtr
Definition: ClientSideRemoteHandleControlBlock.h:34
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28