glooxd  0.3-svn
componentbase.h
1 /*
2  Copyright (c) 2008-2009 by Jakob Schroeter <js@camaya.net>
3  This file is part of the glooxd library. http://camaya.net/glooxd
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef COMPONENTBASE_H__
15 #define COMPONENTBASE_H__
16 
17 #include "confighandler.h"
18 #include "configmanager.h"
19 #include "macros.h"
20 #include "taghandler.h"
21 #include "router.h"
22 
23 #include <gloox/jid.h>
24 #include <gloox/tag.h>
25 
26 #include <string>
27 
28 namespace gloox
29 {
30  class LogSink;
31 }
32 
33 namespace glooxd
34 {
35 
36  class Router;
37 
44  class GLOOXD_API ComponentBase : public TagHandler, public ConfigHandler
45  {
46  public:
54  ComponentBase( Router& _router, ConfigManager& cm, const gloox::JID& _name,
55  const gloox::LogSink& _logInstance )
56  : m_name( _name ), m_router( _router ), m_cm( cm ), m_logInstance( _logInstance )
57  {
58  m_router.registerDomain( this, m_name.full(), false );
59  m_cm.registerConfigHandler( this );
60  }
61 
65  virtual ~ComponentBase() {}
66 
71  const gloox::JID& name() const { return m_name; }
72 
73  // reimplemented from TagHandler
74  virtual void handleIncomingTag( gloox::Tag* tag ) = 0;
75 
76  // reimplemented from TagHandler
77  virtual void handleOutgoingTag( gloox::Tag* tag ) = 0;
78 
79  protected:
81  gloox::JID m_name;
87  const gloox::LogSink& m_logInstance;
88 
89  private:
90  ComponentBase( const ComponentBase& );
91 
92  };
93 
94 }
95 
96 #endif // COMPONENTBASE_H__