API
saving_state_change.hpp
Go to the documentation of this file.
1 /** \file saving_state_change.hpp
2  * \brief The MagAO-X logger saving_state_change log type.
3  * \author Jared R. Males (jaredmales@gmail.com)
4  *
5  * \ingroup logger_types_files
6  *
7  * History:
8  * - 2019-05-04 created by JRM
9  */
10 #ifndef logger_types_saving_state_change_hpp
11 #define logger_types_saving_state_change_hpp
12 
13 #include "../../app/stateCodes.hpp"
14 
15 #include "generated/saving_state_change_generated.h"
16 #include "flatbuffer_log.hpp"
17 
18 namespace MagAOX
19 {
20 namespace logger
21 {
22 
23 
24 ///Saving State Change
25 /** \ingroup logger_types
26  */
28 {
29 
30 
31  ///The type of the message
32  struct messageT : public fbMessage
33  {
34  messageT( int16_t state,
35  uint64_t frameNo
36  )
37  {
38  auto gs = CreateSaving_state_change_fb(builder, state, frameNo);
39  builder.Finish(gs);
40  }
41  };
42 
43  static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
44  flatlogs::msgLenT len ///< [in] length of msgBuffer.
45  )
46  {
47  auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
48  return VerifySaving_state_change_fbBuffer(verifier);
49  }
50 
51  /// Format the message for text output, including translation of state codes to text form.
52  /**
53  * \returns the message formatted as "State changed from UNINITIALIZED to INITIALIZED"
54  */
55  static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
56  flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
57  )
58  {
59  static_cast<void>(len);
60 
61  auto rgs = GetSaving_state_change_fb(msgBuffer);
62 
63  std::stringstream s;
64  s << "Saving ";
65 
66  if(rgs->state() == 0) s << "stopped at frame number ";
67  else s << "started at frame number ";
68 
69  s << rgs->frameNo();
70 
71  return s.str();
72  }
73 };
74 
75 } //namespace logger
76 } //namespace MagAOX
77 
78 #endif //logger_types_saving_state_change_hpp
The MagAO-X logger flatbuffer log base type.
msgLen2T msgLenT
The type used to refer to the message length, regardless of length.
Definition: logDefs.hpp:69
static void * messageBuffer(bufferPtrT &logBuffer)
Get the message buffer address.
Definition: logHeader.hpp:621
std::shared_ptr< char > bufferPtrT
The log entry buffer smart pointer.
Definition: logHeader.hpp:58
Definition: dm.hpp:24
Message type for resolving log messages with a f.b. builder.
flatbuffers::FlatBufferBuilder builder
Base class for logs consisting of a flatbuffer message.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Format the message for text output, including translation of state codes to text form.