5 * Copyright (C) 2008-2009 Pawel Dziepak
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "component.h"
27 #include "component_name.h"
29 #include "libs/pointer.h"
30 #include "libs/list.h"
35 * @brief Components creator.
36 * @details This is an abstract base class for all component creators.
37 * It stores list of created components and provides interface needed
40 class creator
: public component
{
43 * @brief List of components stored by creator.
45 list
<p
<component
> > components
;
49 creator(p
<type
> tpe
) : component(tpe
) {}
52 * @brief Performs creator initialization.
53 * @details This method is called once creator is construced and
54 * ready to work since Manes does not allow some things to be
55 * performed in constructors.
56 * @return information if initialization was successful
58 virtual bool initialize();
61 * @brief New type was registered in the system.
62 * @details This method is called each time new type is registered,
63 * what allows creator to perform any actions that such event
64 * may require. It is commonly used by bus classes that support
65 * lazy drivers loading.
66 * @param newtype name of recently registered type
67 * @return ignored value
69 virtual bool type_added(const component_name
&newtype
);
72 * @brief Create new component.
73 * @details Create new component of specified type. Instances of
74 * class type provides interface that allow to create an object
75 * of specific type. To get type from type_name manager is used.
76 * Notice that some subclasses may make more restricted or
77 * completely impossible creation of new components.
78 * @param name type of requested component
79 * @return created component
81 virtual p
<component
> new_component(const component_name
&name
);
83 virtual p
<component
> add_existing(p
<component
>);
86 * @brief Returns number of components stored in this creator.
87 * @return components count
89 virtual int count() const;
92 * @todo Implement this method.
94 virtual void delete_component(const component_name
&);
97 * @brief Get an exsiting component.
98 * @details Search in components list for a specifed component.
99 * In most cases this function should not be invoced directly, but
100 * client should use manager's method manager::get_component.
101 * @param name name of the requested component
102 * @return requested component
104 virtual p
<component
> get_component(const component_name
&name
);