ai::BooleanAttributeCache< Attribute_t, Bit_t > Class Template Reference
BooleanAttributeCache: A class to store boolean attributes.
More...
#include <IAIScopedCache.hpp>
List of all members.
Public Member Functions |
bool | GetValue (Attribute_t inAttr, bool &outValue) const AINOEXCEPT |
void | SetValue (Attribute_t inAttr, const bool inValue) AINOEXCEPT |
void | Clear () AINOEXCEPT |
Detailed Description
template<typename Attribute_t, typename Bit_t>
class ai::BooleanAttributeCache< Attribute_t, Bit_t >
BooleanAttributeCache: A class to store boolean attributes.
Attributes are generally specified via some enumeration. Storage of each attribute value inside the cache is in a single bit. Additional storage contains another bit per attribute to indicate initialization status.
Sample usage:
enum class DocumentState : ai::uint8 { kUnsaved = 0, kInIsolationMode = 1, ... kUsingSpotColor = 30 };
using BitStorage = ai::uint32; // Large enough to hold 1 bit for each value in enumeration above.
using DocAttrCache = BooleanAttributeCache <DocumentState, BitStorage>;
using DocAttrCacheScopeManager = ai::CacheScopeManager <DocAttrCache>; DocAttrCacheScopeManager cacheScope;
...
bool docIsUnsaved{ false }, docIsInIsolationMode{ false };
if (DocAttrCacheScopeManager::IsCacheValid()) { if (DocAttrCacheScopeManager::GetCache()->GetValue(DocumentState::kUnsaved, docIsUnsaved) == false) { Compute and cache value docIsUnsaved = ComputeDocIsUnsaved(); MyCacheScopeManager::GetCache()->SetValue(DocumentState::kUnsaved, docIsUnsaved); }
if (DocAttrCacheScopeManager::GetCache()->GetValue(DocumentState::kInIsolationMode, docIsInIsolationMode) == false) { Compute and cache value docIsInIsolationMode = ComputeDocIsInIsolationMode(); MyCacheScopeManager::GetCache()->SetValue(DocumentState::kInIsolationMode, docIsInIsolationMode); } } else { Compute docIsUnsaved = ComputeDocIsUnsaved(); docIsInIsolationMode = ComputeDocIsInIsolationMode();
Do not store as cache is invalid }
Use values Print(docIsUnsaved); Print(docIsInIsolationMode);
Member Function Documentation
template<typename Attribute_t , typename Bit_t >
template<typename Attribute_t , typename Bit_t >
template<typename Attribute_t , typename Bit_t >
The documentation for this class was generated from the following file: