]> icculus.org git repositories - duncan/yast2-ruby-bindings.git/blob - src/ruby/Y2CCRuby.h
- Lot of fixes and support for the UI!!!
[duncan/yast2-ruby-bindings.git] / src / ruby / Y2CCRuby.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                                                                      |
10 | ruby language support                              (C) Novell Inc.   |
11 \----------------------------------------------------------------------/
12
13 Author: Duncan Mac-Vicar <dmacvicar@suse.de>
14
15 This program is free software; you can redistribute it and/or
16 modify it under the terms of the GNU General Public License
17 as published by the Free Software Foundation; either version
18 2 of the License, or (at your option) any later version.
19
20 */
21
22 #ifndef _Y2CCRuby_h
23 #define _Y2CCRuby_h
24
25 #include "Y2RubyComponent.h"
26
27 /**
28  * @short Y2ComponentCreator that creates Ruby-from-YCP bindings.
29  *
30  * A Y2ComponentCreator is an object that can create components.
31  * It receives a component name and - if it knows how to create
32  * such a component - returns a newly created component of this
33  * type. Y2CCRuby can create components with the name "Ruby".
34  */
35 class Y2CCRuby : public Y2ComponentCreator
36 {
37 private:
38     Y2Component *cruby;
39
40 public:
41     /**
42      * Creates a Ruby component creator
43      */
44     Y2CCRuby() : Y2ComponentCreator( Y2ComponentBroker::BUILTIN ),
45         cruby (0) {};
46
47     ~Y2CCRuby () {
48         if (cruby)
49             delete cruby;
50     }
51
52     /**
53      * Returns true, since the Ruby component is a YaST2 server.
54      */
55     bool isServerCreator() const { return true; };
56
57     /**
58      * Creates a new Ruby component.
59      */
60     Y2Component *create( const char * name ) const
61     {
62         // create as many as requested, they all share the static YRuby anyway
63         if ( ! strcmp( name, "ruby") ) return new Y2RubyComponent();
64         else return 0;
65     }
66
67     /**
68      * always returns the same component, deletes it finally
69      */
70     Y2Component *provideNamespace (const char *name);
71
72 };
73
74 #endif  // ifndef _Y2CCRuby_h
75
76
77 // EOF