text: /*
   * UAVCAN data structure definition for libuavcan.
   *
   * Autogenerated, do not edit.
   *
   * Source file: /home/zisemangguo/workspace/Firmware/src/modules/uavcan/libuavcan/libuavcan/test/dsdl_test/root_ns_a/A.uavcan
   */
  
  #ifndef ROOT_NS_A_A_HPP_INCLUDED
  #define ROOT_NS_A_A_HPP_INCLUDED
  
  #include <uavcan/build_config.hpp>
  #include <uavcan/node/global_data_type_registry.hpp>
  #include <uavcan/marshal/types.hpp>
  
  #include <root_ns_a/B.hpp>
  
  /******************************* Source text **********************************
  #
  # Nested type.
  # Energy and capacity are expressed in watt hours (Joules are infeasible because of range limitations).
  # Unknown values should be represented as NAN.
  #
  
  float32 scalar
  B[2] vector
  ******************************************************************************/
  
  /********************* DSDL signature source definition ***********************
  root_ns_a.A
  saturated float32 scalar
  root_ns_a.B[2] vector
  ******************************************************************************/
  
  #undef scalar
  #undef vector
  
  namespace root_ns_a
  {
  
  template <int _tmpl>
  struct UAVCAN_EXPORT A_
  {
      typedef const A_<_tmpl>& ParameterType;
      typedef A_<_tmpl>& ReferenceType;
  
      struct ConstantTypes
      {
      };
  
      struct FieldTypes
      {
          typedef ::uavcan::FloatSpec< 32, ::uavcan::CastModeSaturate > scalar;
          typedef ::uavcan::Array< ::root_ns_a::B, ::uavcan::ArrayModeStatic, 2 > vector;
      };
  
      enum
      {
          MinBitLen
              = FieldTypes::scalar::MinBitLen
              + FieldTypes::vector::MinBitLen
      };
  
      enum
      {
          MaxBitLen
              = FieldTypes::scalar::MaxBitLen
              + FieldTypes::vector::MaxBitLen
      };
  
      // Constants
  
      // Fields
      typename ::uavcan::StorageType< typename FieldTypes::scalar >::Type scalar;
      typename ::uavcan::StorageType< typename FieldTypes::vector >::Type vector;
  
      A_()
          : scalar()
          , vector()
      {
          ::uavcan::StaticAssert<_tmpl == 0>::check();  // Usage check
  
  #if UAVCAN_DEBUG
          /*
           * Cross-checking MaxBitLen provided by the DSDL compiler.
           * This check shall never be performed in user code because MaxBitLen value
           * actually depends on the nested types, thus it is not invariant.
           */
          ::uavcan::StaticAssert<320 == MaxBitLen>::check();
  #endif
      }
  
      bool operator==(ParameterType rhs) const;
      bool operator!=(ParameterType rhs) const { return !operator==(rhs); }
  
      /**
       * This comparison is based on @ref uavcan::areClose(), which ensures proper comparison of
       * floating point fields at any depth.
       */
      bool isClose(ParameterType rhs) const;
  
      static int encode(ParameterType self, ::uavcan::ScalarCodec& codec,
                        ::uavcan::TailArrayOptimizationMode tao_mode = ::uavcan::TailArrayOptEnabled);
  
      static int decode(ReferenceType self, ::uavcan::ScalarCodec& codec,
                        ::uavcan::TailArrayOptimizationMode tao_mode = ::uavcan::TailArrayOptEnabled);
  
      /*
       * Static type info
       */
      enum { DataTypeKind = ::uavcan::DataTypeKindMessage };
      // This type has no default data type ID
  
      static const char* getDataTypeFullName()
      {
          return "root_ns_a.A";
      }
  
      static void extendDataTypeSignature(::uavcan::DataTypeSignature& signature)
      {
          signature.extend(getDataTypeSignature());
      }
  
      static ::uavcan::DataTypeSignature getDataTypeSignature();
  
  };
  
  /*
   * Out of line struct method definitions
   */
  
  template <int _tmpl>
  bool A_<_tmpl>::operator==(ParameterType rhs) const
  {
      return
          scalar == rhs.scalar &&
          vector == rhs.vector;
  }
  
  template <int _tmpl>
  bool A_<_tmpl>::isClose(ParameterType rhs) const
  {
      return
          ::uavcan::areClose(scalar, rhs.scalar) &&
          ::uavcan::areClose(vector, rhs.vector);
  }
  
  template <int _tmpl>
  int A_<_tmpl>::encode(ParameterType self, ::uavcan::ScalarCodec& codec,
      ::uavcan::TailArrayOptimizationMode tao_mode)
  {
      (void)self;
      (void)codec;
      (void)tao_mode;
      int res = 1;
      res = FieldTypes::scalar::encode(self.scalar, codec,  ::uavcan::TailArrayOptDisabled);
      if (res <= 0)
      {
          return res;
      }
      res = FieldTypes::vector::encode(self.vector, codec,  tao_mode);
      return res;
  }
  
  template <int _tmpl>
  int A_<_tmpl>::decode(ReferenceType self, ::uavcan::ScalarCodec& codec,
      ::uavcan::TailArrayOptimizationMode tao_mode)
  {
      (void)self;
      (void)codec;
      (void)tao_mode;
      int res = 1;
      res = FieldTypes::scalar::decode(self.scalar, codec,  ::uavcan::TailArrayOptDisabled);
      if (res <= 0)
      {
          return res;
      }
      res = FieldTypes::vector::decode(self.vector, codec,  tao_mode);
      return res;
  }
  
  /*
   * Out of line type method definitions
   */
  template <int _tmpl>
  ::uavcan::DataTypeSignature A_<_tmpl>::getDataTypeSignature()
  {
      ::uavcan::DataTypeSignature signature(0xC03F8DC0D49B7AB5ULL);
  
      FieldTypes::scalar::extendDataTypeSignature(signature);
      FieldTypes::vector::extendDataTypeSignature(signature);
  
      return signature;
  }
  
  /*
   * Out of line constant definitions
   */
  
  /*
   * Final typedef
   */
  typedef A_<0> A;
  
  // No default registration
  
  } // Namespace root_ns_a
  
  /*
   * YAML streamer specialization
   */
  namespace uavcan
  {
  
  template <>
  class UAVCAN_EXPORT YamlStreamer< ::root_ns_a::A >
  {
  public:
      template <typename Stream>
      static void stream(Stream& s, ::root_ns_a::A::ParameterType obj, const int level);
  };
  
  template <typename Stream>
  void YamlStreamer< ::root_ns_a::A >::stream(Stream& s, ::root_ns_a::A::ParameterType obj, const int level)
  {
      (void)s;
      (void)obj;
      (void)level;
      if (level > 0)
      {
          s << '\n';
          for (int pos = 0; pos < level; pos++)
          {
              s << "  ";
          }
      }
      s << "scalar: ";
      YamlStreamer< ::root_ns_a::A::FieldTypes::scalar >::stream(s, obj.scalar, level + 1);
      s << '\n';
      for (int pos = 0; pos < level; pos++)
      {
          s << "  ";
      }
      s << "vector: ";
      YamlStreamer< ::root_ns_a::A::FieldTypes::vector >::stream(s, obj.vector, level + 1);
  }
  
  }
  
  namespace root_ns_a
  {
  
  template <typename Stream>
  inline Stream& operator<<(Stream& s, ::root_ns_a::A::ParameterType obj)
  {
      ::uavcan::YamlStreamer< ::root_ns_a::A >::stream(s, obj, 0);
      return s;
  }
  
  } // Namespace root_ns_a
  
  #endif // ROOT_NS_A_A_HPP_INCLUDED