summaryrefslogtreecommitdiff
path: root/project2/ice/iceClient.h
blob: 93042fd978b7fb805b7831325c08aab41586d0c7 (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
#ifndef ICECLIENT_H
#define ICECLIENT_H

#include <variables.h>
#include <commonObjects.h>
#include <Ice/Ice.h>
#include "iceDataSource.h"

class IceClientBase {
	public:
		IceClientBase(ScriptNodePtr p);

	protected:
		const Variable dataSource;
		const Variable objectId;
		const IceDataSource * ice;
};

template <typename Interface>
class IceClient : public IceClientBase {
	public:
		IceClient(ScriptNodePtr p) : IceClientBase(p) { }

		void loadComplete(const CommonObjects * co)
		{
			ice = co->dataSource<IceDataSource>(dataSource(NULL));
			service = ice->GetProxy<Interface>(objectId(NULL), NULL);
			if (!service) {
				throw std::runtime_error("Invalid service proxy");
			}
		}

	protected:
		Interface service;
};

#endif