mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
refs #684, #766, #776 Support %OwnerName% in cache keys by allowing CCached::m_element to be a dummy
and by using a trick with explicit destructor call and placement new to reconstruct CCached when owner's name changes.
This commit is contained in:
@@ -43,6 +43,16 @@ namespace BlackMisc
|
||||
};
|
||||
//! \endcond
|
||||
|
||||
/*!
|
||||
* \private Destroy an object and reconstruct it with the given constructor arguments.
|
||||
*/
|
||||
template <typename T, typename... Args>
|
||||
void reconstruct(T *object, Args &&... args)
|
||||
{
|
||||
object->~T();
|
||||
new (object) T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \private QObject subclass used by CCached<T> class template for signal/slot communication with CValueCache.
|
||||
* An instance of this class is shared between all CCached<T> referring to the same CValueCache and owned by the same QObject,
|
||||
@@ -76,6 +86,9 @@ namespace BlackMisc
|
||||
//! Set the functor to call to notify that the value corresponding to the element's key was modified.
|
||||
void setNotifySlot(Element &element, NotifySlot slot);
|
||||
|
||||
//! True if the currently paged value corresponds to a valid key.
|
||||
bool isInitialized(const Element &element) const;
|
||||
|
||||
//! True if the currently paged value is a valid instance of the given type.
|
||||
//! \threadsafe
|
||||
bool isValid(const Element &element, int typeId) const;
|
||||
|
||||
Reference in New Issue
Block a user