LCOV - code coverage report
Current view: top level - DCPS/XTypes - DynamicDataBase.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 9 9 100.0 %
Date: 2023-04-30 01:32:43 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Distributed under the OpenDDS License.
       3             :  * See: http://www.opendds.org/license.html
       4             :  */
       5             : 
       6             : #ifndef OPENDDS_DCPS_XTYPES_DYNAMIC_DATA_BASE_H
       7             : #define OPENDDS_DCPS_XTYPES_DYNAMIC_DATA_BASE_H
       8             : 
       9             : #ifndef OPENDDS_SAFETY_PROFILE
      10             : #  include "DynamicTypeImpl.h"
      11             : 
      12             : #  include <dds/DCPS/LocalObject.h>
      13             : #  include <dds/DCPS/Sample.h>
      14             : 
      15             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      16             : 
      17             : namespace OpenDDS {
      18             : 
      19             : namespace DCPS {
      20             :   struct Value;
      21             : }
      22             : 
      23             : namespace XTypes {
      24             : 
      25             : class OpenDDS_Dcps_Export DynamicDataBase : public virtual DCPS::LocalObject<DDS::DynamicData> {
      26             : public:
      27             :   DynamicDataBase();
      28             :   DynamicDataBase(DDS::DynamicType_ptr type);
      29             : 
      30             :   DDS::ReturnCode_t get_descriptor(DDS::MemberDescriptor*& value, MemberId id);
      31             :   DDS::ReturnCode_t set_descriptor(DDS::MemberId id, DDS::MemberDescriptor* value);
      32             :   DDS::MemberId get_member_id_by_name(const char* name);
      33             :   DDS::DynamicType_ptr type();
      34             :   DDS::Boolean equals(DDS::DynamicData_ptr other);
      35             :   DDS::DynamicData_ptr loan_value(DDS::MemberId id);
      36             :   DDS::ReturnCode_t return_loaned_value(DDS::DynamicData_ptr other);
      37             :   DDS::DynamicData_ptr clone();
      38             : 
      39             :   DDS::ReturnCode_t get_int64_value(DDS::Int64& value, DDS::MemberId id);
      40             :   virtual DDS::ReturnCode_t get_int64_value_impl(DDS::Int64& value, DDS::MemberId id) = 0;
      41             :   DDS::ReturnCode_t get_uint64_value(DDS::UInt64& value, DDS::MemberId id);
      42             :   virtual DDS::ReturnCode_t get_uint64_value_impl(DDS::UInt64& value, DDS::MemberId id) = 0;
      43             : 
      44             :   static bool has_explicit_keys(DDS::DynamicType* dt);
      45             :   static bool exclude_member(DCPS::Sample::Extent ext, bool is_key, bool has_explicit_keys);
      46             :   static DCPS::Sample::Extent nested(DCPS::Sample::Extent ext);
      47             : 
      48             : #ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE
      49             :   virtual DDS::ReturnCode_t get_simple_value(DCPS::Value& value, DDS::MemberId id);
      50             : #endif
      51             : 
      52             : protected:
      53             :   /// Verify that a given type is primitive or string or wstring.
      54             :   bool is_type_supported(TypeKind tk, const char* func_name);
      55             : 
      56             :   bool get_index_from_id(DDS::MemberId id, ACE_CDR::ULong& index, ACE_CDR::ULong bound) const;
      57             :   bool enum_string_helper(char*& strInOut, MemberId id);
      58             : 
      59             :   DDS::ReturnCode_t check_member(
      60             :     DDS::MemberDescriptor_var& member_desc, DDS::DynamicType_var& member_type,
      61             :     const char* method, const char* action, DDS::MemberId id, DDS::TypeKind tk = TK_NONE);
      62             : 
      63         635 :   DDS::ReturnCode_t check_member(
      64             :     DDS::DynamicType_var& member_type, const char* method, const char* action,
      65             :     DDS::MemberId id, DDS::TypeKind tk = TK_NONE)
      66             :   {
      67         635 :     DDS::MemberDescriptor_var md;
      68        1270 :     return check_member(md, member_type, method, action, id, tk);
      69         635 :   }
      70             : 
      71             :   static DDS::MemberId get_union_default_member(DDS::DynamicType* type);
      72             :   DDS::ReturnCode_t get_selected_union_branch(
      73             :     DDS::Int32 disc, bool& found_selected_member, DDS::MemberDescriptor_var& selected_md) const;
      74             :   DDS::ReturnCode_t get_selected_union_branch(
      75             :     bool& found_selected_member, DDS::MemberDescriptor_var& selected_md);
      76             :   bool discriminator_selects_no_member(DDS::Int32 disc) const;
      77             : 
      78             :   /// Similar idea to std::shared_from_this(), provide a type compatible with parameter
      79             :   /// passing rules for IDL interfaces that are arguments to operations.
      80             :   /// Doesn't change the reference count.
      81             :   DDS::DynamicData* interface_from_this() const;
      82             : 
      83             :   DDS::ReturnCode_t unsupported_method(const char* method_name, bool warning = false) const;
      84             : 
      85             :   /// The actual (i.e., non-alias) DynamicType of the associated type.
      86             :   DDS::DynamicType_var type_;
      87             :   DDS::TypeDescriptor_var type_desc_;
      88             : };
      89             : 
      90        3066 : inline bool DynamicDataBase::exclude_member(DCPS::Sample::Extent ext, bool is_key, bool has_explicit_keys)
      91             : {
      92             :   // see Fields::Iterator and explicit_keys_only() in opendds_idl's dds_generator.h
      93        3066 :   const bool explicit_keys_only = ext == DCPS::Sample::KeyOnly || (ext == DCPS::Sample::NestedKeyOnly && has_explicit_keys);
      94        3066 :   return explicit_keys_only && !is_key;
      95             : }
      96             : 
      97         441 : inline DCPS::Sample::Extent DynamicDataBase::nested(DCPS::Sample::Extent ext)
      98             : {
      99         441 :   return ext == DCPS::Sample::KeyOnly ? DCPS::Sample::NestedKeyOnly : ext;
     100             : }
     101             : 
     102             : } // namespace XTypes
     103             : } // namespace OpenDDS
     104             : 
     105             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
     106             : 
     107             : #endif // OPENDDS_SAFETY_PROFILE
     108             : 
     109             : #endif // OPENDDS_DCPS_XTYPES_DYNAMIC_DATA_BASE_H

Generated by: LCOV version 1.16