This is Unofficial EPICS BASE Doxygen Site
epics::pvData::Status Class Reference

Status. More...

#include "status.h"

+ Inheritance diagram for epics::pvData::Status:
+ Collaboration diagram for epics::pvData::Status:

Public Types

enum  StatusType { STATUSTYPE_OK, STATUSTYPE_WARNING, STATUSTYPE_ERROR, STATUSTYPE_FATAL }
 

Public Member Functions

 POINTER_DEFINITIONS (Status)
 
 Status ()
 
 Status (StatusType type, std::string const &message)
 
 Status (StatusType type, std::string const &message, std::string const &stackDump)
 
virtual ~Status ()
 
StatusType getType () const
 
const std::string & getMessage () const
 
const std::string & getStackDump () const
 
bool isOK () const
 
bool isSuccess () const
 
FORCE_INLINE operator truth_type () const
 
void maximize (const Status &o)
 
FORCE_INLINE Statusoperator|= (const Status &o)
 short hand for "this->maximize(o)" More...
 
void serialize (ByteBuffer *buffer, SerializableControl *flusher) const
 
void deserialize (ByteBuffer *buffer, DeserializableControl *flusher)
 
void dump (std::ostream &o) const
 
- Public Member Functions inherited from epics::pvData::Serializable
virtual ~Serializable ()
 

Static Public Member Functions

static Status warn (const std::string &m)
 
static Status error (const std::string &m)
 
static Status fatal (const std::string &m)
 

Static Public Attributes

static const char * StatusTypeName [] = { "OK", "WARNING", "ERROR", "FATAL" }
 
static Status Ok
 

Detailed Description

Status.

This is a class for returning status to clients.

Author
mse

Definition at line 28 of file status.h.

Member Enumeration Documentation

Status type enum.

Enumerator
STATUSTYPE_OK 

Operation completed successfully.

STATUSTYPE_WARNING 

Operation completed successfully, but there is a warning message.

STATUSTYPE_ERROR 

Operation failed due to an error.

STATUSTYPE_FATAL 

Operation failed due to an unexpected error.

Definition at line 34 of file status.h.

Constructor & Destructor Documentation

epics::pvData::Status::Status ( )
inline

Creates OK status; STATUSTYPE_OK, empty message and stackDump.

Definition at line 56 of file status.h.

epics::pvData::Status::Status ( StatusType  type,
std::string const &  message 
)

Create non-OK status.

epics::pvData::Status::Status ( StatusType  type,
std::string const &  message,
std::string const &  stackDump 
)

Create non-OK status.

virtual epics::pvData::Status::~Status ( )
inlinevirtual

Definition at line 68 of file status.h.

68 {}

Member Function Documentation

void epics::pvData::Status::deserialize ( ByteBuffer buffer,
DeserializableControl flusher 
)
virtual

Deserialize buffer.

Parameters
bufferserialization buffer.
flusherdeserialization control.

Implements epics::pvData::Serializable.

Definition at line 61 of file status.cpp.

62 {
63  flusher->ensureData(1);
64  int8 typeCode = buffer->getByte();
65  if (typeCode == (int8)-1)
66  {
67  // in most of the cases status will be OK, we statistically optimize
68  if (m_statusType != STATUSTYPE_OK)
69  {
70  m_statusType = STATUSTYPE_OK;
71  m_message.clear();
72  m_stackDump.clear();
73  }
74  }
75  else
76  {
77  m_statusType = (StatusType)typeCode;
78  m_message = SerializeHelper::deserializeString(buffer, flusher);
79  m_stackDump = SerializeHelper::deserializeString(buffer, flusher);
80  }
81 }
int8_t int8
Definition: pvType.h:75
static std::string deserializeString(ByteBuffer *buffer, DeserializableControl *control)
void epics::pvData::Status::dump ( std::ostream &  o) const

Definition at line 83 of file status.cpp.

84 {
85  o << "Status [type=" << Status::StatusTypeName[m_statusType];
86  if (!m_message.empty())
87  o << ", message=" << m_message;
88  if (!m_stackDump.empty())
89  o << ", stackDump=" << std::endl << m_stackDump;
90  o << ']';
91 }
static const char * StatusTypeName[]
Definition: status.h:45
static Status epics::pvData::Status::error ( const std::string &  m)
inlinestatic

Definition at line 50 of file status.h.

static Status epics::pvData::Status::fatal ( const std::string &  m)
inlinestatic

Definition at line 51 of file status.h.

const std::string& epics::pvData::Status::getMessage ( ) const
inline

Get error message describing an error. Required if error status.

Returns
error message.

Definition at line 80 of file status.h.

80 { return m_message; }
const std::string& epics::pvData::Status::getStackDump ( ) const
inline

Get stack dump where error (exception) happened. Optional.

Returns
stack dump.

Definition at line 86 of file status.h.

86 { return m_stackDump; }
StatusType epics::pvData::Status::getType ( ) const
inline

Get status type.

Returns
status type, non-null.

Definition at line 74 of file status.h.

74 { return m_statusType; }
bool epics::pvData::Status::isOK ( ) const
inline

Convenient OK test. Same as (getType() == StatusType.OK). NOTE: this will return false on WARNING message although operation succeeded. To check if operation succeeded, use isSuccess.

Returns
OK status.
See also
isSuccess()

Definition at line 95 of file status.h.

95  {
96  return (m_statusType == STATUSTYPE_OK);
97  }
bool epics::pvData::Status::isSuccess ( ) const
inline

Check if operation succeeded (OK or WARNING).

Returns
operation success status.

Definition at line 103 of file status.h.

103  {
104  return (m_statusType == STATUSTYPE_OK || m_statusType == STATUSTYPE_WARNING);
105  }
void epics::pvData::Status::maximize ( const Status o)

override this Status if the other has higher StatusType

Status ret;
ret |= call1();
if(ret)
ret |= call2();
return ret;

Definition at line 36 of file status.cpp.

37 {
38  if(m_statusType < o.m_statusType) {
39  m_statusType = o.m_statusType;
40  m_message = o.m_message;
41  m_stackDump = o.m_stackDump;
42  }
43 }
FORCE_INLINE epics::pvData::Status::operator truth_type ( ) const
inline

Definition at line 115 of file status.h.

115  {
116  return isSuccess() ? &Status::isSuccess : 0;
117  }
bool isSuccess() const
Definition: status.h:103
FORCE_INLINE Status& epics::pvData::Status::operator|= ( const Status o)
inline

short hand for "this->maximize(o)"

Definition at line 132 of file status.h.

132  {
133  maximize(o);
134  return *this;
135  }
void maximize(const Status &o)
Definition: status.cpp:36
epics::pvData::Status::POINTER_DEFINITIONS ( Status  )
void epics::pvData::Status::serialize ( ByteBuffer buffer,
SerializableControl flusher 
) const
virtual

Serialize field into given buffer.

Parameters
bufferserialization buffer.
flusherflush interface.

Implements epics::pvData::Serializable.

Definition at line 45 of file status.cpp.

46 {
47  flusher->ensureBuffer(1);
48  if (m_statusType == STATUSTYPE_OK)
49  {
50  // special code for okStatus (optimization)
51  buffer->putByte((int8)-1);
52  }
53  else
54  {
55  buffer->putByte((int8)m_statusType);
56  SerializeHelper::serializeString(m_message, buffer, flusher);
57  SerializeHelper::serializeString(m_stackDump, buffer, flusher);
58  }
59 }
int8_t int8
Definition: pvType.h:75
static void serializeString(const std::string &value, ByteBuffer *buffer, SerializableControl *flusher)
static Status epics::pvData::Status::warn ( const std::string &  m)
inlinestatic

Definition at line 49 of file status.h.

Member Data Documentation

Status epics::pvData::Status::Ok
static

Definition at line 47 of file status.h.

const char * epics::pvData::Status::StatusTypeName = { "OK", "WARNING", "ERROR", "FATAL" }
static

Definition at line 45 of file status.h.


The documentation for this class was generated from the following files: