cmObject.h 1.4 KB

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