sampleClass.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Filename: sampleClass.h
  2. // Created by: drose (10Jun00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #ifndef SAMPLECLASS_H
  15. #define SAMPLECLASS_H
  16. // This file shows some sample code that illustrates our general
  17. // naming and style conventions for Panda coding. Note that there is
  18. // generally one .h file per class, with the .h file named after the
  19. // class but the first letter lowercase.
  20. #include "pandabase.h"
  21. #include "localHeaderFile.h"
  22. #include "anotherLocalHeaderFile.h"
  23. #include "typedObject.h"
  24. #include "anotherPandaHeaderFile.h"
  25. #include <systemHeaderFile.h>
  26. ////////////////////////////////////////////////////////////////////
  27. // Class : SampleClass
  28. // Description : A basic description of the function and purpose of
  29. // SampleClass. Note that class names are generally
  30. // mixed case, no underscore, beginning with a capital
  31. // letter.
  32. ////////////////////////////////////////////////////////////////////
  33. class EXPCL_PANDA SampleClass : public TypedObject {
  34. public:
  35. enum NestedEnum {
  36. NE_case_one,
  37. NE_case_two,
  38. };
  39. class EXPCL_PANDA NestedClass {
  40. public:
  41. int _data_member;
  42. };
  43. SampleClass();
  44. INLINE SampleClass(const SampleClass &copy);
  45. INLINE ~SampleClass();
  46. // Note that inline function bodies are generally not given here in
  47. // the .h file--they're defined in the associated .I file.
  48. // Method names are generally lower case, with underscores
  49. // separating words. Accessors are generally of the form set_*()
  50. // and get_*(). Respect the const convention for methods which
  51. // should be const.
  52. INLINE void set_flag(int flag);
  53. INLINE int get_flag() const;
  54. int public_method();
  55. protected:
  56. bool protected_method();
  57. private:
  58. void private_method();
  59. public:
  60. // Data members, whether private or public, are generally lower
  61. // case, with underscores separating words, and beginning with a
  62. // leading underscore.
  63. bool _public_data_member;
  64. private:
  65. NestedEnumType _private_data_member;
  66. int _flag;
  67. // The TypeHandle stuff, below, need be present only for classes
  68. // that inherit from TypedObject. Classes that do not inherit from
  69. // TypedObject may optionally define just the non-virtual methods
  70. // below: get_class_type(), init_type().
  71. public:
  72. static TypeHandle get_class_type() {
  73. return _type_handle;
  74. }
  75. static void init_type() {
  76. TypedObject::init_type();
  77. register_type(_type_handle, "SampleClass",
  78. TypedObject::get_class_type());
  79. }
  80. virtual TypeHandle get_type() const {
  81. return get_class_type();
  82. }
  83. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  84. private:
  85. static TypeHandle _type_handle;
  86. };
  87. #include "sampleClass.I"
  88. #endif