OpenDDS  Snapshot(2023/04/07-19:43)
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
TopicKeys Class Reference

#include <topic_keys.h>

Classes

class  Error
 
class  Iterator
 

Public Types

enum  RootType {
  PrimitiveType, StructureType, ArrayType, UnionType,
  SequenceType, InvalidType
}
 

Public Member Functions

 TopicKeys ()
 
 TopicKeys (const TopicKeys &other)
 
 TopicKeys (AST_Structure *root, bool recursive=true)
 
 TopicKeys (AST_Union *root)
 
 ~TopicKeys ()
 
TopicKeysoperator= (const TopicKeys &other)
 
AST_Decl * root () const
 
RootType root_type () const
 
Iterator begin ()
 
Iterator end ()
 
size_t count ()
 
bool recursive () const
 

Static Public Member Functions

static RootType root_type (AST_Type *type)
 

Private Attributes

AST_Decl * root_
 
RootType root_type_
 
bool counted_
 
size_t count_
 
bool recursive_
 } More...
 

Detailed Description

Find Keys in Topic Types

Use like this: AST_Structure* struct_node; // ... TopicKeys keys(struct_node); TopicKeys::Iterator end = keys.end(); for (TopicKeys::Iterator i = keys.begin(); i != end; ++i) { AST_Decl* key = *i; // ... }

The key AST_Decl will be a different type of node depending on the key:

Definition at line 34 of file topic_keys.h.

Member Enumeration Documentation

◆ RootType

Enumerator
PrimitiveType 
StructureType 
ArrayType 
UnionType 
SequenceType 
InvalidType 

Definition at line 36 of file topic_keys.h.

Constructor & Destructor Documentation

◆ TopicKeys() [1/4]

TopicKeys::TopicKeys ( )

Definition at line 447 of file topic_keys.cpp.

448  : root_(0),
450  counted_(false),
451  count_(0),
452  recursive_(false)
453 {
454 }
RootType root_type_
Definition: topic_keys.h:195
size_t count_
Definition: topic_keys.h:200
bool recursive_
}
Definition: topic_keys.h:204
AST_Decl * root_
Definition: topic_keys.h:194
bool counted_
Definition: topic_keys.h:199

◆ TopicKeys() [2/4]

TopicKeys::TopicKeys ( const TopicKeys other)

Definition at line 456 of file topic_keys.cpp.

457 {
458  *this = other;
459 }

◆ TopicKeys() [3/4]

TopicKeys::TopicKeys ( AST_Structure *  root,
bool  recursive = true 
)

If recursive is false, do a shallow iteration.

Definition at line 461 of file topic_keys.cpp.

References root(), and root_.

462  : root_(root),
464  counted_(false),
465  count_(0),
467 {
468  root_ = root;
469 }
RootType root_type_
Definition: topic_keys.h:195
size_t count_
Definition: topic_keys.h:200
bool recursive_
}
Definition: topic_keys.h:204
AST_Decl * root_
Definition: topic_keys.h:194
bool counted_
Definition: topic_keys.h:199
AST_Decl * root() const
Definition: topic_keys.cpp:505
bool recursive() const
Definition: topic_keys.cpp:528

◆ TopicKeys() [4/4]

TopicKeys::TopicKeys ( AST_Union *  root)

Definition at line 471 of file topic_keys.cpp.

References root(), and root_.

472  : root_(root),
474  counted_(false),
475  count_(0),
476  recursive_(false)
477 {
478  root_ = root;
479 }
RootType root_type_
Definition: topic_keys.h:195
size_t count_
Definition: topic_keys.h:200
bool recursive_
}
Definition: topic_keys.h:204
AST_Decl * root_
Definition: topic_keys.h:194
bool counted_
Definition: topic_keys.h:199
AST_Decl * root() const
Definition: topic_keys.cpp:505

◆ ~TopicKeys()

TopicKeys::~TopicKeys ( )

Definition at line 481 of file topic_keys.cpp.

482 {
483 }

Member Function Documentation

◆ begin()

TopicKeys::Iterator TopicKeys::begin ( void  )

Definition at line 495 of file topic_keys.cpp.

Referenced by count(), keys_generator::gen_struct(), marshal_generator::gen_typedef(), ts_generator::ts_generator(), and dds_visitor::visit_structure().

496 {
497  return Iterator(*this);
498 }

◆ count()

size_t TopicKeys::count ( void  )

Count the keys in the topic type

Definition at line 515 of file topic_keys.cpp.

References begin(), count_, counted_, and end().

Referenced by metaclass_generator::gen_enum(), keys_generator::gen_struct(), marshal_generator::gen_typedef(), ts_generator::generate_ts(), and dds_visitor::visit_structure().

516 {
517  if (!counted_) {
518  count_ = 0;
519  Iterator finished = end();
520  for (Iterator i = begin(); i != finished; ++i) {
521  count_++;
522  }
523  counted_ = true;
524  }
525  return count_;
526 }
Iterator begin()
Definition: topic_keys.cpp:495
size_t count_
Definition: topic_keys.h:200
bool counted_
Definition: topic_keys.h:199
Iterator end()
Definition: topic_keys.cpp:500

◆ end()

TopicKeys::Iterator TopicKeys::end ( void  )

◆ operator=()

TopicKeys & TopicKeys::operator= ( const TopicKeys other)

Definition at line 485 of file topic_keys.cpp.

References count_, counted_, recursive_, root_, and root_type_.

486 {
487  root_ = other.root_;
488  root_type_ = other.root_type_;
489  counted_ = other.counted_;
490  count_ = other.count_;
491  recursive_ = other.recursive_;
492  return *this;
493 }
RootType root_type_
Definition: topic_keys.h:195
size_t count_
Definition: topic_keys.h:200
bool recursive_
}
Definition: topic_keys.h:204
AST_Decl * root_
Definition: topic_keys.h:194
bool counted_
Definition: topic_keys.h:199

◆ recursive()

bool TopicKeys::recursive ( ) const

Definition at line 528 of file topic_keys.cpp.

References recursive_.

529 {
530  return recursive_;
531 }
bool recursive_
}
Definition: topic_keys.h:204

◆ root()

AST_Decl * TopicKeys::root ( void  ) const

Definition at line 505 of file topic_keys.cpp.

References root_.

Referenced by TopicKeys::Iterator::Iterator(), and TopicKeys().

506 {
507  return root_;
508 }
AST_Decl * root_
Definition: topic_keys.h:194

◆ root_type() [1/2]

TopicKeys::RootType TopicKeys::root_type ( AST_Type *  type)
static

Get the RootType of the AST_Type

Definition at line 15 of file topic_keys.cpp.

References ArrayType, InvalidType, PrimitiveType, SequenceType, StructureType, and UnionType.

Referenced by marshal_generator::gen_typedef(), and TopicKeys::Iterator::Iterator().

16 {
17  if (!type) {
18  return InvalidType;
19  }
20  switch (type->unaliased_type()->node_type()) {
21  case AST_Decl::NT_pre_defined:
22  case AST_Decl::NT_string:
23  case AST_Decl::NT_wstring:
24  case AST_Decl::NT_enum:
25  return PrimitiveType;
26  case AST_Decl::NT_struct:
27  return StructureType;
28  case AST_Decl::NT_union:
29  return UnionType;
30  case AST_Decl::NT_array:
31  return ArrayType;
32  case AST_Decl::NT_sequence:
33  return SequenceType;
34  default:
35  return InvalidType;
36  }
37 }

◆ root_type() [2/2]

TopicKeys::RootType TopicKeys::root_type ( ) const

Definition at line 510 of file topic_keys.cpp.

References root_type_.

Referenced by TopicKeys::Iterator::Iterator().

511 {
512  return root_type_;
513 }
RootType root_type_
Definition: topic_keys.h:195

Member Data Documentation

◆ count_

size_t TopicKeys::count_
private

Definition at line 200 of file topic_keys.h.

Referenced by count(), and operator=().

◆ counted_

bool TopicKeys::counted_
private

Cached Key Count {

Definition at line 199 of file topic_keys.h.

Referenced by count(), and operator=().

◆ recursive_

bool TopicKeys::recursive_
private

}

Have iterators recurse into structures

Definition at line 204 of file topic_keys.h.

Referenced by operator=(), and recursive().

◆ root_

AST_Decl* TopicKeys::root_
private

Definition at line 194 of file topic_keys.h.

Referenced by operator=(), root(), and TopicKeys().

◆ root_type_

RootType TopicKeys::root_type_
private

Definition at line 195 of file topic_keys.h.

Referenced by operator=(), and root_type().


The documentation for this class was generated from the following files: