SubscriptionHandle.cpp
Go to the documentation of this file.
1 #include "SubscriptionHandle.h"
2 
3 #include "MemoryListener.h"
4 
6 {
7  SubscriptionHandle::SubscriptionHandle(MemoryListener* memoryListener,
8  const MemoryID& memoryID,
9  long id) :
10  valid{true}, memoryListener{memoryListener}, memoryID(memoryID), id{id}
11  {
12  }
13 
15  {
16  }
17 
19  valid{other.valid},
20  memoryListener{other.memoryListener},
21  memoryID(std::move(other.memoryID)),
22  id{other.id}
23  {
24  other.valid = false;
25  }
26 
27  SubscriptionHandle&
29  {
30  swap(*this, other);
31  return *this;
32  }
33 
34  void
36  {
37  memoryListener->unsubscribe(*this);
38  }
39 
41  {
42  }
43 
45  handle(std::move(handle))
46  {
47  }
48 
51  {
52  std::swap(this->handle, handle);
53  return *this;
54  }
55 
57  {
58  handle.release();
59  }
60 
61 } // namespace armarx::armem::client::util
62 
63 namespace armarx::armem::client
64 {
65  void
67  {
68  std::swap(first.valid, second.valid);
69  std::swap(first.memoryListener, second.memoryListener);
70  std::swap(first.memoryID, second.memoryID);
71  std::swap(first.id, second.id);
72  }
73 } // namespace armarx::armem::client
armarx::armem::client::util::SubscriptionHandle::operator=
SubscriptionHandle & operator=(SubscriptionHandle other)
Assignment operator.
Definition: SubscriptionHandle.cpp:28
armarx::armem::client::util::ScopedSubscriptionHandle::ScopedSubscriptionHandle
ScopedSubscriptionHandle()
Definition: SubscriptionHandle.cpp:40
armarx::armem::client
This file is part of ArmarX.
Definition: forward_declarations.h:7
armarx::armem::client::util::swap
void swap(SubscriptionHandle &first, SubscriptionHandle &second)
Definition: SubscriptionHandle.cpp:66
armarx::armem::client::util::SubscriptionHandle
Definition: SubscriptionHandle.h:10
armarx::armem::client::util::ScopedSubscriptionHandle
Definition: SubscriptionHandle.h:40
armarx::armem::client::util::ScopedSubscriptionHandle::operator=
ScopedSubscriptionHandle & operator=(SubscriptionHandle handle)
Assignment operator.
Definition: SubscriptionHandle.cpp:50
armarx::armem::client::util::ScopedSubscriptionHandle::~ScopedSubscriptionHandle
~ScopedSubscriptionHandle()
Definition: SubscriptionHandle.cpp:56
armarx::armem::client::util::SubscriptionHandle::swap
friend void swap(SubscriptionHandle &first, SubscriptionHandle &second)
SubscriptionHandle.h
std
Definition: Application.h:66
armarx::armem::client::util::SubscriptionHandle::release
void release()
Definition: SubscriptionHandle.cpp:35
armarx::armem::index::memoryID
const MemoryID memoryID
Definition: memory_ids.cpp:29
armarx::armem::client::util
Definition: MemoryListener.cpp:13
armarx::armem::client::util::MemoryListener::unsubscribe
void unsubscribe(SubscriptionHandle &subscriptionHandle)
Definition: MemoryListener.cpp:144
MemoryListener.h
armarx::armem::client::util::SubscriptionHandle::SubscriptionHandle
SubscriptionHandle()
Definition: SubscriptionHandle.cpp:14
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition: memory_ids.cpp:29