};
-typedef Callback1<const char*> KeyObserver;
-
/// \brief A key/value pair of strings.
///
/// - Notifies observers when value changes - value changes to "" on destruction.
/// - Provides undo support through the global undo system.
-class KeyValue
+class KeyValue : public EntityKeyValue
{
typedef UnsortedSet<KeyObserver> KeyObservers;
public:
typedef KeyValue Value;
- class Observer
- {
- public:
- virtual void insert(const char* key, Value& value) = 0;
- virtual void erase(const char* key, Value& value) = 0;
- };
-
static StringPool& getPool()
{
return Static<StringPool, KeyContext>::instance();
}
~EntityKeyValues()
{
+ for(Observers::iterator i = m_observers.begin(); i != m_observers.end();)
+ {
+ // post-increment to allow current element to be removed safely
+ (*i++)->clear();
+ }
ASSERT_MESSAGE(m_observers.empty(), "EntityKeyValues::~EntityKeyValues: observers still attached");
}