Tomographer  v5.3
Tomographer C++ Framework Documentation
statusprovider.h
1 /* This file is part of the Tomographer project, which is distributed under the
2  * terms of the MIT license.
3  *
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2016 ETH Zurich, Institute for Theoretical Physics, Philippe Faist
7  * Copyright (c) 2017 Caltech, Institute for Quantum Information and Matter, Philippe Faist
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy
10  * of this software and associated documentation files (the "Software"), to deal
11  * in the Software without restriction, including without limitation the rights
12  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13  * copies of the Software, and to permit persons to whom the Software is
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included in
17  * all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25  * SOFTWARE.
26  */
27 
28 #ifndef TOMOGRAPHER_TOOLS_STATUSPROVIDER_H
29 #define TOMOGRAPHER_TOOLS_STATUSPROVIDER_H
30 
31 
33 
34 
35 namespace Tomographer {
36 namespace Tools {
37 
38 
39 
40 
49 template<typename StatusableObject_>
50 struct TOMOGRAPHER_EXPORT StatusProvider
51 {
52  typedef StatusableObject_ StatusableObject;
53 
54  static constexpr bool CanProvideStatusLine = false;
55 
63  static inline std::string getStatusLine(const StatusableObject * /*obj*/)
64  {
65  return std::string();
66  }
67 };
68 
69 
70 
71 namespace tomo_internal {
72 template<typename StObj, typename canprovideline = void>
73 struct status_can_provide_line {
74  static constexpr bool val = false;
75 };
76 template<typename StObj>
77 struct status_can_provide_line<StObj,
78  typename std::enable_if<StatusProvider<StObj>::CanProvideStatusLine,void>::type> {
79  static constexpr bool val = true;
80 };
81 template<typename StObj, typename canprovidefullmessage = void>
82 struct status_can_provide_fullmessage {
83  static constexpr bool val = false;
84 };
85 template<typename StObj>
86 struct status_can_provide_fullmessage<StObj,
87  typename std::enable_if<StatusProvider<StObj>::CanProvideStatusFullMessage,void>::type> {
88  static constexpr bool val = true;
89 };
90 }
91 
92 
93 
100 template<typename StatusableObject_>
101 struct TOMOGRAPHER_EXPORT StatusQuery
102 {
103  typedef StatusableObject_ StatusableObject;
104 
105  static constexpr bool CanProvideStatusLine = tomo_internal::status_can_provide_line<StatusableObject>::val;
106 
107  TOMOGRAPHER_ENABLED_IF(CanProvideStatusLine)
108  static inline std::string getStatusLine(const StatusableObject * obj)
109  {
111  }
112  TOMOGRAPHER_ENABLED_IF(!CanProvideStatusLine)
113  static inline std::string getStatusLine(const StatusableObject * ) { return std::string(); }
114 
115  // other status stuff we could imagine providing in the future
116 
117  static constexpr bool CanProvideStatusFullMessage = tomo_internal::status_can_provide_fullmessage<StatusableObject>::val;
118 
119  TOMOGRAPHER_ENABLED_IF(CanProvideStatusFullMessage)
120  static inline std::string getStatusFullMessage(const StatusableObject * obj)
121  {
123  }
124  TOMOGRAPHER_ENABLED_IF(!CanProvideStatusFullMessage)
125  static inline std::string getStatusFullMessage(const StatusableObject * ) { return std::string(); }
126 
127 
128 };
129 // static members:
130 template<typename StatusableObject_>
132 template<typename StatusableObject_>
134 
135 
136 
137 
138 
139 
140 } // namespace Tools
141 } // namespace Tomographer
142 
143 
144 
145 
146 
147 #endif
Base namespace for the Tomographer project.
Definition: densellh.h:45
static std::string getStatusLine(const StatusableObject *)
Prepare a short status message which reports the status of the given object.
Query status from different objects.
STL class.
Some C++ utilities, with a tad of C++11 tricks.
Template, specializable class to provide status reports for different objects.