Fawkes API  Fawkes Development Version
aspect_provider.cpp
1 
2 /***************************************************************************
3  * aspect_provider.h - Aspect to provider a new aspect for Fawkes
4  *
5  * Created: Thu Nov 25 12:08:21 2010 (Thanksgiving)
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 <aspect/aspect_provider.h>
25 
26 namespace fawkes {
27 #if 0 /* just to make Emacs auto-indent happy */
28 }
29 #endif
30 
31 /** @class AspectProviderAspect <aspect/aspect_provider.h>
32  * Thread aspect provide a new aspect.
33  * Aspects in Fawkes are used to provide access to framework features.
34  * More generally speaking they are used to provide access to features on the
35  * C++ programming level. In some situations, it might be useful to provide
36  * a custom aspect to allow for access to a resource on this level, e.g.
37  * bypassing the blackboard for communication. In this case the
38  * AspectProviderAspect can be used.
39  *
40  * Use this rarely! Be absolutely certain, that there is no better or equally
41  * good way to implement a feature without a new aspect. If used it allows
42  * for a well-defined way to exchange resources between threads (and even
43  * plugins). Make sure that you define strong guarantees and keep them by
44  * means of your aspect initializer/finalizer. For example if you share a
45  * (pointer to a) resource, you <i>must</i> make sure, that this
46  * resource stays as long as there is any user!
47  *
48  * @ingroup Aspects
49  * @author Tim Niemueller
50  */
51 
52 /** Constructor.
53  * This special constructor is needed to define the wakeup point.
54  * @param aspect_name Name of the aspect which is provided. The string
55  * must exist for the whole lifetime of this AspectProviderAspect instance!
56  * @param inifin intializer/finalizer for the aspect. The inifin
57  * must exist for the whole lifetime of this AspectProviderAspect instance!
58  */
60  AspectIniFin *inifin)
61 {
62  add_aspect("AspectProviderAspect");
63  __aspect_name = aspect_name;
64  __aspect_inifin = inifin;
65 }
66 
67 
68 /** Virtual empty destructor. */
70 {
71 }
72 
73 
74 /** Get name of the provided aspect.
75  * @return name of the provided aspect
76  */
77 const char *
79 {
80  return __aspect_name;
81 }
82 
83 
84 /** Get initializer/finalizer for the provided aspect.
85  * @return initializer/finalizer for the provided aspect
86  */
89 {
90  return __aspect_inifin;
91 }
92 
93 } // end namespace fawkes
AspectIniFin * aspect_provider_inifin() const
Get initializer/finalizer for the provided aspect.
AspectProviderAspect(const char *aspect_name, AspectIniFin *inifin)
Constructor.
Fawkes library namespace.
const char * aspect_provider_name() const
Get name of the provided aspect.
void add_aspect(const char *name)
Add an aspect to a thread.
Definition: aspect.cpp:52
virtual ~AspectProviderAspect()
Virtual empty destructor.
Aspect initializer/finalizer base class.
Definition: inifin.h:36