101 AST_Structure* struct_node = 0;
102 AST_Union* union_node = 0;
103 if (!node || !
name) {
106 if (node->node_type() == AST_Decl::NT_struct) {
107 struct_node =
dynamic_cast<AST_Structure*
>(node);
108 }
else if (node->node_type() == AST_Decl::NT_union) {
109 union_node =
dynamic_cast<AST_Union*
>(node);
114 if (!struct_node && !union_node) {
115 idl_global->err()->misc_error(
116 "Could not cast AST Nodes to valid types", node);
121 IDL_GlobalData::DCPS_Data_Type_Info* info = 0;
124 info = idl_global->is_dcps_type(
name);
125 if (
be_global->is_topic_type(struct_node)) {
127 key_count = keys.
count();
129 key_count = info->key_list_.size();
133 }
else if (
be_global->is_topic_type(union_node)) {
134 key_count =
be_global->union_discriminator_is_key(union_node) ? 1 : 0;
140 const std::string short_name =
name->last_component()->get_string();
142 const std::string ts_short_name =
to_string(
144 const std::string unescaped_name =
147 static const std::string ns(
"OpenDDS::DCPS::");
150 static const char* idl_includes[] = {
151 "dds/DdsDcpsInfrastructure.idl",
"dds/DdsDcpsTopic.idl",
152 "dds/DdsDcpsPublication.idl",
"dds/DdsDcpsSubscriptionExt.idl",
153 "dds/DdsDcpsTypeSupportExt.idl" 155 add_includes(idl_includes, BE_GlobalData::STREAM_IDL);
158 dc.replace(dc.end() - 6, dc.end() - 2,
"C");
161 static const char* h_includes[] = {
162 "dds/DCPS/TypeSupportImpl.h",
"dds/DCPS/ValueDispatcher.h" 164 add_includes(h_includes, BE_GlobalData::STREAM_H);
166 static const char* cpp_includes[] = {
167 "dds/DCPS/debug.h",
"dds/DCPS/Registered_Data_Types.h",
168 "dds/DdsDcpsDomainC.h",
"dds/DCPS/Service_Participant.h",
169 "dds/DCPS/Qos_Helper.h",
"dds/DCPS/PublicationInstance.h",
170 "dds/DCPS/PublisherImpl.h",
"dds/DCPS/SubscriberImpl.h",
171 "dds/DCPS/ReceivedDataElementList.h",
"dds/DCPS/RakeResults_T.h",
172 "dds/DCPS/BuiltInTopicUtils.h",
"dds/DCPS/Util.h",
173 "dds/DCPS/ContentFilteredTopicImpl.h",
"dds/DCPS/RakeData.h",
174 "dds/DCPS/MultiTopicDataReader_T.h",
"dds/DCPS/DataWriterImpl_T.h",
175 "dds/DCPS/DataReaderImpl_T.h",
"dds/DCPS/XTypes/TypeObject.h" 177 add_includes(cpp_includes, BE_GlobalData::STREAM_CPP);
179 std::map<std::string, std::string> replacements;
183 replacements[
"SCOPED_NOT_GLOBAL"] =
191 replaceAll(idl, replacements);
199 "class " << ts_short_name <<
"TypeSupportImpl;\n";
204 "OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL\n" 205 "namespace OpenDDS {\n" 208 "struct DDSTraits<" << cxx_name <<
"> {\n" 209 " typedef " << cxx_name <<
" MessageType;\n" 210 " typedef " << ts_name <<
be_global->sequence_suffix() <<
" MessageSequenceType;\n" 211 " typedef " << ts_name <<
be_global->sequence_suffix() <<
"::PrivateMemberAccess MessageSequenceAdapterType;\n" 212 " typedef " << ts_name <<
"TypeSupport TypeSupportType;\n" 213 " typedef " << ts_name <<
"TypeSupportImpl TypeSupportImplType;\n" 214 " typedef " << ts_name <<
"DataWriter DataWriterType;\n" 215 " typedef " << ts_name <<
"DataReader DataReaderType;\n" 216 " typedef " << cxx_name <<
"_OpenDDS_KeyLessThan LessThanType;\n" 217 " typedef OpenDDS::DCPS::KeyOnly<const " << cxx_name <<
"> KeyOnlyType;\n" 218 " typedef " << xtag <<
" XtagType;\n" 220 " static const char* type_name() { return \"" << unescaped_name <<
"\"; }\n" 221 " static size_t key_count() { return " << key_count <<
"; }\n" 222 " static bool is_key(const char*);\n" 224 "} // namespace DCPS\n" 225 "} // namespace OpenDDS\n" 226 "OPENDDS_END_VERSIONED_NAMESPACE_DECL\n\n";
229 "OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL\n" 230 "namespace OpenDDS {\n" 232 "bool DDSTraits<" << cxx_name <<
">::is_key(const char* field)\n" 234 " ACE_UNUSED_ARG(field);\n";
235 if (struct_node && key_count) {
245 "} // namespace DCPS\n" 246 "} // namespace OpenDDS\n" 247 "OPENDDS_END_VERSIONED_NAMESPACE_DECL\n\n";
254 "class " <<
be_global->export_macro() <<
" " << ts_short_name <<
"TypeSupportImpl\n" 255 " : public virtual OpenDDS::DCPS::LocalObject<" << ts_short_name <<
"TypeSupport>\n" 256 " , public virtual OpenDDS::DCPS::TypeSupportImpl_T<" << short_name <<
">\n" 257 " , public virtual OpenDDS::DCPS::ValueDispatcher_T<" << short_name <<
">\n" 260 " typedef " << ts_short_name <<
"TypeSupport TypeSupportType;\n" 261 " typedef " << ts_short_name <<
"TypeSupport::_var_type _var_type;\n" 262 " typedef " << ts_short_name <<
"TypeSupport::_ptr_type _ptr_type;\n" 264 " " << ts_short_name <<
"TypeSupportImpl() {}\n" 265 " virtual ~" << ts_short_name <<
"TypeSupportImpl() {}\n" 267 " virtual " <<
be_global->versioning_name() <<
"::DDS::DataWriter_ptr create_datawriter();\n" 268 " virtual " <<
be_global->versioning_name() <<
"::DDS::DataReader_ptr create_datareader();\n" 269 "#ifndef OPENDDS_NO_MULTI_TOPIC\n" 270 " virtual " <<
be_global->versioning_name() <<
"::DDS::DataReader_ptr create_multitopic_datareader();\n" 271 "#endif /* !OPENDDS_NO_MULTI_TOPIC */\n" 272 "#ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE\n" 273 " virtual const OpenDDS::DCPS::MetaStruct& getMetaStructForType() const;\n" 274 "#endif /* !OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE */\n" 276 " virtual const OpenDDS::XTypes::TypeIdentifier& getMinimalTypeIdentifier() const;\n" 277 " virtual const OpenDDS::XTypes::TypeMap& getMinimalTypeMap() const;\n" 279 " virtual const OpenDDS::XTypes::TypeIdentifier& getCompleteTypeIdentifier() const;\n" 280 " virtual const OpenDDS::XTypes::TypeMap& getCompleteTypeMap() const;\n" 282 " static " << ts_short_name <<
"TypeSupport::_ptr_type _narrow(CORBA::Object_ptr obj);\n" 291 "::DDS::DataWriter_ptr " << ts_short_name <<
"TypeSupportImpl::create_datawriter()\n" 293 " typedef OpenDDS::DCPS::DataWriterImpl_T<" << short_name <<
"> DataWriterImplType;\n" 294 " ::DDS::DataWriter_ptr writer_impl = ::DDS::DataWriter::_nil();\n" 295 " ACE_NEW_NORETURN(writer_impl,\n" 296 " DataWriterImplType());\n" 297 " return writer_impl;\n" 299 "::DDS::DataReader_ptr " << ts_short_name <<
"TypeSupportImpl::create_datareader()\n" 301 " typedef OpenDDS::DCPS::DataReaderImpl_T<" << short_name <<
"> DataReaderImplType;\n" 302 " ::DDS::DataReader_ptr reader_impl = ::DDS::DataReader::_nil();\n" 303 " ACE_NEW_NORETURN(reader_impl,\n" 304 " DataReaderImplType());\n" 305 " return reader_impl;\n" 307 "#ifndef OPENDDS_NO_MULTI_TOPIC\n" 308 "::DDS::DataReader_ptr " << ts_short_name <<
"TypeSupportImpl::create_multitopic_datareader()\n" 310 " typedef OpenDDS::DCPS::DataReaderImpl_T<" << short_name <<
"> DataReaderImplType;\n" 311 " typedef OpenDDS::DCPS::MultiTopicDataReader_T<" << short_name <<
", DataReaderImplType> MultiTopicDataReaderImplType;\n" 312 " ::DDS::DataReader_ptr multitopic_reader_impl = ::DDS::DataReader::_nil();\n" 313 " ACE_NEW_NORETURN(multitopic_reader_impl,\n" 314 " MultiTopicDataReaderImplType());\n" 315 " return multitopic_reader_impl;\n" 317 "#endif /* !OPENDDS_NO_MULTI_TOPIC */\n\n" 318 "#ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE\n" 319 "const OpenDDS::DCPS::MetaStruct& " << ts_short_name <<
"TypeSupportImpl::getMetaStructForType() const\n" 321 " return OpenDDS::DCPS::getMetaStruct<" << short_name <<
">();\n" 323 "#endif /* !OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE */\n\n" 325 " OpenDDS::DCPS::TypeSupportInitializer<" << ts_short_name <<
"TypeSupportImpl> ts_init_" << name_underscores <<
";\n" 328 "const OpenDDS::XTypes::TypeIdentifier& " << ts_short_name <<
"TypeSupportImpl::getMinimalTypeIdentifier() const\n" 332 const bool generate_xtypes = !
be_global->suppress_xtypes() && !java_ts_only;
333 if (generate_xtypes) {
335 " return OpenDDS::DCPS::getMinimalTypeIdentifier<" << xtag <<
">();\n";
338 " static OpenDDS::XTypes::TypeIdentifier ti;\n" 343 "const OpenDDS::XTypes::TypeMap& " << ts_short_name <<
"TypeSupportImpl::getMinimalTypeMap() const\n" 346 if (generate_xtypes) {
348 " return OpenDDS::DCPS::getMinimalTypeMap<" << xtag <<
">();\n";
351 " static OpenDDS::XTypes::TypeMap tm;\n" 356 "const OpenDDS::XTypes::TypeIdentifier& " << ts_short_name <<
"TypeSupportImpl::getCompleteTypeIdentifier() const\n" 359 const bool generate_xtypes_complete = generate_xtypes &&
be_global->xtypes_complete();
360 if (generate_xtypes_complete) {
362 " return OpenDDS::DCPS::getCompleteTypeIdentifier<" << xtag <<
">();\n";
365 " static OpenDDS::XTypes::TypeIdentifier ti;\n" 370 "const OpenDDS::XTypes::TypeMap& " << ts_short_name <<
"TypeSupportImpl::getCompleteTypeMap() const\n" 373 if (generate_xtypes_complete) {
375 " return OpenDDS::DCPS::getCompleteTypeMap<" << xtag <<
">();\n";
378 " static OpenDDS::XTypes::TypeMap tm;\n" 383 << ts_short_name <<
"TypeSupport::_ptr_type " << ts_short_name <<
"TypeSupportImpl::_narrow(CORBA::Object_ptr obj)\n" 385 " return TypeSupportType::_narrow(obj);\n" 391 if (node->node_type() == AST_Decl::NT_struct) {
394 idl_global->err()->misc_error(
395 "Generating FACE type support for Union topic types is not supported", node);
const char * c_str(void) const
static std::string to_string(Identifier *id, EscapeContext ec=EscapeContext_Normal)
void generate(UTL_ScopedName *name)
DDS::ReturnCode_t key_count(DDS::DynamicType_ptr type, size_t &count)
static std::string get_xtag_name(UTL_ScopedName *name)
This is for generated IDL. (Like *TypeSupport.idl)
std::string scoped(UTL_ScopedName *sn, EscapeContext ec=EscapeContext_Normal)
This is for a name coming from generated IDL. (Like *TypeSupportC.h)
BE_GlobalData * be_global
size_type length(void) const
std::string idl_template_
static std::string scoped_helper(UTL_ScopedName *sn, const char *sep, EscapeContext cxt=EscapeContext_Normal)