OpenWalnut  1.4.0
WPrototyped.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WPROTOTYPED_H
26 #define WPROTOTYPED_H
27 
28 #include <string>
29 
30 #ifndef Q_MOC_RUN
31 #include <boost/shared_ptr.hpp>
32 #endif
33 
34 
35 
36 /**
37  * Interface class for the concept "Prototype". The requirements are a zero-parameter constructor.
38  */
39 class WPrototyped // NOLINT
40 {
41 public:
42  /**
43  * Default constructor. Creates a instance of the class. This not necessarily mean that the instance is fully usable. This is
44  * required for type checking and inheritance checking.
45  */
46  WPrototyped();
47 
48  /**
49  * Destructor.
50  */
51  virtual ~WPrototyped();
52 
53  /**
54  * Gets the name of this prototype.
55  *
56  * \return the name.
57  */
58  virtual const std::string getName() const = 0;
59 
60  /**
61  * Gets the description for this prototype.
62  *
63  * \return the description
64  */
65  virtual const std::string getDescription() const = 0;
66 
67  /**
68  * Checks whether the actual prototype has the specified runtime type.
69  *
70  * \return true if you can safely cast this instance to the specified type.
71  */
72  template < typename T > bool isA();
73 
74 protected:
75 private:
76 };
77 
78 template < typename T >
80 {
81  return dynamic_cast< T* >( this );
82 }
83 
84 #endif // WPROTOTYPED_H
85 
virtual const std::string getName() const =0
Gets the name of this prototype.
bool isA()
Checks whether the actual prototype has the specified runtime type.
Definition: WPrototyped.h:79
Interface class for the concept "Prototype".
Definition: WPrototyped.h:39
virtual ~WPrototyped()
Destructor.
Definition: WPrototyped.cpp:34
virtual const std::string getDescription() const =0
Gets the description for this prototype.
WPrototyped()
Default constructor.
Definition: WPrototyped.cpp:29