PVData C++
8.0.9
Toggle main menu visibility
Loading...
Searching...
No Matches
misc
pv
status.h
1
/* status.h */
2
/*
3
* Copyright information and license terms for this software can be
4
* found in the file LICENSE that is included with the distribution
5
*/
9
#ifndef STATUS_H
10
#define STATUS_H
11
12
#include <
ostream
>
13
14
#include <pv/serialize.h>
15
#include <pv/byteBuffer.h>
16
#include <
pv/sharedPtr.h
>
17
18
#include <shareLib.h>
19
20
namespace
epics
{
namespace
pvData
{
21
28
class
epicsShareClass
Status
:
public
epics::pvData::Serializable
{
29
public
:
30
POINTER_DEFINITIONS(
Status
);
34
enum
StatusType
{
36
STATUSTYPE_OK
,
38
STATUSTYPE_WARNING
,
40
STATUSTYPE_ERROR
,
42
STATUSTYPE_FATAL
43
};
44
45
static
const
char
* StatusTypeName[];
46
47
static
Status
Ok;
48
49
static
inline
Status
warn(
const
std::string
& m) {
return
Status
(STATUSTYPE_WARNING, m); }
50
static
inline
Status error(
const
std::string
& m) {
return
Status(STATUSTYPE_ERROR, m); }
51
static
inline
Status fatal(
const
std::string
& m) {
return
Status(STATUSTYPE_FATAL, m); }
52
56
Status
() :m_statusType(
STATUSTYPE_OK
) {}
57
61
Status
(
StatusType
type,
std::string
const
& message);
62
66
Status
(
StatusType
type,
std::string
const
& message,
std::string
const
& stackDump);
67
68
virtual
~Status
() {}
69
74
inline
StatusType
getType
()
const
{
return
m_statusType; }
75
80
inline
const
std::string
&
getMessage
()
const
{
return
m_message; }
81
86
inline
const
std::string
&
getStackDump
()
const
{
return
m_stackDump; }
87
95
inline
bool
isOK
()
const
{
96
return
(m_statusType ==
STATUSTYPE_OK
);
97
}
98
103
inline
bool
isSuccess
()
const
{
104
return
(m_statusType ==
STATUSTYPE_OK
|| m_statusType ==
STATUSTYPE_WARNING
);
105
}
106
107
#if __cplusplus>=201103L
108
FORCE_INLINE
explicit
operator
bool()
const
{
109
return
isSuccess();
110
}
111
#else
112
private
:
113
typedef
bool (Status::*truth_type)()
const
;
114
public
:
115
FORCE_INLINE
operator
truth_type()
const
{
116
return
isSuccess() ? &Status::isSuccess : 0;
117
}
118
#endif
119
129
void
maximize
(
const
Status
& o);
130
132
FORCE_INLINE
Status
&
operator|=
(
const
Status
& o) {
133
maximize
(o);
134
return
*
this
;
135
}
136
137
void
serialize
(
ByteBuffer
*buffer,
SerializableControl
*flusher)
const
;
138
void
deserialize
(
ByteBuffer
*buffer,
DeserializableControl
*flusher);
139
140
void
dump(
std::ostream
& o)
const
;
141
142
private
:
143
144
StatusType
m_statusType;
145
std::string
m_message;
146
std::string
m_stackDump;
147
148
};
149
150
FORCE_INLINE
std::ostream
& operator<<(
std::ostream
& o,
const
Status
& status) {
151
status.dump(o);
152
return
o;
153
}
154
155
FORCE_INLINE
std::ostream
&
operator<<
(
std::ostream
& o,
const
Status::StatusType
& statusType) {
156
o << Status::StatusTypeName[statusType];
157
return
o;
158
}
159
160
}}
161
#endif
/* STATUS_H */
ostream
std::ostream
basic_ostream< char > ostream
std::string
basic_string< char > string
operator<<
basic_ostream< _CharT, _Traits > & operator<<(basic_ostream< _CharT, _Traits > &__os, const basic_string< _CharT, _Traits, _Alloc > &__str)
epics::pvData::ByteBuffer
This class implements a Bytebuffer that is like the java.nio.ByteBuffer.
Definition
byteBuffer.h:237
epics::pvData::DeserializableControl
Callback class for deserialization.
Definition
serialize.h:93
epics::pvData::SerializableControl
Callback class for serialization.
Definition
serialize.h:42
epics::pvData::Serializable
Base class for serialization.
Definition
serialize.h:138
epics::pvData::Status
Status.
Definition
status.h:28
epics::pvData::Status::isOK
bool isOK() const
Definition
status.h:95
epics::pvData::Status::getMessage
const std::string & getMessage() const
Definition
status.h:80
epics::pvData::Status::operator|=
Status & operator|=(const Status &o)
short hand for "this->maximize(o)"
Definition
status.h:132
epics::pvData::Status::getType
StatusType getType() const
Definition
status.h:74
epics::pvData::Status::serialize
void serialize(ByteBuffer *buffer, SerializableControl *flusher) const
epics::pvData::Status::StatusType
StatusType
Definition
status.h:34
epics::pvData::Status::STATUSTYPE_FATAL
@ STATUSTYPE_FATAL
Definition
status.h:42
epics::pvData::Status::STATUSTYPE_OK
@ STATUSTYPE_OK
Definition
status.h:36
epics::pvData::Status::STATUSTYPE_ERROR
@ STATUSTYPE_ERROR
Definition
status.h:40
epics::pvData::Status::STATUSTYPE_WARNING
@ STATUSTYPE_WARNING
Definition
status.h:38
epics::pvData::Status::Status
Status()
Definition
status.h:56
epics::pvData::Status::deserialize
void deserialize(ByteBuffer *buffer, DeserializableControl *flusher)
epics::pvData::Status::Status
Status(StatusType type, std::string const &message)
epics::pvData::Status::Status
Status(StatusType type, std::string const &message, std::string const &stackDump)
epics::pvData::Status::isSuccess
bool isSuccess() const
Definition
status.h:103
epics::pvData::Status::maximize
void maximize(const Status &o)
epics::pvData::Status::getStackDump
const std::string & getStackDump() const
Definition
status.h:86
epics::pvData
pvData
Definition
convert.h:21
epics
epics
Definition
convert.h:21
sharedPtr.h
Generated on
for PVData C++ by
1.17.0