Imported Upstream version 2.8.12.2
[platform/upstream/cmake.git] / Source / cmObject.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifndef cmObject_h
13 #define cmObject_h
14
15 #include "cmStandardIncludes.h"
16
17 /** \class cmObject
18  * \brief Superclass for all commands and other classes in CMake.
19  *
20  * cmObject is the base class for all classes in CMake. It defines some
21  * methods such as GetNameOfClass, IsA, SafeDownCast.
22  */
23 class cmObject
24 {
25 public:
26   /**
27    * Need virtual destructor to destroy real command type.
28    */
29   virtual ~cmObject() {}
30
31   /**
32    * The class name of the command.
33    */
34   virtual const char* GetNameOfClass() = 0;
35
36   /**
37    * Returns true if this class is the given class, or a subclass of it.
38    */
39   static bool IsTypeOf(const char *type)
40     { return !strcmp("cmObject", type); }
41
42   /**
43    * Returns true if this object is an instance of the given class or
44    * a subclass of it.
45    */
46   virtual bool IsA(const char *type)
47     { return cmObject::IsTypeOf(type); }
48 };
49
50 #endif
51