3 * Managed Execution Controller
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 "cds/component.h"
28 #include "libs/pointer.h"
29 #include "arch/low/irq.h"
30 #include "arch/low/general.h"
47 /* Managed Execution Controller */
48 class manec
: public cds::component
{
51 p
<cds::factory
> types
;
53 p
<services::kernel_state
> kstate
;
58 static p
<cds::component
> comp
;
59 static p
<manec
> instance
;
63 virtual p
<cds::component
> get_component(const cds::component_name
&name
);
64 virtual p
<cds::component
> get_component(const string cname
);
67 * @brief Get component specified by path.
69 * @details This method parses given path and then uses multiple invocations
70 * of get_component method to get specified component. This is the syntax
73 * /type,id/type,id/type,id
75 * @param path Path to the requested component.
76 * @return Requested component.
78 virtual p
<cds::component
> get_by_path(const string
&path
);
81 * @brief Get certain interface of the specific component.
83 * @details This is a part of simplified interface of Manes manager.
84 * It gets specified component using method get_by_path, then narrows
85 * it to the needed interface T.
86 * @param path Path to the requested component.
87 * @return Requested interface of the component.
90 p
<T
> get(const string
&path
);
92 virtual void register_type(const string
&, const string
&, delegate
<p
<cds::component
> >);
93 virtual void register_driver(const string
&, const string
&, delegate
<p
<cds::component
> >, delegate
<bool, p
<resources::did
> >);
96 * @brief Register new type in Manes.
98 * @details When given a pointer to a completely initialized type this function
99 * inserts that type into internal Manes database, so that it is available
100 * for all clients and operations on components of that type are possible.
101 * @param newtype Pointer to newly created type.
103 virtual void register_type(p
<cds::type
> newtype
);
106 * @brief Get type from Manes.
108 * @details This method looks for requested type in internal Manes database.
109 * An error will occur if type wasn't previously registered.
110 * @param name Name of the requested type.
111 * @return Requested type.
113 virtual p
<cds::type
> get_type(const cds::component_name
&name
);
115 virtual p
<cds::type
> get_driver(p
<resources::did
>);
117 virtual arch::irq_op
*get_low();
120 virtual void connect_manes(p
<cds::root
> root_mgr
);
121 static void connect_manes();
123 static p
<manec
> get();
125 virtual p
<cds::root
> get_root();
126 virtual p
<cds::factory
> get_factory();
128 virtual p
<services::kernel_state
> state();
130 virtual p
<error
> err_msg(const string
&x
);
132 inline bool far_calls() {
137 void register_type(const string
&, const string
&);
140 void register_driver(const string
&, const string
&, delegate
<bool, p
<resources::did
> >);
142 virtual void register_abstract(const string
&, const string
&);
145 template<typename T
, typename U
>
146 p
<T
> create_object() {
151 void manec::register_type(const string
&me
, const string
&parent
) {
152 register_type(me
, parent
, delegate
<p
<cds::component
> >::function(create_object
<cds::component
, T
>));
156 void manec::register_driver(const string
&me
, const string
&parent
, delegate
<bool, p
<resources::did
> > check
) {
157 register_driver(me
, parent
, delegate
<p
<cds::component
> >::function(create_object
<cds::component
, T
>), check
);
161 p
<T
> manec::get(const string
&path
) {
162 return get_by_path(path
).cast
<T
>();