Free Electron
Attribute.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_Attribute_h__
8 #define __data_Attribute_h__
9 
10 #define FE_ATTRIBUTE(name,description)
11 #define FE_USE_3(name,description,maybe_use_this_later) name
12 #define FE_SPEC(name,description) name
13 #define FE_USE_1(name) name
14 #define FE_USE_0() "FE_USE"
15 
16 #define FE_DISPATCH(name,doc) name
17 #define FE_SLOT(name) name
18 // yes, cheated, got this macro magic from stackoverflow
19 // this gives FE_USE multiple (unused by C++) arguments (that our dox can use)
20 #define FE_USE_X(x,A,B,C,name, ...) name
21 
22 #define FE_USE(...) FE_USE_X(,##__VA_ARGS__,\
23  FE_USE_3(__VA_ARGS__),\
24  FE_SPEC(__VA_ARGS__),\
25  FE_USE_1(__VA_ARGS__),\
26  FE_USE_0(__VA_ARGS__))
27 
28 namespace fe
29 {
30 
31 struct SerialFlags;
32 
33 
34 /** @brief An attribute within a Layout (record type)
35 
36  @ingroup data
37  */
38 class FE_DL_EXPORT Attribute : public Counted, public ClassSafe<Attribute>
39 {
40  public:
41  Attribute(const Attribute &other);
42 virtual ~Attribute(void);
43 
44  Attribute &operator=(const Attribute &other);
45 
46  /** Get the BaseType for this Attribute. */
47  const sp<BaseType> &type(void) const;
48  /** Get the TypeMaster for the BaseType for this Attribute. */
49  const sp<TypeMaster> &typeMaster(void) const;
50  /** Get the name of this Attribute. */
51  const String &name(void) const;
52  /** Get the long name of this Attribute. */
53  const String verboseName(void) const;
54 
55  /** Return true if attribute should be serialized. */
56  bool isSerialize(void);
57  /** Set whether or not attribute should be serialized. */
58  void setSerialize(bool set);
59 
60  /** Return true if attribute should be cloned. */
61  bool isCloneable(void);
62  /** Set whether or not attribute should be cloned. */
63  void setCloneable(bool set);
64 
65  Instance &defaultInstance(void) { return m_default; }
66  Instance &deadInstance(void) { return m_dead; }
67 
68  void peek(Peeker &peeker);
69 
70  friend class Scope; // only really want Scopes creating these things
71  private:
72  Attribute(const String name, sp<BaseType> type, sp<TypeMaster> spTM);
73  Attribute(void);
74  String m_name;
75  sp<BaseType> m_spType;
76  sp<TypeMaster> m_spTypeMaster;
77  bool m_serialize;
78  bool m_cloneable;
79  Instance m_default;
80  Instance m_dead;
81 };
82 
83 inline const String &Attribute::name(void) const
84 {
85  return m_name;
86 }
87 
88 inline const String Attribute::verboseName(void) const
89 {
90  return "Attribute " + m_name;
91 }
92 
93 inline const sp<BaseType> &Attribute::type(void) const
94 {
95  return m_spType;
96 }
97 
98 inline const sp<TypeMaster> &Attribute::typeMaster(void) const
99 {
100  return m_spTypeMaster;
101 }
102 
103 } /* namespace */
104 
105 #endif /* __data_Attribute_h__ */
Class level locking for thread safety.
Definition: Safe.h:213
Heap-based support for classes participating in fe::ptr <>
Definition: Counted.h:35
Smart pointer used with types represented by BaseType.
Definition: Instance.h:28
kernel
Definition: namespace.dox:3
An attribute within a Layout (record type)
Definition: Attribute.h:38
const String verboseName(void) const
Get the long name of this Attribute.
Definition: Attribute.h:88
Automatically reference-counted string container.
Definition: String.h:128
const sp< TypeMaster > & typeMaster(void) const
Get the TypeMaster for the BaseType for this Attribute.
Definition: Attribute.h:98
const sp< BaseType > & type(void) const
Get the BaseType for this Attribute.
Definition: Attribute.h:93
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Layout namespace.
Definition: Scope.h:71
const String & name(void) const
Get the name of this Attribute.
Definition: Attribute.h:83