MaxHistorySize.h
Go to the documentation of this file.
1 #pragma once
2 
4 {
5  // TODO: Replace by ConstrainedHistorySize (not only max entries, e.g. delete oldest / delete least accessed / ...)
6 
8  {
9  public:
10  /**
11  * @brief Set the maximum number of snapshots to be contained in an entity.
12  * Affected entities are to be update right away.
13  */
14  void setMaxHistorySize(long maxSize, const std::string& additionalInfo = "");
15 
16  long getMaxHistorySize() const;
17 
18 
19  protected:
20  /**
21  * @brief Maximum size of entity histories.
22  *
23  * If negative, the size of `history` is not limited.
24  *
25  * @see Entity::maxHstorySize
26  */
27  long _maxHistorySize = -1;
28  };
29 
30  template <class DerivedT>
32  {
33  public:
34  /**
35  * @brief Sets the maximum history size of entities in this container.
36  * This affects all current entities as well as new ones.
37  *
38  * @see MaxHistorySize::setMaxHistorySize()
39  */
40  void
41  setMaxHistorySize(long maxSize)
42  {
44  static_cast<DerivedT&>(*this).forEachChild([maxSize](auto& child)
45  { child.setMaxHistorySize(maxSize); });
46  }
47  };
48 } // namespace armarx::armem::server::wm::detail
armarx::armem::server::wm::detail::MaxHistorySizeParent::setMaxHistorySize
void setMaxHistorySize(long maxSize)
Sets the maximum history size of entities in this container.
Definition: MaxHistorySize.h:41
armarx::armem::server::wm::detail
Definition: MaxHistorySize.cpp:5
armarx::armem::server::wm::detail::MaxHistorySize::_maxHistorySize
long _maxHistorySize
Maximum size of entity histories.
Definition: MaxHistorySize.h:27
armarx::armem::server::wm::detail::MaxHistorySizeParent
Definition: MaxHistorySize.h:31
armarx::armem::server::wm::detail::MaxHistorySize::getMaxHistorySize
long getMaxHistorySize() const
Definition: MaxHistorySize.cpp:32
armarx::armem::server::wm::detail::MaxHistorySize
Definition: MaxHistorySize.h:7
armarx::armem::server::wm::detail::MaxHistorySize::setMaxHistorySize
void setMaxHistorySize(long maxSize, const std::string &additionalInfo="")
Set the maximum number of snapshots to be contained in an entity.
Definition: MaxHistorySize.cpp:8