OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::UndoRedo::ObjectHistory< T > Class Template Referenceabstract
Inheritance diagram for Slic3r::UndoRedo::ObjectHistory< T >:
Collaboration diagram for Slic3r::UndoRedo::ObjectHistory< T >:

Public Member Functions

 ~ObjectHistory () override
bool empty () override
size_t release_before_timestamp (size_t timestamp) override
size_t release_after_timestamp (size_t timestamp) override
size_t release_between_timestamps (size_t timestamp_start, size_t timestamp_end) override
virtual bool is_mutable () const =0
virtual bool is_immutable () const =0
virtual bool is_optional () const
virtual const void * immutable_object_ptr () const
virtual size_t release_optional ()=0
virtual void restore_optional ()=0
virtual size_t memsize () const =0
virtual bool valid ()=0

Protected Attributes

std::vector< T > m_history

Detailed Description

template<typename T>
class Slic3r::UndoRedo::ObjectHistory< T >

Constructor & Destructor Documentation

◆ ~ObjectHistory()

template<typename T>
Slic3r::UndoRedo::ObjectHistory< T >::~ObjectHistory ( )
inlineoverride
144{}

Member Function Documentation

◆ empty()

template<typename T>
bool Slic3r::UndoRedo::ObjectHistory< T >::empty ( )
inlineoverridevirtual

Implements Slic3r::UndoRedo::ObjectHistoryBase.

147{ return m_history.empty(); }
std::vector< T > m_history
Definition UndoRedo.cpp:228

References m_history.

◆ immutable_object_ptr()

virtual const void * Slic3r::UndoRedo::ObjectHistoryBase::immutable_object_ptr ( ) const
inlinevirtualinherited

Reimplemented in Slic3r::UndoRedo::ImmutableObjectHistory< T >.

108{ return nullptr; }

◆ is_immutable()

virtual bool Slic3r::UndoRedo::ObjectHistoryBase::is_immutable ( ) const
pure virtualinherited

◆ is_mutable()

virtual bool Slic3r::UndoRedo::ObjectHistoryBase::is_mutable ( ) const
pure virtualinherited

◆ is_optional()

virtual bool Slic3r::UndoRedo::ObjectHistoryBase::is_optional ( ) const
inlinevirtualinherited

Reimplemented in Slic3r::UndoRedo::ImmutableObjectHistory< T >.

106{ return false; }

◆ memsize()

virtual size_t Slic3r::UndoRedo::ObjectHistoryBase::memsize ( ) const
pure virtualinherited

◆ release_after_timestamp()

template<typename T>
size_t Slic3r::UndoRedo::ObjectHistory< T >::release_after_timestamp ( size_t timestamp)
inlineoverridevirtual

Implements Slic3r::UndoRedo::ObjectHistoryBase.

178 {
179 size_t mem_released = 0;
180 if (! m_history.empty()) {
181 assert(this->valid());
182 // it points to an interval which either starts with timestamp, or follows the timestamp.
183 auto it = std::lower_bound(m_history.begin(), m_history.end(), T(timestamp, timestamp));
184 if (it != m_history.begin()) {
185 auto it_prev = it;
186 -- it_prev;
187 assert(it_prev->begin() < timestamp);
188 // Trim the last interval with timestamp.
189 it_prev->trim_end(timestamp);
190 }
191 for (auto it2 = it; it2 != m_history.end(); ++ it2)
193 m_history.erase(it, m_history.end());
194 assert(this->valid());
195 }
196 return mem_released;
197 }
virtual size_t memsize() const =0
Definition UndoRedo.cpp:142

References m_history, and Slic3r::UndoRedo::ObjectHistoryBase::valid().

Here is the call graph for this function:

◆ release_before_timestamp()

template<typename T>
size_t Slic3r::UndoRedo::ObjectHistory< T >::release_before_timestamp ( size_t timestamp)
inlineoverridevirtual

Implements Slic3r::UndoRedo::ObjectHistoryBase.

150 {
151 size_t mem_released = 0;
152 if (! m_history.empty()) {
153 assert(this->valid());
154 // it points to an interval which either starts with timestamp, or follows the timestamp.
155 auto it = std::lower_bound(m_history.begin(), m_history.end(), T(timestamp, timestamp));
156 // Find the first iterator with begin() < timestamp.
157 if (it == m_history.end())
158 -- it;
159 while (it != m_history.begin() && it->begin() >= timestamp)
160 -- it;
161 if (it->begin() < timestamp && it->end() > timestamp) {
162 it->trim_begin(timestamp);
163 if (it != m_history.begin())
164 -- it;
165 }
166 if (it->end() <= timestamp) {
167 auto it_end = ++ it;
168 for (it = m_history.begin(); it != it_end; ++ it)
169 mem_released += it->memsize();
170 m_history.erase(m_history.begin(), it_end);
171 }
172 assert(this->valid());
173 }
174 return mem_released;
175 }

References m_history, and Slic3r::UndoRedo::ObjectHistoryBase::valid().

Here is the call graph for this function:

◆ release_between_timestamps()

template<typename T>
size_t Slic3r::UndoRedo::ObjectHistory< T >::release_between_timestamps ( size_t timestamp_start,
size_t timestamp_end )
inlineoverridevirtual

Implements Slic3r::UndoRedo::ObjectHistoryBase.

202 {
203 size_t mem_released = 0;
204 if (! m_history.empty()) {
205 assert(this->valid());
206 // Find the span of m_history intervals that are fully in (timestamp_start, timestamp_end>, thus they will be never
207 // deserialized for any snapshot in <timestamp_start, timestamp_end).
208 auto it_lo = std::upper_bound(m_history.begin(), m_history.end(), timestamp_start, [](size_t l, const auto &r) { return l < r.begin(); });
209 auto it_hi = std::upper_bound(it_lo, m_history.end(), timestamp_end, [](size_t l, const auto &r) { return l < r.end(); });
210 if (it_lo != it_hi) {
211 // There are some intervals that start inside (timestamp_start, timestamp_end), that could be released.
212 assert(it_lo->begin() > timestamp_start && it_lo->end() <= timestamp_end);
213 assert(it_hi == m_history.end() || (it_hi->begin() > it_lo->begin() && it_hi->end() > timestamp_end));
214 if (it_lo != m_history.begin() && it_hi != m_history.end()) {
215 // One may consider merging the two intervals.
216 //FIXME merge them.
217 }
218 for (auto it = it_lo; it != it_hi; ++ it)
219 mem_released += it->memsize();
220 m_history.erase(it_lo, it_hi);
221 }
222 assert(this->valid());
223 }
224 return mem_released;
225 }

References m_history, and Slic3r::UndoRedo::ObjectHistoryBase::valid().

Here is the call graph for this function:

◆ release_optional()

virtual size_t Slic3r::UndoRedo::ObjectHistoryBase::release_optional ( )
pure virtualinherited

◆ restore_optional()

virtual void Slic3r::UndoRedo::ObjectHistoryBase::restore_optional ( )
pure virtualinherited

◆ valid()

virtual bool Slic3r::UndoRedo::ObjectHistoryBase::valid ( )
pure virtualinherited

Implemented in Slic3r::UndoRedo::ImmutableObjectHistory< T >, and Slic3r::UndoRedo::MutableObjectHistory< T >.

Referenced by Slic3r::UndoRedo::ObjectHistory< T >::release_after_timestamp(), Slic3r::UndoRedo::ObjectHistory< T >::release_before_timestamp(), and Slic3r::UndoRedo::ObjectHistory< T >::release_between_timestamps().

Here is the caller graph for this function:

Member Data Documentation

◆ m_history

template<typename T>
std::vector<T> Slic3r::UndoRedo::ObjectHistory< T >::m_history
protected

The documentation for this class was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/Utils/UndoRedo.cpp