GeoModel - GeoModelCore
Main Page
Related Pages
Classes
Files
File List
GeoModelKernel
GeoModelKernel
Query.h
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef GEOMODELKERNEL_QUERY_H
6
#define GEOMODELKERNEL_QUERY_H
7
21
#include <stdexcept>
22
template
<
class
T >
class
Query
23
{
24
25
public
:
26
27
// Constructor:
28
inline
Query
(
const
T &);
29
30
// Default constructor:
31
inline
Query
();
32
33
// Convert to "T"
34
inline
operator
T ()
const
;
35
36
// Test Validity
37
inline
bool
isValid ()
const
;
38
39
private
:
40
41
bool
m_failed;
42
T m_instance;
43
44
};
45
46
47
template
<
class
T >
inline
Query < T >::Query
(
const
T & t):
48
m_failed (
false
),
49
m_instance (t)
50
{
51
}
52
53
template
<
class
T >
inline
Query < T >::Query
():
54
m_failed (
true
),
55
m_instance (T())
56
{
57
}
58
59
template
<
class
T >
inline
Query < T >::operator
T ()
const
60
{
61
if
(m_failed)
62
throw
std::range_error (
"Failed query"
);
63
return
m_instance;
64
}
65
66
template
<
class
T >
inline
bool
Query < T >::isValid
()
const
67
{
68
return
!m_failed;
69
}
70
71
72
#endif
Query
This class can be used to return the result of a query that can fail. Objects of this class can conve...
Definition:
Query.h:22
Generated on Thu May 28 2020 05:11:07 for GeoModel - GeoModelCore by
1.8.11