libart-paperback 0.1.0-a.1.20260122225059.e5fea306241a
PDF (1.4) library for C++
file.hxx
1#ifndef art__paperback__carousel__file_hxx_
2#define art__paperback__carousel__file_hxx_
3
4#include <art/paperback/types.hxx>
5#include <art/paperback/forward.hxx>
6
7#include <art/paperback/carousel/array.hxx>
8#include <art/paperback/carousel/cross-reference.hxx>
9#include <art/paperback/carousel/name.hxx>
10#include <art/paperback/carousel/object.hxx>
11#include <art/paperback/carousel/writer.hxx>
12
14{
15
16 /// Represents a COS-format file.
17 ///
18 class File
19 {
20 public:
21 struct Create_new {};
22
23 /// Dispatch-tag for creating a new COS-file.
24 ///
25 static constexpr Create_new create_new{};
26
27 /// Constructor.
28 ///
29 File(Create_new const&, iostream&, int, int, string);
30
31 /// Destructor.
32 ///
33 ~File() noexcept;
34
35 /// Access the COS-file catalog dictionary object.
36 ///
38 catalog();
39
40 /// Access the COS-file info dictionary object.
41 ///
43 info();
44
45 /// Create a new object.
46 ///
47 template<typename T, typename... Args>
48 Object
49 create_object(Args&&... args)
50 {
51 auto identity = allocate();
52
53 auto container = make_shared<Object_model::Container<T>>(
54 std::forward<Args>(args)...
55 );
56
57 insert(identity, std::move(container));
58
59 return Object{
60 make_shared<Object_model::Reference>(*this, identity)
61 };
62 }
63
64 /// Commit the current COS-file revision to the output stream.
65 ///
66 void
68
69 private:
71
72 /// Get container.
73 ///
75 get_container(Identity const&);
76
77 /// Get container.
78 ///
80 get_container(Identity const&) const;
81
82 private:
83 File(File const&) = delete;
84 File(File&&) = delete;
85 File& operator=(File const&) = delete;
86 File& operator=(File&&) = delete;
87
88 /// Allocates a new index.
89 ///
91 allocate();
92
93 /// Inserts an object into the cross-reference table.
94 ///
95 void
96 insert(Identity const&, shared_ptr<Object_model::Container_base>);
97
98 struct Revision;
99
100 struct Internal;
101 unique_ptr<Internal> internal;
102
103 };
104
105} // namespace Art::Paperback::Carousel
106
107#endif
Represents a COS dictionary.
Definition dictionary.hxx:17
Represents a COS-format file.
Definition file.hxx:19
File(Create_new const &, iostream &, int, int, string)
Constructor.
Definition file.cxx:121
Object create_object(Args &&... args)
Create a new object.
Definition file.hxx:49
Object_model::Container_base & get_container(Identity const &)
Get container.
Definition file.cxx:273
static constexpr Create_new create_new
Dispatch-tag for creating a new COS-file.
Definition file.hxx:25
~File() noexcept
Destructor.
Definition file.cxx:135
Identity allocate()
Allocates a new index.
Definition file.cxx:289
void commit_revision()
Commit the current COS-file revision to the output stream.
Definition file.cxx:181
Dictionary & info()
Access the COS-file info dictionary object.
Definition file.cxx:163
void insert(Identity const &, shared_ptr< Object_model::Container_base >)
Inserts an object into the cross-reference table.
Definition file.cxx:299
Dictionary & catalog()
Access the COS-file catalog dictionary object.
Definition file.cxx:150
Base class for containers.
Definition object-model.hxx:82
Represents a reference to an indirect object.
Definition object-model.hxx:241
Represents a COS-file object.
Definition object.hxx:16
COS file format implementation namespace.
Definition array.cxx:6
Represents the identity of an indirect object.
Definition types.hxx:81