OpenWalnut  1.5.0dev
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 <memory>
29 #include <string>
30 
31 
32 
33 
34 /**
35  * Interface class for the concept "Prototype". The requirements are a zero-parameter constructor.
36  */
37 class WPrototyped // NOLINT
38 {
39 public:
40  /**
41  * Default constructor. Creates a instance of the class. This not necessarily mean that the instance is fully usable. This is
42  * required for type checking and inheritance checking.
43  */
44  WPrototyped();
45 
46  /**
47  * Destructor.
48  */
49  virtual ~WPrototyped();
50 
51  /**
52  * Gets the name of this prototype. Not allowed line-breaks, ":", "/", "\".
53  *
54  * \return the name.
55  */
56  virtual const std::string getName() const = 0;
57 
58  /**
59  * Gets the description for this prototype.
60  *
61  * \return the description
62  */
63  virtual const std::string getDescription() const = 0;
64 
65  /**
66  * Checks whether the actual prototype has the specified runtime type.
67  *
68  * \return true if you can safely cast this instance to the specified type.
69  */
70  template < typename T > bool isA();
71 
72 protected:
73 private:
74 };
75 
76 template < typename T >
78 {
79  return dynamic_cast< T* >( this );
80 }
81 
82 #endif // WPROTOTYPED_H
83 
Interface class for the concept "Prototype".
Definition: WPrototyped.h:38
virtual ~WPrototyped()
Destructor.
Definition: WPrototyped.cpp:34
bool isA()
Checks whether the actual prototype has the specified runtime type.
Definition: WPrototyped.h:77
WPrototyped()
Default constructor.
Definition: WPrototyped.cpp:29
virtual const std::string getName() const =0
Gets the name of this prototype.
virtual const std::string getDescription() const =0
Gets the description for this prototype.