-
Notifications
You must be signed in to change notification settings - Fork 1
/
ServiceRegistration.cpp
58 lines (49 loc) · 1.58 KB
/
ServiceRegistration.cpp
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
54
55
56
57
58
/*
* nOSGi Project - http://www-vs.informatik.uni-ulm.de/proj/nosgi/
*
* Copyright (C) 2009-2011 Aspectix Research Team,
* Institute of Distributed Systems, Ulm University, Germany
*
* This file is part of the nOSGi Project, which is released
* under the terms of the GNU General Public License.
* See the LICENSE.txt file in the root directory of the software
* distribution for more details.
*/
#include "framework.h"
#include <nosgi/framework/ServiceEvent.h>
#include <nosgi/framework/ServiceRegistration.h>
#include <nosgi/framework/ServiceReference.h>
#include <map>
#include <string>
using namespace std;
ServiceRegistration::ServiceRegistration(string& interf) :
ranking(0) {
id = Framework::getNextServiceId();
reference = new ServiceReference(this);
interface = interf;
}
ServiceRegistration::~ServiceRegistration() {
delete reference;
}
void ServiceRegistration::unregister() {
Framework::removeInterfaceRegistration(id, interface);
Framework::removeServiceRegistration(id);
ServiceEvent event(ServiceEvent::UNREGISTERING, *reference);
Framework::notifyServiceListeners(event);
}
long ServiceRegistration::getId() const {
return id;
}
int ServiceRegistration::getRanking() const {
return ranking;
}
ServiceReference *ServiceRegistration::getReference() const {
return reference;
}
void ServiceRegistration::setProperties(map<string,Property*> *props) {
//FIXME delete properties
if (reference->properties) delete reference->properties;
reference->properties = props;
ServiceEvent event(ServiceEvent::MODIFIED, *reference);
Framework::notifyServiceListeners(event);
}