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 
31 namespace armarx
32 {
33  class ClientSideRemoteHandleControlBlock;
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 
70  inline ClientSideRemoteHandleControlBlock::ClientSideRemoteHandleControlBlock(
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
armarx::ClientSideRemoteHandleControlBlock::operator=
ClientSideRemoteHandleControlBlock & operator=(ClientSideRemoteHandleControlBlock &&other)=default
armarx::ClientSideRemoteHandleControlBlock::~ClientSideRemoteHandleControlBlock
~ClientSideRemoteHandleControlBlock() override
Definition: ClientSideRemoteHandleControlBlock.h:84
armarx::ClientSideRemoteHandleControlBlock::getManagedObjectProxy
Ice::ObjectPrx getManagedObjectProxy(const Ice::Current &=Ice::emptyCurrent) override
Definition: ClientSideRemoteHandleControlBlock.h:106
armarx::ClientSideRemoteHandleControlBlock::ice_postUnmarshal
void ice_postUnmarshal() override
Definition: ClientSideRemoteHandleControlBlock.h:100
armarx::ClientSideRemoteHandleControlBlock
The ClientSideRemoteHandleControlBlock is used at the client side for reference counting.
Definition: ClientSideRemoteHandleControlBlock.h:46
armarx::GenericFactory
Definition: FactoryCollectionBase.h:51
T
float T
Definition: UnscentedKalmanFilterTest.cpp:38
armarx::ClientSideRemoteHandleControlBlockPtr
std::shared_ptr< ClientSideRemoteHandleControlBlock > ClientSideRemoteHandleControlBlockPtr
Definition: ClientSideRemoteHandleControlBlock.h:35
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27