ArtServiceProvider.h
Go to the documentation of this file.
1 // ArtServiceProvider.h
2 
3 #ifndef ArtServiceProvider_H
4 #define ArtServiceProvider_H
5 
6 // David Adams
7 // January 2017
8 //
9 // ArtServiceProvider provides access to an art service provider.
10 //
11 // Usage:
12 // MyServiceProvider* pprv = ArtServiceProvider<MyService>()
13 //
14 // Template specializations may be used enable service without
15 // direct use of ServiceHandle, i.e. inside root.
16 
18 
19 // Access a provider via service and provider types.
20 template<class S, class P>
22  S* psvc = ArtServicePointer<S>();
23  if ( psvc == nullptr ) return nullptr;
24  return psvc->GetProviderPtr();
25 }
26 
27 // Access a provide via service type assuming the service
28 // knows its provider type.
29 template<class S>
30 const typename S::provider_type* DefaultArtServiceProvider() {
31  return ArtServiceProviderFromService<S, typename S::provider_type>();
32 }
33 
34 // Access a provider via provider type.
35 // This requires specialization.
36 template<class P>
38  std::cout << "ArtServiceProvider: No specialization found for " << typeid(P).name() << std::endl;
39  return nullptr;
40 }
41 
42 #endif
static QCString name
Definition: declinfo.cpp:673
Definition: 044_section.h:5
std::pair< float, std::string > P
const S::provider_type * DefaultArtServiceProvider()
const P * ArtServiceProvider()
const P * ArtServiceProviderFromService()
QTextStream & endl(QTextStream &s)