| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "ientity.h" |
| 4 |
|
| 5 |
#include "SREntity.h" |
| 6 |
#include "StimTypes.h" |
| 7 |
|
| 8 |
/** greebo: This visitor removes all the Stim/Response-related |
| 9 |
* spawnargs from the visited entity. |
| 10 |
* |
| 11 |
* It first visits all the keyvalues, and adds the |
| 12 |
* matching items to an internal list. Upon destruction, |
| 13 |
* the list is traversed and the keys are deleted. |
| 14 |
* (in-loop deletion will crash the app as the iterators |
| 15 |
* get invalidated by the deletion...) |
| 16 |
* |
| 17 |
* Use this before saving the new values to the entity. |
| 18 |
*/ |
| 19 |
class SRPropertyRemover |
| 20 |
{ |
| 21 |
// The entity to be cleaned |
| 22 |
Entity* _target; |
| 23 |
|
| 24 |
// The reference to the list of possible key names |
| 25 |
SREntity::KeyList& _keys; |
| 26 |
|
| 27 |
typedef std::vector<std::string> KeyList; |
| 28 |
// The list of keys that have to be removed after the walk |
| 29 |
KeyList _removeList; |
| 30 |
|
| 31 |
// Local helper class containing all the stimtypes |
| 32 |
StimTypes _stimTypes; |
| 33 |
|
| 34 |
public: |
| 35 |
// Constructor |
| 36 |
SRPropertyRemover(Entity* target, SREntity::KeyList& keys); |
| 37 |
|
| 38 |
// Destructor, this is where the values are destroyed. |
| 39 |
~SRPropertyRemover(); |
| 40 |
|
| 41 |
// Visitor function |
| 42 |
void visitKeyValue(const std::string& key, const std::string& value); |
| 43 |
}; |