34#include <unordered_map>
53template<
typename ValueType>
54using PROPERTY_MAP = std::map<std::pair<size_t, wxString>, ValueType>;
147 return const_cast<void*
>(
TypeCast( (
const void*) aSource, aBase, aTarget ) );
174 const wxString& aGroup = wxEmptyString );
308 std::vector<std::reference_wrapper<CLASS_DESC>>
m_bases;
371#define REGISTER_TYPE(x) PROPERTY_MANAGER::Instance().RegisterType(TYPE_HASH(x), TYPE_NAME(x))
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Class that other classes need to inherit from, in order to be inspectable.
~PROPERTY_COMMIT_HANDLER()
Provide class metadata.Helper macro to map type hashes to names.
bool m_dirty
Flag indicating that the list of properties needs to be rebuild (RebuildProperties())
CLASSES_INFO GetAllClasses()
std::vector< CLASS_INFO > CLASSES_INFO
const wxString & ResolveType(TYPE_ID aType) const
Return name of a type.
const PROPERTY_LIST & GetProperties(TYPE_ID aType) const
Return all properties for a specific type.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
const PROPERTY_DISPLAY_ORDER & GetDisplayOrder(TYPE_ID aType) const
bool IsWriteableFor(TYPE_ID aItemClass, PROPERTY_BASE *aProp, INSPECTABLE *aItem)
Checks overriden availability and original availability of a property, returns false if the property ...
void PropertyChanged(INSPECTABLE *aObject, PROPERTY_BASE *aProperty)
Callback to alert the notification system that a property has changed.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
void UnregisterListeners(TYPE_ID aType)
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void Rebuild()
Rebuild the list of all registered properties.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
std::unordered_map< TYPE_ID, CLASS_DESC > m_classes
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
CLASS_DESC & getClass(TYPE_ID aTypeId)
void RegisterType(TYPE_ID aType, const wxString &aName)
Associate a name with a type.
bool IsAvailableFor(TYPE_ID aItemClass, PROPERTY_BASE *aProp, INSPECTABLE *aItem)
Checks overriden availability and original availability of a property, returns false if the property ...
void * TypeCast(void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
std::vector< TYPE_ID > GetMatchingClasses(PROPERTY_BASE *aProperty)
std::map< TYPE_ID, std::vector< PROPERTY_LISTENER > > m_listeners
void OverrideAvailability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override availability functor for a base class property of a given derived class.
bool IsOfType(TYPE_ID aDerived, TYPE_ID aBase) const
Return true if aDerived is inherited from aBase.
PROPERTY_BASE & ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew, const wxString &aGroup=wxEmptyString)
Replace an existing property for a specific type.
void RegisterListener(TYPE_ID aType, PROPERTY_LISTENER aListenerFunc)
Registers a listener for the given type.
void OverrideWriteability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override writeability functor for a base class property of a given derived class.
std::unordered_map< TYPE_ID, wxString > m_classNames
Map of all available types.
const std::vector< wxString > & GetGroupDisplayOrder(TYPE_ID aType) const
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
PROPERTY_MAP< std::function< bool(INSPECTABLE *)> > PROPERTY_FUNCTOR_MAP
std::function< void(INSPECTABLE *, PROPERTY_BASE *, COMMIT *)> PROPERTY_LISTENER
std::vector< PROPERTY_BASE * > PROPERTY_LIST
std::map< std::pair< size_t, wxString >, ValueType > PROPERTY_MAP
std::map< PROPERTY_BASE *, int > PROPERTY_DISPLAY_ORDER
std::set< std::pair< size_t, wxString > > PROPERTY_SET
size_t TYPE_ID
Unique type identifier.
Returns metadata for a specific type.
std::vector< std::reference_wrapper< CLASS_DESC > > m_bases
Properties unique to this type (i.e. not inherited)
PROPERTY_SET m_replaced
Recreates the list of properties.
PROPERTY_SET m_maskedBaseProperties
Overrides for base class property availabilities.
std::vector< wxString > m_groupDisplayOrder
Non-owning list of classes's direct properties in display order.
std::map< wxString, std::unique_ptr< PROPERTY_BASE > > m_ownProperties
Type converters available for this type.
std::vector< PROPERTY_BASE * > m_ownDisplayOrder
The property groups provided by this class.
CLASS_DESC(TYPE_ID aId)
Unique type identifier (obtained using TYPE_HASH)
std::vector< PROPERTY_BASE * > m_allProperties
Compiled display order for all properties.
PROPERTY_DISPLAY_ORDER m_displayOrder
List of property groups provided by this class in display order.
PROPERTY_FUNCTOR_MAP m_writeabilityOverrides
All properties (both unique to the type and inherited)
std::map< TYPE_ID, std::unique_ptr< TYPE_CAST_BASE > > m_typeCasts
Properties from bases that should be masked (hidden) on this subclass.
void rebuild()
Traverses the class inheritance hierarchy bottom-to-top, gathering all properties available to a type...
void collectPropsRecur(PROPERTY_LIST &aResult, PROPERTY_SET &aReplaced, PROPERTY_DISPLAY_ORDER &aDisplayOrder, PROPERTY_SET &aMasked) const
PROPERTY_FUNCTOR_MAP m_availabilityOverrides
Overrides for base class property writeable status.
const TYPE_ID m_id
Types after which this type inherits.
std::set< wxString > m_groups
Replaced properties (TYPE_ID / name)
std::vector< PROPERTY_BASE * > properties