1 /*=============================================================================
3 Library: CppMicroServices
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
20 =============================================================================*/
24 template<class S, class TTT>
25 TrackedService<S,TTT>::TrackedService(ServiceTracker<S,TTT>* serviceTracker,
26 ServiceTrackerCustomizer<S,T>* customizer)
27 : serviceTracker(serviceTracker), customizer(customizer)
32 template<class S, class TTT>
33 void TrackedService<S,TTT>::ServiceChanged(const ServiceEvent event)
36 * Check if we had a delayed call (which could happen when we
44 ServiceReference<S> reference = event.GetServiceReference(InterfaceType<S>());
45 US_DEBUG(serviceTracker->d->DEBUG_OUTPUT) << "TrackedService::ServiceChanged["
46 << event.GetType() << "]: " << reference;
52 switch (event.GetType())
54 case ServiceEvent::REGISTERED :
55 case ServiceEvent::MODIFIED :
57 if (!serviceTracker->d->listenerFilter.empty())
58 { // service listener added with filter
59 this->Track(reference, event);
61 * If the customizer throws an unchecked exception, it
62 * is safe to let it propagate
66 { // service listener added without filter
67 if (serviceTracker->d->filter.Match(reference))
69 this->Track(reference, event);
71 * If the customizer throws an unchecked exception,
72 * it is safe to let it propagate
77 this->Untrack(reference, event);
79 * If the customizer throws an unchecked exception,
80 * it is safe to let it propagate
86 case ServiceEvent::MODIFIED_ENDMATCH :
87 case ServiceEvent::UNREGISTERING :
88 this->Untrack(reference, event);
90 * If the customizer throws an unchecked exception, it is
91 * safe to let it propagate
97 template<class S, class TTT>
98 void TrackedService<S,TTT>::Modified()
100 Superclass::Modified(); /* increment the modification count */
101 serviceTracker->d->Modified();
104 template<class S, class TTT>
105 typename TrackedService<S,TTT>::T
106 TrackedService<S,TTT>::CustomizerAdding(ServiceReference<S> item,
107 const ServiceEvent& /*related*/)
109 return customizer->AddingService(item);
112 template<class S, class TTT>
113 void TrackedService<S,TTT>::CustomizerModified(ServiceReference<S> item,
114 const ServiceEvent& /*related*/,
117 customizer->ModifiedService(item, object);
120 template<class S, class TTT>
121 void TrackedService<S,TTT>::CustomizerRemoved(ServiceReference<S> item,
122 const ServiceEvent& /*related*/,
125 customizer->RemovedService(item, object);