LCOV - code coverage report
Current view: top level - INDI/libcommon - IndiMessage.cpp (source / functions) Coverage Total Hit
Test: MagAOX Lines: 13.3 % 60 8
Test Date: 2026-01-03 21:03:39 Functions: 36.4 % 11 4

            Line data    Source code
       1              : /// IndiMessage.cpp
       2              : ///
       3              : /// @author Paul Grenz
       4              : ///
       5              : ////////////////////////////////////////////////////////////////////////////////
       6              : 
       7              : #include <string>
       8              : #include "IndiMessage.hpp"
       9              : 
      10              : using std::string;
      11              : using pcf::IndiProperty;
      12              : using pcf::IndiMessage;
      13              : 
      14              : ////////////////////////////////////////////////////////////////////////////////
      15              : /// Constructor.
      16              : 
      17            0 : IndiMessage::IndiMessage()
      18              : {
      19            0 : }
      20              : 
      21              : ////////////////////////////////////////////////////////////////////////////////
      22              : /// Constructor with type and property - this will be used often.
      23              : 
      24           10 : IndiMessage::IndiMessage( const Type &tType, const IndiProperty &ipMsg ) : m_ipMsg(ipMsg), m_tType(tType)
      25              : {
      26           10 : }
      27              : 
      28              : ////////////////////////////////////////////////////////////////////////////////
      29              : ///  Copy constructor.
      30              : 
      31            0 : IndiMessage::IndiMessage( const IndiMessage &imRhs ) : m_ipMsg(imRhs.m_ipMsg), m_tType(imRhs.m_tType)
      32              : {
      33            0 : }
      34              : 
      35              : ////////////////////////////////////////////////////////////////////////////////
      36              : /// Destructor.
      37              : 
      38           10 : IndiMessage::~IndiMessage()
      39              : {
      40           10 : }
      41              : 
      42              : ////////////////////////////////////////////////////////////////////////////////
      43              : /// Assigns the internal data of this object from an existing one.
      44              : 
      45            0 : const IndiMessage &IndiMessage::operator=( const IndiMessage &imRhs )
      46              : {
      47            0 :   if ( &imRhs != this )
      48              :   {
      49            0 :     m_ipMsg = imRhs.m_ipMsg;
      50            0 :     m_tType = imRhs.m_tType;
      51              :   }
      52            0 :   return *this;
      53              : }
      54              : 
      55              : ////////////////////////////////////////////////////////////////////////////////
      56              : /// Returns the message type.
      57              : 
      58           10 : const IndiMessage::Type &IndiMessage::getType() const
      59              : {
      60           10 :   return m_tType;
      61              : }
      62              : 
      63              : ////////////////////////////////////////////////////////////////////////////////
      64              : /// Returns the Indi property contained here.
      65              : 
      66           10 : const IndiProperty &IndiMessage::getProperty() const
      67              : {
      68           10 :   return m_ipMsg;
      69              : }
      70              : 
      71              : ////////////////////////////////////////////////////////////////////////////////
      72              : /// Returns the Indi property contained here.
      73              : 
      74            0 : IndiProperty &IndiMessage::getProperty()
      75              : {
      76            0 :   return m_ipMsg;
      77              : }
      78              : 
      79              : ////////////////////////////////////////////////////////////////////////////////
      80              : /// Sets the Indi property contained here.
      81              : 
      82            0 : void IndiMessage::setProperty( const IndiProperty &ipMsg )
      83              : {
      84            0 :   m_ipMsg = ipMsg;
      85            0 : }
      86              : 
      87              : ////////////////////////////////////////////////////////////////////////////////
      88              : /// Returns the string type given the enumerated type.
      89              : 
      90            0 : string IndiMessage::convertTypeToString( const IndiMessage::Type &tType )
      91              : {
      92            0 :   string szType = "";
      93              : 
      94            0 :   switch ( tType )
      95              :   {
      96            0 :     case Unknown:
      97            0 :       szType = "Unknown"; break;
      98              :     // Define properties.
      99            0 :     case Define:
     100            0 :       szType = "Define"; break;
     101              :     // Delete properties.
     102            0 :     case Delete:
     103            0 :       szType = "Delete"; break;
     104              :     // Enable blobs for a client.
     105            0 :     case EnableBLOB:
     106            0 :       szType = "EnableBLOB"; break;
     107              :     // Command to enable snooping messages from other devices.
     108            0 :     case GetProperties:
     109            0 :       szType = "GetProperties"; break;
     110              :     // A message.
     111            0 :     case Message:
     112            0 :       szType = "Message"; break;
     113              :     // Update properties.
     114            0 :     case NewProperty:
     115            0 :       szType = "NewProperty"; break;
     116              :     // Set properties.
     117            0 :     case SetProperty:
     118            0 :       szType = "SetProperty"; break;
     119              :   }
     120              : 
     121            0 :   return szType;
     122            0 : }
     123              : 
     124              : ////////////////////////////////////////////////////////////////////////////////
     125              : /// Returns the enumerated type given the tag.
     126              : 
     127            0 : IndiMessage::Type IndiMessage::convertStringToType( const string &szTag )
     128              : {
     129            0 :   Type tType = Unknown;
     130              : 
     131            0 :   if ( szTag == "Define" )
     132            0 :     tType = Define;
     133            0 :   else if ( szTag == "Delete" )
     134            0 :     tType = Delete;
     135            0 :   else if ( szTag == "EnableBLOB" )
     136            0 :     tType = EnableBLOB;
     137            0 :   else if ( szTag == "GetProperties" )
     138            0 :     tType = GetProperties;
     139            0 :   else if ( szTag == "Message" )
     140            0 :     tType = Message;
     141            0 :   else if ( szTag == "NewProperty" )
     142            0 :     tType = NewProperty;
     143            0 :   else if ( szTag == "SetProperty" )
     144            0 :     tType = SetProperty;
     145              : 
     146            0 :   return tType;
     147              : }
     148              : 
     149              : ////////////////////////////////////////////////////////////////////////////////
     150              : /// Returns true if this is a 'def' (define) message, false otherwise.
     151              : /*
     152              : bool IndiMessage::isDefType() const
     153              : {
     154              :   return ( m_tType == Define );
     155              : }
     156              : */
     157              : ////////////////////////////////////////////////////////////////////////////////
     158              : /// Returns true if this is a 'new' (update) message, false otherwise.
     159              : /*
     160              : bool IndiMessage::isNewType() const
     161              : {
     162              :   return ( m_tType == NewProperty );
     163              : }
     164              : */
     165              : ////////////////////////////////////////////////////////////////////////////////
     166              : /// Returns true if this is a 'set' (assign) message, false otherwise.
     167              : /*
     168              : bool IndiMessage::isSetType() const
     169              : {
     170              :   return ( m_tType == SetProperty );
     171              : }
     172              : */
     173              : ////////////////////////////////////////////////////////////////////////////////
     174              : 
     175              : 
        

Generated by: LCOV version 2.0-1