LCOV - code coverage report
Current view: top level - src - EventRegistry.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 30 51 58.8 %
Date: 2010-12-13 Functions: 7 10 70.0 %
Branches: 21 52 40.4 %

           Branch data     Line data    Source code
       1                 :            : // $Id: EventRegistry.cc 6829 2009-07-09 09:12:59Z vern $
       2                 :            : 
       3                 :            : #include "EventRegistry.h"
       4                 :            : #include "RE.h"
       5                 :            : #include "RemoteSerializer.h"
       6                 :            : 
       7                 :       1066 : void EventRegistry::Register(EventHandlerPtr handler)
       8                 :            :         {
       9                 :       1066 :         HashKey key(handler->Name());
      10                 :       1066 :         handlers.Insert(&key, handler.Ptr());
      11                 :       1066 :         }
      12                 :            : 
      13                 :      20767 : EventHandler* EventRegistry::Lookup(const char* name)
      14                 :            :         {
      15                 :      20767 :         HashKey key(name);
      16                 :      20767 :         return handlers.Lookup(&key);
      17                 :            :         }
      18                 :            : 
      19                 :          0 : EventRegistry::string_list* EventRegistry::Match(RE_Matcher* pattern)
      20                 :            :         {
      21                 :          0 :         string_list* names = new string_list;
      22                 :            : 
      23                 :          0 :         IterCookie* c = handlers.InitForIteration();
      24                 :            : 
      25                 :            :         HashKey* k;
      26                 :            :         EventHandler* v;
      27         [ #  # ]:          0 :         while ( (v = handlers.NextEntry(k, c)) )
      28                 :            :                 {
      29 [ #  # ][ #  # ]:          0 :                 if ( v->LocalHandler() && pattern->MatchExactly(v->Name()) )
                 [ #  # ]
      30                 :          0 :                         names->append(v->Name());
      31                 :            : 
      32         [ #  # ]:          0 :                 delete k;
      33                 :            :                 }
      34                 :            : 
      35                 :          0 :         return names;
      36                 :            :         }
      37                 :            : 
      38                 :          1 : EventRegistry::string_list* EventRegistry::UnusedHandlers()
      39                 :            :         {
      40                 :          1 :         string_list* names = new string_list;
      41                 :            : 
      42                 :          1 :         IterCookie* c = handlers.InitForIteration();
      43                 :            : 
      44                 :            :         HashKey* k;
      45                 :            :         EventHandler* v;
      46         [ +  + ]:        341 :         while ( (v = handlers.NextEntry(k, c)) )
      47                 :            :                 {
      48 [ +  + ][ +  + ]:        340 :                 if ( v->LocalHandler() && ! v->Used() )
                 [ +  + ]
      49                 :          1 :                         names->append(v->Name());
      50                 :            : 
      51         [ +  - ]:        340 :                 delete k;
      52                 :            :                 }
      53                 :            : 
      54                 :          1 :         return names;
      55                 :            :         }
      56                 :            : 
      57                 :          1 : EventRegistry::string_list* EventRegistry::UsedHandlers()
      58                 :            :         {
      59                 :          1 :         string_list* names = new string_list;
      60                 :            : 
      61                 :          1 :         IterCookie* c = handlers.InitForIteration();
      62                 :            : 
      63                 :            :         HashKey* k;
      64                 :            :         EventHandler* v;
      65         [ +  + ]:        341 :         while ( (v = handlers.NextEntry(k, c)) )
      66                 :            :                 {
      67 [ +  + ][ +  + ]:        340 :                 if ( v->LocalHandler() && v->Used() )
                 [ +  + ]
      68                 :         69 :                         names->append(v->Name());
      69                 :            : 
      70         [ +  - ]:        340 :                 delete k;
      71                 :            :                 }
      72                 :            : 
      73                 :          1 :         return names;
      74                 :            :         }
      75                 :            : 
      76                 :          0 : void EventRegistry::PrintDebug()
      77                 :            :         {
      78                 :          0 :         IterCookie* c = handlers.InitForIteration();
      79                 :            : 
      80                 :            :         HashKey* k;
      81                 :            :         EventHandler* v;
      82         [ #  # ]:          0 :         while ( (v = handlers.NextEntry(k, c)) )
      83                 :            :                 {
      84         [ #  # ]:          0 :                 delete k;
      85                 :            :                 fprintf(stderr, "Registered event %s (%s handler)\n", v->Name(),
      86         [ #  # ]:          0 :                                 v->LocalHandler()? "local" : "no");
      87                 :            :                 }
      88                 :          0 :         }
      89                 :            : 
      90                 :        216 : void EventRegistry::SetGroup(const char* name, const char* group)
      91                 :            :         {
      92                 :        216 :         EventHandler* eh = Lookup(name);
      93         [ -  + ]:        216 :         if ( ! eh )
      94                 :          0 :                 internal_error("unknown event handler in SetGroup()");
      95                 :            : 
      96                 :        216 :         eh->SetGroup(group);
      97                 :        216 :         }
      98                 :            : 
      99                 :          0 : void EventRegistry::EnableGroup(const char* group, bool enable)
     100                 :            :         {
     101                 :          0 :         IterCookie* c = handlers.InitForIteration();
     102                 :            : 
     103                 :            :         HashKey* k;
     104                 :            :         EventHandler* v;
     105         [ #  # ]:          0 :         while ( (v = handlers.NextEntry(k, c)) )
     106                 :            :                 {
     107         [ #  # ]:          0 :                 delete k;
     108                 :            : 
     109 [ #  # ][ #  # ]:          0 :                 if ( v->Group() && strcmp(v->Group(), group) == 0 )
                 [ #  # ]
     110                 :          0 :                         v->SetEnable(enable);
     111                 :            :                 }
     112 [ +  - ][ +  - ]:          6 :         }
     113                 :          3 : 

Generated by: LCOV version 1.8