Free Electron
Depend.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __data_Depend_h__
8 #define __data_Depend_h__
9 
10 namespace fe
11 {
12 
13 /** @brief Attribute dependency information
14 
15  @ingroup data
16 
17  Encapsulates Layout configuration (Attribute dependency) information.
18  This is mainly for internal use, but may have applicability for
19  advanced configuration setup.
20 
21  For typical configuration setup see:
22  - Scope::support()
23  - Scope::enforce()
24  - Scope::populate()
25  - Scope::clear()
26  - Scope::share()
27  */
28 class FE_DL_EXPORT Depend : public Counted
29 {
30  public:
31  /** Dependency types */
32  enum
33  {
34  e_null = (FE_UWORD)(0),
35  e_available = (FE_UWORD)(1<<0),
36  e_attribute = (FE_UWORD)(1<<1),
37  e_populate = (FE_UWORD)(1<<2),
38  e_share = (FE_UWORD)(1<<3),
39  e_within = (FE_UWORD)(1<<4)
40  };
41 
42  Depend(void):
43  m_attributeName(""),
44  m_attributeType(""),
45  m_depName(""),
46  m_shareName(""),
47  m_depFlag(0)
48  { suppressReport(); }
49 
50  Depend(const String& attributeName):
51  m_attributeName(attributeName),
52  m_attributeType(""),
53  m_depName(""),
54  m_shareName(""),
55  m_depFlag(0)
56  { suppressReport(); }
57 
58  Depend(const Depend &other):
59  Castable(),
60  Counted()
61  {
62  m_attributeName = other.m_attributeName;
63  m_attributeType = other.m_attributeType;
64  m_depName = other.m_depName;
65  m_depFlag = other.m_depFlag;
66  m_shareName = other.m_shareName;
67  m_matchAttributes = other.m_matchAttributes;
68  suppressReport();
69  }
70 
71  ~Depend(void)
72  {
73  }
74 
75  Depend &operator=(const Depend &other)
76  {
77  if(this != &other)
78  {
79  m_attributeName = other.m_attributeName;
80  m_attributeType = other.m_attributeType;
81  m_depName = other.m_depName;
82  m_depFlag = other.m_depFlag;
83  m_shareName = other.m_shareName;
84  m_matchAttributes = other.m_matchAttributes;
85  }
86  return *this;
87  }
88 
89  bool operator==(const Depend &other) const
90  {
91  if(m_attributeName != other.m_attributeName) { return false; }
92  if(m_attributeType != other.m_attributeType) { return false; }
93  if(m_depName != other.m_depName) { return false; }
94  if(m_shareName != other.m_shareName) { return false; }
95  if(m_depFlag != other.m_depFlag) { return false; }
96  if(!(m_matchAttributes == other.m_matchAttributes))
97  {
98  if(m_matchAttributes.size() != other.m_matchAttributes.size())
99  {
100  return false;
101  }
102  std::set<String> a, b;
103  for(unsigned int i = 0; i < m_matchAttributes.size(); i++)
104  {
105  a.insert(m_matchAttributes[i]);
106  }
107  for(unsigned int i = 0; i < other.m_matchAttributes.size(); i++)
108  {
109  b.insert(other.m_matchAttributes[i]);
110  }
111  if(!(a == b))
112  {
113  return false;
114  }
115  }
116  return true;
117  }
118 
119  void peek(Peeker &peeker);
120 
121  String &attributeName(void) { return m_attributeName; }
122  String &attributeType(void) { return m_attributeType; }
123  String &dependName(void) { return m_depName; }
124  String &shareName(void) { return m_shareName; }
125  size_t &offset(void) { return m_offset; }
126  FE_UWORD &dependFlag(void) { return m_depFlag; }
128  &matchAttributes(void) { return m_matchAttributes; }
129 
130 const String &name(void) const { return m_attributeName; }
131 const String verboseName(void) const
132  { return "Depend " + m_attributeName + " on " + m_depName; }
133 
134  private:
135  String m_attributeName;
136  String m_attributeType;
137  String m_depName;
138  String m_shareName;
139  Array<String> m_matchAttributes;
140  size_t m_offset;
141  FE_UWORD m_depFlag;
142 };
143 
144 inline void Depend::peek(Peeker &peeker)
145 {
146  peeker.str().catf("attribute:%s type:%s dep:%s share:%s flags:",
147  m_attributeName.c_str(),
148  m_attributeType.c_str(),
149  m_depName.c_str(),
150  m_shareName.c_str());
151  if(m_depFlag & e_available)
152  {
153  peeker.cat(" available");
154  }
155  if(m_depFlag & e_attribute)
156  {
157  peeker.cat(" attribute");
158  }
159  if(m_depFlag & e_populate)
160  {
161  peeker.cat(" populate");
162  }
163  if(m_depFlag & e_share)
164  {
165  peeker.cat(" share");
166  }
167  if(m_depFlag & e_within)
168  {
169  peeker.cat(" within");
170  }
171  peeker.cat(" |");
172  for(unsigned int i = 0; i < m_matchAttributes.size(); i++)
173  {
174  peeker.cat(" ");
175  peeker.cat(m_matchAttributes[i]);
176  }
177 }
178 
179 } /* namespace */
180 
181 #endif /* __data_Depend_h__ */
182 
Heap-based support for classes participating in fe::ptr <>
Definition: Counted.h:35
Base participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:93
Attribute dependency information.
Definition: Depend.h:28
kernel
Definition: namespace.dox:3
BWORD operator==(const DualString &s1, const DualString &s2)
Compare two DualString&#39;s.
Definition: DualString.h:208
Automatically reference-counted string container.
Definition: String.h:128
Wrapper for std::vector.
Definition: Array.h:21