summaryrefslogtreecommitdiff
path: root/p2pvr/lib/temporaryIceAdapterObject.h
blob: 949661a9865ced4a3dd0748d8f1a25031e6ad374 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef TEMPORARYICEADAPTER_H
#define TEMPORARYICEADAPTER_H

#include <Ice/ObjectAdapter.h>

template <typename Object>
class TemporaryIceAdapterObject {
	public:
		TemporaryIceAdapterObject(Ice::ObjectAdapterPtr a, Object * o) :
			adapter(a),
			object(o),
			proxy(Object::ProxyType::checkedCast(adapter->addWithUUID(object)))
		{
			if (!proxy) {
			}
		}

		~TemporaryIceAdapterObject()
		{
			adapter->remove(proxy->ice_getIdentity());
		}

		TemporaryIceAdapterObject(const TemporaryIceAdapterObject &) = delete;
		void operator=(const TemporaryIceAdapterObject &) = delete;

		operator typename Object::ProxyType() const
		{
			return proxy;
		}

		Object * Get() const
		{
			return object;
		}

		typename Object::ProxyType operator->() const
		{
			return proxy;
		}

		bool operator==(const typename Object::ProxyType & pr) const
		{
			return pr == proxy;
		}

	private:
		Ice::ObjectAdapterPtr adapter;
		Object * object;
		typename Object::ProxyType proxy;
};

#endif