43ae95449cdd2a640168eadb0955e96201a2a544
[senf.git] / Utils / Logger / Target.hh
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief Target public header */
25
26 #ifndef HH_Target_
27 #define HH_Target_ 1
28
29 // Custom includes
30 #include "../singleton.hh"
31 #include "Stream.hh"
32 #include "Area.hh"
33
34 //#include "Target.mpp"
35 ///////////////////////////////hh.p////////////////////////////////////////
36
37 namespace senf {
38 namespace log {
39
40     /** \brief
41       */
42     class Target
43         : public senf::singleton<Target>
44     {
45     public:
46         ///////////////////////////////////////////////////////////////////////////
47         // Types
48
49         ///////////////////////////////////////////////////////////////////////////
50         ///\name Structors and default members
51         ///@{
52
53         virtual ~Target();
54
55         // default default constructor
56         // default copy constructor
57         // default copy assignment
58         // default destructor
59
60         // no conversion constructors
61
62         ///@}
63
64     protected:
65
66     private:
67
68         void route(detail::StreamBase const * stream, detail::AreaBase const * area, 
69                    unsigned level);
70         void unroute(detail::StreamBase const * stream, detail::AreaBase const * area, 
71                      unsigned level);
72
73         void updateAreaCache(detail::AreaBase const & area, detail::StreamBase const * stream,
74                              unsigned level);
75
76         void write(detail::StreamBase const & stream, detail::AreaBase const & area, 
77                    unsigned level, std::string const & message);
78         
79         virtual void v_write(std::string const & stream, std::string const & area, unsigned level,
80                              std::string const & message) = 0;
81
82         struct RoutingEntry 
83         {
84             RoutingEntry(detail::StreamBase const * stream_, detail::AreaBase const * area_, 
85                          unsigned level_)
86                 : stream(stream_), area(area_), level(level_) {}
87             RoutingEntry() 
88                 : stream(0), area(0), level(0) {}
89
90             bool operator==(RoutingEntry const & other) 
91                 { return stream == other.stream && area == other.area && level == other.level; }
92
93             detail::StreamBase const * stream;
94             detail::AreaBase const * area;
95             unsigned level;
96         };
97
98         typedef std::vector<RoutingEntry> RIB;
99
100         RIB rib_;
101     };
102
103 }}
104
105 ///////////////////////////////hh.e////////////////////////////////////////
106 #include "Target.cci"
107 //#include "Target.ct"
108 //#include "Target.cti"
109 #endif
110
111 \f
112 // Local Variables:
113 // mode: c++
114 // fill-column: 100
115 // comment-column: 40
116 // c-file-style: "senf"
117 // indent-tabs-mode: nil
118 // ispell-local-dictionary: "american"
119 // compile-command: "scons -u test"
120 // End: