2
0

sampleClass.h 2.7 KB

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