summaryrefslogtreecommitdiff
path: root/p2pvr/lib/temporaryIceAdapterObject.h
blob: e8b83d8de987077a62876c8e51035b5a6e84321f (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
#ifndef TEMPORARYICEADAPTER_H
#define TEMPORARYICEADAPTER_H

#include <Ice/ObjectAdapter.h>

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

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

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

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

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

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

#endif