summaryrefslogtreecommitdiff
path: root/objects/objdelete_controller.hh
blob: eccee06069e2e4309a67ce608797ce01629b0996 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef __OBJECTS_OBJDELETE_CONTROLLER_HH__
#define __OBJECTS_OBJDELETE_CONTROLLER_HH__

#include "objects_parser.hh"
#include "common/tools.hh"

namespace rtfl {

namespace objects {

/**
 * \brief Processes `obj-delete` specially and maps ids of deleted objects to
 *    new ones, if they are reused.
 */
class ObjDeleteController: public ObjectsControllerBase
{
private:
   class ObjInfo: public lout::object::Object
   {
   private:
      int numCreated, numDeleted;
      char *origId, *mappedId;

   public:
      ObjInfo (const char *id);
      ~ObjInfo ();

      void use ();
      void objCreate ();
      void objDelete ();

      inline const char *getMappedId () { return mappedId; }
   };
   
   ObjectsController *successor;
   lout::container::typed::HashTable<lout::object::String, ObjInfo> *objInfos;

   const char *mapId (const char *id);
   bool objInfoCreated (const char *id);
   ObjInfo *getObjInfo (const char *id);
   ObjInfo *ensureObjInfo (const char *id);

public:   
   ObjDeleteController (ObjectsController *successor);
   ~ObjDeleteController ();

   void objMsg (tools::CommonLineInfo *info, const char *id,
                const char *aspect, int prio, const char *message);
   void objMark (tools::CommonLineInfo *info, const char *id,
                 const char *aspect, int prio, const char *message);
   void objMsgStart (tools::CommonLineInfo *info, const char *id);
   void objMsgEnd (tools::CommonLineInfo *info, const char *id);
   void objEnter (tools::CommonLineInfo *info, const char *id,
                  const char *aspect, int prio, const char *funname,
                  const char *args);
   void objLeave (tools::CommonLineInfo *info, const char *id,
                  const char *vals);
   void objCreate (tools::CommonLineInfo *info, const char *id,
                   const char *klass);
   void objIdent (tools::CommonLineInfo *info, const char *id1,
                  const char *id2);
   void objNoIdent (tools::CommonLineInfo *info);
   void objAssoc (tools::CommonLineInfo *info, const char *parent,
                  const char *child);
   void objSet (tools::CommonLineInfo *info, const char *id, const char *var,
                const char *val);
   void objClassColor (tools::CommonLineInfo *info, const char *klass,
                       const char *color);
   void objObjectColor (tools::CommonLineInfo *info, const char *id,
                        const char *color);
   void objDelete (tools::CommonLineInfo *info, const char *id);
};

} // namespace objects

} // namespace rtfl

#endif // __OBJECTS_OBJDELETE_CONTROLLER_HH__