ATLAS Offline Software
Loading...
Searching...
No Matches
IdDictDictionaryRef Class Reference

#include <IdDictDictionaryRef.h>

Inheritance diagram for IdDictDictionaryRef:
Collaboration diagram for IdDictDictionaryRef:

Public Member Functions

 IdDictDictionaryRef (const std::string &dictionary_name)
 IdDictDictionaryRef (IdDictDictionary *dictionary)
virtual ~IdDictDictionaryRef ()
const std::string & dictionary_name () const
virtual void resolve_references (IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion &region) override
virtual void generate_implementation (const IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion &region, const std::string &tag="") override
virtual void reset_implementation () override
virtual bool verify () const override
virtual Range build_range () const override
virtual void clear ()

Private Attributes

std::string m_dictionary_name
IdDictDictionarym_dictionary {}
bool m_resolved_references {}
bool m_generated_implementation {}
bool m_propagated_information {}

Detailed Description

Definition at line 16 of file IdDictDictionaryRef.h.

Constructor & Destructor Documentation

◆ IdDictDictionaryRef() [1/2]

IdDictDictionaryRef::IdDictDictionaryRef ( const std::string & dictionary_name)

Definition at line 17 of file IdDictDictionaryRef.cxx.

◆ IdDictDictionaryRef() [2/2]

IdDictDictionaryRef::IdDictDictionaryRef ( IdDictDictionary * dictionary)

Definition at line 26 of file IdDictDictionaryRef.cxx.

27 :
28 m_dictionary(dictionary),
32}

◆ ~IdDictDictionaryRef()

IdDictDictionaryRef::~IdDictDictionaryRef ( )
virtual

Definition at line 34 of file IdDictDictionaryRef.cxx.

34 {
35}

Member Function Documentation

◆ build_range()

Range IdDictDictionaryRef::build_range ( ) const
overridevirtual

Implements IdDictRegionEntry.

Definition at line 146 of file IdDictDictionaryRef.cxx.

146 {
147 Range result;
148
149 return(result);
150}

◆ clear()

void IdDictRegionEntry::clear ( )
virtualinherited

Definition at line 29 of file IdDictRegionEntry.cxx.

29 {
30}

◆ dictionary_name()

const std::string & IdDictDictionaryRef::dictionary_name ( ) const
inline

Definition at line 68 of file IdDictDictionaryRef.h.

69{
70 return m_dictionary_name;
71}

◆ generate_implementation()

void IdDictDictionaryRef::generate_implementation ( const IdDictMgr & idd,
IdDictDictionary & dictionary,
IdDictRegion & region,
const std::string & tag = "" )
overridevirtual

Reimplemented from IdDictRegionEntry.

Definition at line 50 of file IdDictDictionaryRef.cxx.

53 {
55 if (m_dictionary) {
57 // Propagate information to referenced dictionary:
58 //
59 // 1) Loop over ranges in this region and add them to the
60 // referenced dictionary, then propagate the generate
61 // implementation
62
63 // 2) Duplicate the regions of the current dictionary in
64 // referenced dictionary. Only the top level range(s) need
65 // to be propagated to correctly calculate the bits of the
66 // upper levels.
67
68 // Save a vector of entries to prepend, inverting their order
69 std::vector<IdDictRegionEntry*> prepend_entries;
70 for (const std::unique_ptr<IdDictRegionEntry>& entry : region.entries()) {
71 if (this == entry.get()) break; // end when we get to the dictionary (this)
72 // If this is a range entry, add a duplicate to all
73 // regions in the subdictionary
74 IdDictRange* range = dynamic_cast<IdDictRange*> (entry.get());
75 if (range) {
76 prepend_entries.insert(prepend_entries.begin(), entry.get());
77 }
78 }
79
80
81
82
83 // Now prepend list to each region and generate each region
84 for (IdDictRegion* region2 : m_dictionary->all_regions()) {
85 for (IdDictRegionEntry* entry : prepend_entries) {
86 IdDictRange* range = dynamic_cast<IdDictRange*> (entry);
87 if (range) {
88 region2->prepend_entry(std::make_unique<IdDictRangeRef> (*range));
89 }
90 }
91 }
92
93 // Now copy all prefixes into new regions in the
94 // referenced dictionary
95 if (prepend_entries.size() > 0) {
96 // Save region number
97 const IdDictRegion& region2 = *m_dictionary->all_regions().back();
98 size_t region_number = region2.index() + 1;
99
100 // Loop over all regions of current dict, add to ref dict (m_dictionary)
101 for (IdDictRegion* region3 : dictionary.all_regions()) {
102 auto new_region = std::make_unique<IdDictRegion> ("dummy", "dummy", "");
103
104 new_region->set_index (region_number++);
105
106 // Now add in only the ranges
107 size_t i = 0;
108 for (const std::unique_ptr<IdDictRegionEntry>& entry : region3->entries()) {
109 if (i++ >= prepend_entries.size()) continue;
110
111 IdDictRange* range = dynamic_cast<IdDictRange*> (entry.get());
112 if (range) {
113 new_region->add_entry(std::make_unique<IdDictRangeRef> (*range));
114 }
115 }
116
117 // to all region vectors
118 m_dictionary->add_region(new_region.get());
119 // to the entries of the dictionary
120 m_dictionary->add_dictentry(std::move(new_region));
121 }
122 }
124 }
125 m_dictionary->generate_implementation(idd, tag);
127 } else {
128 std::cout <<
129 "IdDictDictionaryRef::generate_implementation: - WARNING no dictionary named " << m_dictionary_name << " found, cannot generate implementation "
130 << std::endl;
131 }
132 }
133}
const std::vector< std::unique_ptr< IdDictRegionEntry > > & entries()
Non-const access to entry pointers.
size_t index() const
dictionary
Definition master.py:47

◆ reset_implementation()

void IdDictDictionaryRef::reset_implementation ( )
overridevirtual

Reimplemented from IdDictRegionEntry.

Definition at line 135 of file IdDictDictionaryRef.cxx.

135 {
137 m_dictionary->reset_implementation();
139 }
140}

◆ resolve_references()

void IdDictDictionaryRef::resolve_references ( IdDictMgr & idd,
IdDictDictionary & dictionary,
IdDictRegion & region )
overridevirtual

Reimplemented from IdDictRegionEntry.

Definition at line 37 of file IdDictDictionaryRef.cxx.

39 {
42 if (m_dictionary) {
43 m_dictionary->resolve_references(idd);
44 m_dictionary->set_parent_dict (&dictionary);
45 }
47 }
48}
const IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.

◆ verify()

bool IdDictDictionaryRef::verify ( ) const
overridevirtual

Reimplemented from IdDictRegionEntry.

Definition at line 142 of file IdDictDictionaryRef.cxx.

142 {
143 return(true);
144}

Member Data Documentation

◆ m_dictionary

IdDictDictionary* IdDictDictionaryRef::m_dictionary {}
private

Definition at line 57 of file IdDictDictionaryRef.h.

57{};

◆ m_dictionary_name

std::string IdDictDictionaryRef::m_dictionary_name
private

Definition at line 56 of file IdDictDictionaryRef.h.

◆ m_generated_implementation

bool IdDictDictionaryRef::m_generated_implementation {}
private

Definition at line 62 of file IdDictDictionaryRef.h.

62{};

◆ m_propagated_information

bool IdDictDictionaryRef::m_propagated_information {}
private

Definition at line 63 of file IdDictDictionaryRef.h.

63{};

◆ m_resolved_references

bool IdDictDictionaryRef::m_resolved_references {}
private

Definition at line 61 of file IdDictDictionaryRef.h.

61{};

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