sampleClass.h 3.2 KB

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