usb: getting string descriptors, minor improvements
[quarnos.git] / manes / cds / type.h
blob8dce9b782888a7e5f77c05616bed2ee49e7103bc
1 /* Quarn OS / Manes
3 * Type class
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.
23 #ifndef _TYPE_H_
24 #define _TYPE_H_
26 #include "libs/pointer.h"
27 #include "libs/delegate.h"
29 #include "component.h"
31 namespace manes {
32 namespace cds {
34 /**
35 * @brief Type class
36 * @details This class describes type of components. It provides
37 * inheritance information as well as possibility to create a new
38 * instance. As long as types are just special kind of components
39 * client code can inherit from them and introduce new functionality.
40 * @see driver
42 class type : public component {
43 protected:
44 const component_name base;
46 const delegate<p<component> > create_impl;
48 public:
50 type(const component_name&, const component_name&, delegate<p<component> >);
52 component_name get_base() const;
54 /**
55 * @brief Tell if type1 is-a type2.
56 * @details This function checks if this type is or inherits
57 * from type given in argument.
58 * @param x type to compare with
59 * @return true if cast would be successful
61 bool is(const component_name &x) const;
63 /**
64 * @brief Create new instance of the type.
65 * @details This method creates new instance of the type described
66 * by this class. It mainly uses create_impl delegate.
67 * @param parent component that wants to create new object
68 * @return pointer to newly created instance
70 p<component> create_component();
72 bool operator==(const type&) const;
73 bool operator!=(const type&) const;
78 #endif