Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunecore
dunecore
ArtSupport
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
17
#include "
dunecore/ArtSupport/ArtServicePointer.h
"
18
19
// Access a provider via service and provider types.
20
template
<
class
S,
class
P>
21
const
P
*
ArtServiceProviderFromService
() {
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>
37
const
P
*
ArtServiceProvider
() {
38
std::cout <<
"ArtServiceProvider: No specialization found for "
<<
typeid
(
P
).
name
() <<
std::endl
;
39
return
nullptr
;
40
}
41
42
#endif
name
static QCString name
Definition:
declinfo.cpp:673
S
Definition:
044_section.h:5
gar::P
std::pair< float, std::string > P
Definition:
anatree_module.cc:75
DefaultArtServiceProvider
const S::provider_type * DefaultArtServiceProvider()
Definition:
ArtServiceProvider.h:30
ArtServicePointer.h
ArtServiceProvider
const P * ArtServiceProvider()
Definition:
ArtServiceProvider.h:37
ArtServiceProviderFromService
const P * ArtServiceProviderFromService()
Definition:
ArtServiceProvider.h:21
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11