25 #ifndef PSTORE_MCREPO_LINKED_DEFINITIONS_SECTION_HPP 26 #define PSTORE_MCREPO_LINKED_DEFINITIONS_SECTION_HPP 28 #include "pstore/mcrepo/compilation.hpp" 29 #include "pstore/mcrepo/section.hpp" 37 template <
typename InputIt>
38 auto udistance (InputIt first, InputIt last) {
39 auto d = std::distance (first, last);
40 PSTORE_ASSERT (d >= 0);
41 return static_cast<std::make_unsigned_t<decltype (d)>
> (d);
70 , pointer{pointer_} {}
72 bool operator== (
value_type const & rhs)
const noexcept;
73 bool operator!= (
value_type const & rhs)
const noexcept {
74 return !operator== (rhs);
83 std::uint32_t index = 0;
84 std::uint32_t unused = 0;
96 template <
typename Iterator,
97 typename =
typename std::enable_if_t<std::is_same<
98 typename std::iterator_traits<Iterator>::value_type,
value_type>::value>>
107 value_type const & operator[] (std::size_t
const i)
const {
108 return index_impl (*
this, i);
110 value_type & operator[] (std::size_t
const i) {
return index_impl (*
this, i); }
117 const_iterator
begin () const noexcept {
return definitions_; }
118 const_iterator cbegin () const noexcept {
return this->
begin (); }
120 iterator end () noexcept {
return definitions_ + size_; }
121 const_iterator end () const noexcept {
return definitions_ + size_; }
122 const_iterator cend () const noexcept {
return this->end (); }
129 bool empty () const noexcept {
return size_ == 0; }
131 std::size_t
size () const noexcept {
return size_; }
139 static std::size_t size_bytes (std::uint64_t size) noexcept;
142 std::size_t size_bytes ()
const noexcept;
151 -> std::shared_ptr<linked_definitions const>;
154 template <
typename LinkedDefinitions,
typename ResultType =
typename inherit_const<
156 static ResultType & index_impl (LinkedDefinitions & v, std::size_t pos) {
157 PSTORE_ASSERT (pos < v.size ());
158 return v.definitions_[pos];
162 std::uint64_t unused_ = 0;
166 PSTORE_STATIC_ASSERT (std::is_standard_layout<linked_definitions::value_type>::value);
174 template <
typename Iterator,
typename>
175 linked_definitions::linked_definitions (Iterator
begin, Iterator end)
176 : size_{details::udistance (begin, end)} {
177 std::copy (begin, end, &definitions_[0]);
180 PSTORE_STATIC_ASSERT (std::is_standard_layout<linked_definitions>::value);
189 inline unsigned section_alignment<pstore::repo::linked_definitions> (
194 inline std::uint64_t section_size<pstore::repo::linked_definitions> (
211 const_iterator
const end)
215 PSTORE_ASSERT (std::distance (begin, end) > 0 &&
216 "a linked_definitions section must hold " 217 "at least one reference to a definition");
224 std::size_t size_bytes ()
const final;
226 std::uint8_t * write (std::uint8_t * out)
const final;
229 const_iterator
begin ()
const {
return begin_; }
231 const_iterator
end ()
const {
return end_; }
234 std::uintptr_t aligned_impl (std::uintptr_t in)
const final;
236 const_iterator begin_;
251 std::size_t size_bytes ()
const final {
return d_.size_bytes (); }
252 unsigned align ()
const final { error (); }
253 std::size_t size ()
const final { error (); }
259 PSTORE_NO_RETURN
void error ()
const;
272 #endif // PSTORE_MCREPO_LINKED_DEFINITIONS_SECTION_HPP const_iterator end() const
Returns a const_iterator for the end of definition address range.
Definition: linked_definitions_section.hpp:231
const_iterator begin() const
Returns a const_iterator for the beginning of the definition address range.
Definition: linked_definitions_section.hpp:229
Definition: uint128.hpp:85
typed_address< definition > pointer
The address of the definition given by value_type::compilation and value_type::index.
Definition: linked_definitions_section.hpp:90
index::digest compilation
The digest of the compilation containing the definition to which the owning fragment is linked...
Definition: linked_definitions_section.hpp:79
Definition: linked_definitions_section.hpp:64
std::size_t size() const noexcept
Returns the number of elements.
Definition: linked_definitions_section.hpp:131
A simple wrapper around the elements of one of the three arrays that make up a section.
Definition: section.hpp:152
Maps from the type of data that is associated with a fragment's section to a "dispatcher" subclass wh...
Definition: section.hpp:146
transaction< transaction_lock > begin(database &db, transaction_lock &lock)
Creates a new transaction. Every operation performed on a transaction instance can be potentially und...
Definition: transaction.hpp:311
This class is used to add virtual methods to a fragment's section.
Definition: section.hpp:195
Definition: address.hpp:231
An empty class used as the base type for all sections.
Definition: section.hpp:69
Maps from the type of data that is associated with a fragment's section to a "dispatcher" subclass wh...
Definition: section.hpp:214
container< std::uint8_t > payload() const final
Return the data section stored in the object file.
Definition: linked_definitions_section.hpp:256
bool empty() const noexcept
Checks whether the container is empty.
Definition: linked_definitions_section.hpp:129
Represents the definitions linked to a fragment.
Definition: linked_definitions_section.hpp:62
A utility template intended to simplify the writing of the const- and non-const variants of member fu...
A compilation is a holder for zero or more definitions.
Definition: compilation.hpp:128
Definition: nonpod2.cpp:40
Definition: database.hpp:40
Provides a member typedef inherit_const::type, which is defined as R const if T is a const type and R...
Definition: inherit_const.hpp:108
Definition: linked_definitions_section.hpp:206
Definition: linked_definitions_section.hpp:245
A section creation dispatcher is used to instantiate and construct each of a fragment's sections in p...
Definition: section.hpp:91