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-2013 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 #include <aspect/inifins/inifin.h>
26 
27 namespace fawkes {
28 
29 /** @class AspectProviderAspect <aspect/aspect_provider.h>
30  * Thread aspect provide a new aspect.
31  * Aspects in Fawkes are used to provide access to framework features.
32  * More generally speaking they are used to provide access to features on the
33  * C++ programming level. In some situations, it might be useful to provide
34  * a custom aspect to allow for access to a resource on this level, e.g.
35  * bypassing the blackboard for communication. In this case the
36  * AspectProviderAspect can be used.
37  *
38  * Use this rarely! Be absolutely certain, that there is no better or equally
39  * good way to implement a feature without a new aspect. If used it allows
40  * for a well-defined way to exchange resources between threads (and even
41  * plugins). Make sure that you define strong guarantees and keep them by
42  * means of your aspect initializer/finalizer. For example if you share a
43  * (pointer to a) resource, you <i>must</i> make sure, that this
44  * resource stays as long as there is any user!
45  *
46  * @ingroup Aspects
47  * @author Tim Niemueller
48  */
49 
50 /** Constructor.
51  * Add a single aspect.
52  * @param inifin intializer/finalizer for the aspect. The inifin
53  * must exist for the whole lifetime of this AspectProviderAspect instance!
54  */
56 {
57  add_aspect("AspectProviderAspect");
58  aspect_provider_aspects_.push_back(inifin);
59 }
60 
61 /** Constructor.
62  * Add multiple aspects.
63  * @param aspects Map from aspect name to initializer/finalizer
64  */
65 AspectProviderAspect::AspectProviderAspect(const std::list<AspectIniFin *> aspects)
66 {
67  add_aspect("AspectProviderAspect");
68  aspect_provider_aspects_ = aspects;
69 }
70 
71 /** Virtual empty destructor. */
73 {
74 }
75 
76 /** Get name of the provided aspect.
77  * @return name of the provided aspect
78  */
79 const std::list<AspectIniFin *> &
81 {
82  return aspect_provider_aspects_;
83 }
84 
85 } // end namespace fawkes
Fawkes library namespace.
AspectProviderAspect(AspectIniFin *inifin)
Constructor.
void add_aspect(const char *name)
Add an aspect to a thread.
Definition: aspect.cpp:49
virtual ~AspectProviderAspect()
Virtual empty destructor.
const std::list< AspectIniFin * > & aspect_provider_aspects() const
Get name of the provided aspect.
Aspect initializer/finalizer base class.
Definition: inifin.h:33