Fawkes API  Fawkes Development Version
rrd_inifin.cpp
1 
2 /***************************************************************************
3  * rrd_inifin.cpp - Fawkes RRDAspect initializer/finalizer
4  *
5  * Created: Mon Dec 06 22:33:03 2010
6  * Copyright 2006-2010 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <plugins/rrd/aspect/rrd_inifin.h>
25 #include <plugins/rrd/aspect/rrd.h>
26 #include <plugins/rrd/aspect/rrd_manager.h>
27 #include <core/threading/thread_finalizer.h>
28 
29 namespace fawkes {
30 #if 0 /* just to make Emacs auto-indent happy */
31 }
32 #endif
33 
34 /** @class RRDAspectIniFin <plugins/rrd/aspect/rrd_inifin.h>
35  * RRDAspect initializer/finalizer.
36  * This initializer/finalizer will provide the RRDManager to threads with
37  * the RRDAspect.
38  * @author Tim Niemueller
39  */
40 
41 /** Constructor.
42  * @param rrd_manager RRD manager to pass on to threads
43  */
45  : AspectIniFin("RRDAspect")
46 {
47  __rrd_manager = rrd_manager;
48 }
49 
50 void
52 {
53  RRDAspect *rrd_thread;
54  rrd_thread = dynamic_cast<RRDAspect *>(thread);
55  if (rrd_thread == NULL) {
56  throw CannotInitializeThreadException("Thread '%s' claims to have the "
57  "RRDAspect, but RTTI says it "
58  "has not. ", thread->name());
59  }
60 
61  rrd_thread->init_RRDAspect(__rrd_manager);
62 }
63 
64 void
66 {
67 }
68 
69 
70 
71 } // end namespace fawkes
RRDAspectIniFin(RRDManager *rrd_manager)
Constructor.
Definition: rrd_inifin.cpp:44
Interface for a RRD connection creator.
Definition: rrd_manager.h:40
Fawkes library namespace.
virtual void finalize(Thread *thread)
Finalize thread.
Definition: rrd_inifin.cpp:65
Thread class encapsulation of pthreads.
Definition: thread.h:42
Thread cannot be initialized.
Thread aspect create, update, and graph round-robin databases (RRD).
Definition: rrd.h:36
const char * name() const
Get name of thread.
Definition: thread.h:95
virtual void init(Thread *thread)
Initialize thread.
Definition: rrd_inifin.cpp:51
Aspect initializer/finalizer base class.
Definition: inifin.h:36