OpenDDS  Snapshot(2023/04/28-20:55)
TypeLookupService.h
Go to the documentation of this file.
1 /*
2  * Distributed under the OpenDDS License.
3  * See: http://www.opendds.org/license.html
4  */
5 
6 #ifndef OPENDDS_DCPS_XTYPES_TYPE_LOOKUP_SERVICE_H
7 #define OPENDDS_DCPS_XTYPES_TYPE_LOOKUP_SERVICE_H
8 
9 #include "TypeObject.h"
10 #include "DynamicTypeMemberImpl.h"
11 #include "MemberDescriptorImpl.h"
12 #include "TypeDescriptorImpl.h"
13 #include "DynamicTypeImpl.h"
14 
15 #include <dds/DCPS/RcObject.h>
16 #include <dds/DCPS/GuidUtils.h>
17 
18 #include <ace/Thread_Mutex.h>
19 
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 
25 
26 namespace OpenDDS {
27 namespace XTypes {
28 
30 public:
33 
34  /// For TypeAssignability
35  const TypeObject& get_type_object(const TypeIdentifier& type_id) const;
36  void add(const TypeIdentifier& ti, const TypeObject& tobj);
37 
38  /// For TypeLookup_getTypes
39  void get_type_objects(const TypeIdentifierSeq& type_ids,
40  TypeIdentifierTypeObjectPairSeq& types) const;
41  void add_type_objects_to_cache(const TypeIdentifierTypeObjectPairSeq& types);
42 
43  /// For converting between complete to minimal TypeObject of remote types
44  ///@{
45  void update_type_identifier_map(const TypeIdentifierPairSeq& tid_pairs);
46  bool complete_to_minimal_type_object(const TypeObject& cto, TypeObject& mto) const;
47  ///@}
48 
49 #ifndef OPENDDS_SAFETY_PROFILE
50  typedef OPENDDS_MAP(TypeIdentifier, DDS::DynamicType_var) DynamicTypeMap;
51  typedef OPENDDS_MAP(DCPS::GUID_t, DynamicTypeMap) GuidTypeMap;
52  DDS::DynamicType_ptr complete_to_dynamic(const CompleteTypeObject& cto, const DCPS::GUID_t& guid);
53  void remove_guid_from_dynamic_map(const DCPS::GUID_t& guid);
54 
55  bool has_complete(const TypeIdentifier& ti) const;
56  DDS::DynamicType_ptr type_identifier_to_dynamic(const TypeIdentifier& ti, const DCPS::GUID_t& guid);
57 #endif // OPENDDS_SAFETY_PROFILE
58 
59  /// For TypeLookup_getTypeDependencies
60  bool get_type_dependencies(const TypeIdentifier& type_id,
61  TypeIdentifierWithSizeSeq& dependencies) const;
62  void get_type_dependencies(const TypeIdentifierSeq& type_ids,
63  TypeIdentifierWithSizeSeq& dependencies) const;
64  void add_type_dependencies(const TypeIdentifier& type_id,
65  const TypeIdentifierWithSizeSeq& dependencies);
66 
67  /// For adding local endpoint types
68  void add(TypeMap::const_iterator begin, TypeMap::const_iterator end);
69 
70  bool type_object_in_cache(const TypeIdentifier& ti) const;
71  bool extensibility(TypeFlag extensibility_mask, const TypeIdentifier& ti) const;
72 
73  /// For caching and retrieving TypeInformation of remote endpoints
74  void cache_type_info(const DDS::BuiltinTopicKey_t& key, const TypeInformation& type_info);
75  const TypeInformation& get_type_info(const DDS::BuiltinTopicKey_t& key) const;
76 
77 private:
78  const TypeObject& get_type_object_i(const TypeIdentifier& type_id) const;
79  void get_type_dependencies_i(const TypeIdentifierSeq& type_ids,
80  TypeIdentifierWithSizeSeq& dependencies) const;
81 
82  /// Contains both minimal and complete type mapping.
83  TypeMap type_map_;
84 
85  /// For dependencies of local types
86  typedef OPENDDS_MAP(TypeIdentifier, TypeIdentifierWithSizeSeq) TypeIdentifierWithSizeSeqMap;
87  TypeIdentifierWithSizeSeqMap type_dependencies_map_;
88 
90 
92 
93  /// Mapping from complete to minimal TypeIdentifiers of dependencies of remote types.
94  typedef OPENDDS_MAP(TypeIdentifier, TypeIdentifier) TypeIdentifierMap;
95  TypeIdentifierMap complete_to_minimal_ti_map_;
96 
97  bool get_minimal_type_identifier(const TypeIdentifier& ct, TypeIdentifier& mt) const;
98 
99  // Initialize received TypeObjects to defaults.
100  bool set_type_object_defaults(TypeObject& to);
101 
102  bool complete_to_minimal_struct(const CompleteStructType& ct, MinimalStructType& mt) const;
103  bool complete_to_minimal_union(const CompleteUnionType& ct, MinimalUnionType& mt) const;
104  bool complete_to_minimal_annotation(const CompleteAnnotationType& ct, MinimalAnnotationType& mt) const;
105  bool complete_to_minimal_alias(const CompleteAliasType& ct, MinimalAliasType& mt) const;
106  bool complete_to_minimal_sequence(const CompleteSequenceType& ct, MinimalSequenceType& mt) const;
107  bool complete_to_minimal_array(const CompleteArrayType& ct, MinimalArrayType& mt) const;
108  bool complete_to_minimal_map(const CompleteMapType& ct, MinimalMapType& mt) const;
109  bool complete_to_minimal_enumerated(const CompleteEnumeratedType& ct, MinimalEnumeratedType& mt) const;
110  bool complete_to_minimal_bitmask(const CompleteBitmaskType& ct, MinimalBitmaskType& mt) const;
111  bool complete_to_minimal_bitset(const CompleteBitsetType& ct, MinimalBitsetType& mt) const;
112 
113 #ifndef OPENDDS_SAFETY_PROFILE
114  DDS::MemberDescriptor* complete_struct_member_to_member_descriptor(const CompleteStructMember& cm, const DCPS::GUID_t& guid);
115  DDS::MemberDescriptor* complete_union_member_to_member_descriptor(const CompleteUnionMember& cm, const DCPS::GUID_t& guid);
116  DDS::MemberDescriptor* complete_annotation_member_to_member_descriptor(const CompleteAnnotationParameter& cm, const DCPS::GUID_t& guid);
117  void complete_to_dynamic_i(DynamicTypeImpl* dt, const CompleteTypeObject& cto, const DCPS::GUID_t& guid);
118  GuidTypeMap gt_map_;
119 #endif
120  /// Map from BuiltinTopicKey_t of remote endpoint to its TypeInformation.
122  DCPS::BuiltinTopicKey_tKeyLessThan) TypeInformationMap;
123  TypeInformationMap type_info_map_;
125 };
126 
128 
129 } // namespace XTypes
130 } // namespace OpenDDS
131 
133 
134 
135 #endif /* ifndef OPENDDS_DCPS_XTYPES_TYPE_LOOKUP_SERVICE_H */
TypeIdentifierMap complete_to_minimal_ti_map_
TypeIdentifierWithSizeSeqMap type_dependencies_map_
#define OpenDDS_Dcps_Export
Definition: dcps_export.h:24
sequence< octet > key
TypeMap type_map_
Contains both minimal and complete type mapping.
#define OPENDDS_MAP_CMP(K, V, C)
ACE_CDR::UShort TypeFlag
Definition: TypeObject.h:399
DCPS::RcHandle< TypeLookupService > TypeLookupService_rch
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
typedef OPENDDS_MAP(TypeIdentifier, TypeObject) TypeMap
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
extensibility(MUTABLE) struct TypeLookup_getTypes_In
Definition: TypeLookup.idl:29