libart-paperback 0.1.0-a.1.20260122225059.e5fea306241a
PDF (1.4) library for C++
object.hxx
1#ifndef art__paperback__carousel__object_hxx_
2#define art__paperback__carousel__object_hxx_
3
4#include <art/paperback/types.hxx>
5#include <art/paperback/forward.hxx>
6#include <art/paperback/visitor.hxx>
7
8#include <art/paperback/carousel/object-model.hxx>
9
11{
12
13 /// Represents a COS-file object.
14 ///
15 class Object
16 {
17 public:
18 /// Constructor.
19 ///
20 Object(Undefined const&);
21
22 /// Constructor.
23 ///
25
26 /// Constructor.
27 ///
29
30 /// Constructor.
31 ///
33
34 /// Constructor.
35 ///
37
38 /// Constructor.
39 ///
40 Object(Name);
41
42 /// Constructor.
43 ///
44 Object(Real);
45
46 /// Constructor.
47 ///
48 Object(Text);
49
50 /// Constructor.
51 ///
52 Object(Object const&);
53
54 /// Constructor.
55 ///
56 Object(Object&&);
57
58 /// Attach object to owner.
59 ///
60 void
62
63 /// Check if the objcet is a reference.
64 ///
65 bool
66 is_reference() const;
67
68 /// Get object identity, if reference.
69 ///
70 Identity const&
71 identity() const;
72
73 template<typename>
74 friend
75 bool
76 is_of_type(Object const&);
77
78 template<typename T>
79 friend
80 T&
82
83 template<typename T>
84 friend
85 T const&
86 object_cast(Object const&);
87
88 friend
89 Object
90 clone(Object&);
91
92 friend
93 void
95
96 friend
97 void
98 accept(Object const&, Visitor&);
99
100 /// Assignment.
101 ///
102 Object&
103 operator=(Object const&);
104
105 /// Assignment.
106 ///
107 Object&
108 operator=(Object&&);
109
110 /// Comparison.
111 ///
112 bool
113 operator==(Object const&) const;
114
115 /// Comparison.
116 ///
117 bool
118 operator!=(Object const&) const;
119
120 private:
121 friend File;
122 friend Writer;
123
124 /// Constructor.
125 ///
126 explicit
127 Object(shared_ptr<Object_model::Abstract>);
128
129 /// Get the container of the object.
130 ///
132 container();
133
134 /// Get the container of the object.
135 ///
137 container() const;
138
139 private:
140 /// Holds the data of the object, either an instance of
141 /// Object_model::Reference for references, or an instance of
142 /// Object_model::Container for direct objects.
143 ///
144 shared_ptr<Object_model::Abstract> _data;
145
146 };
147
148 /// Check object type.
149 ///
150 template<typename T>
151 bool
152 is_of_type(Object const& object)
153 {
154 return typeid(T) == object.container().type();
155 }
156
157 /// This function provides access to the value of an object.
158 ///
159 template<typename T>
160 T&
162 {
163 return object.container().get<T>();
164 }
165
166 /// This function provides access to the value of an object.
167 ///
168 template<typename T>
169 T const&
170 object_cast(Object const& object)
171 {
172 return object.container().get<T>();
173 }
174
175 /// Clone an object.
176 ///
177 Object
178 clone(Object&);
179
180 /// Accept visitor on object.
181 ///
182 void
184
185 /// Accept visitor on object.
186 ///
187 void
188 accept(Object const&, Visitor&);
189
190} // namespace Art::Paperback::Carousel
191
192#endif
Definition array.hxx:14
Represents a COS boolean.
Definition boolean.hxx:16
Represents a COS dictionary.
Definition dictionary.hxx:17
Represents a COS integer.
Definition integer.hxx:16
Represents a COS name.
Definition name.hxx:16
Base class for containers.
Definition object-model.hxx:82
Owner of an indirect object.
Definition object-model.hxx:341
Represents a COS-file object.
Definition object.hxx:16
bool operator==(Object const &) const
Comparison.
Definition object.cxx:261
shared_ptr< Object_model::Abstract > _data
Holds the data of the object, either an instance of Object_model::Reference for references,...
Definition object.hxx:144
Identity const & identity() const
Get object identity, if reference.
Definition object.cxx:222
bool operator!=(Object const &) const
Comparison.
Definition object.cxx:270
friend bool is_of_type(Object const &)
Check object type.
Definition object.hxx:152
Object(Undefined const &)
Constructor.
Definition object.cxx:105
friend void accept(Object &, Visitor &)
Accept visitor on object.
Definition object.cxx:312
Object_model::Container_base & container()
Get the container of the object.
Definition object.cxx:288
Object & operator=(Object const &)
Assignment.
Definition object.cxx:235
friend Object clone(Object &)
Clone an object.
Definition object.cxx:303
friend T & object_cast(Object &)
This function provides access to the value of an object.
Definition object.hxx:161
void attach(Object_model::Owner &)
Attach object to owner.
Definition object.cxx:202
bool is_reference() const
Check if the objcet is a reference.
Definition object.cxx:211
Represents a COS real.
Definition real.hxx:16
Represents COS text.
Definition text.hxx:16
Definition undefined.hxx:14
Virtual base class for visitors.
Definition visitor.hxx:10
COS file format implementation namespace.
Definition array.cxx:6
bool is_of_type(Object const &object)
Check object type.
Definition object.hxx:152
void accept(Object &visitee, Visitor &v)
Accept visitor on object.
Definition object.cxx:312
T & object_cast(Object &object)
This function provides access to the value of an object.
Definition object.hxx:161
Object clone(Object &object)
Clone an object.
Definition object.cxx:303
Represents the identity of an indirect object.
Definition types.hxx:81