Panda3D
sampleClass.h
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 
15 #ifndef SAMPLECLASS_H
16 #define SAMPLECLASS_H
17 
18 // This file shows some sample code that illustrates our general
19 // naming and style conventions for Panda coding. Note that there is
20 // generally one .h file per class, with the .h file named after the
21 // class but the first letter lowercase.
22 
23 #include "pandabase.h"
24 
25 #include "localHeaderFile.h"
26 #include "anotherLocalHeaderFile.h"
27 
28 #include "typedObject.h"
29 #include "anotherPandaHeaderFile.h"
30 
31 #include <systemHeaderFile.h>
32 
33 ////////////////////////////////////////////////////////////////////
34 // Class : SampleClass
35 // Description : A basic description of the function and purpose of
36 // SampleClass. Note that class names are generally
37 // mixed case, no underscore, beginning with a capital
38 // letter.
39 ////////////////////////////////////////////////////////////////////
40 class EXPCL_PANDA SampleClass : public TypedObject {
41 public:
42  enum NestedEnum {
43  NE_case_one,
44  NE_case_two,
45  };
46 
47  class EXPCL_PANDA NestedClass {
48  public:
49  int _data_member;
50  };
51 
52  SampleClass();
53  INLINE SampleClass(const SampleClass &copy);
54  INLINE ~SampleClass();
55 
56  // Note that inline function bodies are generally not given here in
57  // the .h file--they're defined in the associated .I file.
58 
59  // Method names are generally lower case, with underscores
60  // separating words. Accessors are generally of the form set_*()
61  // and get_*(). Respect the const convention for methods which
62  // should be const.
63 
64  INLINE void set_flag(int flag);
65  INLINE int get_flag() const;
66 
67  int public_method();
68 
69 protected:
70  bool protected_method();
71 
72 private:
73  void private_method();
74 
75 
76 public:
77  // Data members, whether private or public, are generally lower
78  // case, with underscores separating words, and beginning with a
79  // leading underscore.
80 
81  bool _public_data_member;
82 
83 private:
84 
85  NestedEnumType _private_data_member;
86  int _flag;
87 
88 
89  // The TypeHandle stuff, below, need be present only for classes
90  // that inherit from TypedObject. Classes that do not inherit from
91  // TypedObject may optionally define just the non-virtual methods
92  // below: get_class_type(), init_type().
93 public:
94  static TypeHandle get_class_type() {
95  return _type_handle;
96  }
97  static void init_type() {
99  register_type(_type_handle, "SampleClass",
100  TypedObject::get_class_type());
101  }
102  virtual TypeHandle get_type() const {
103  return get_class_type();
104  }
105  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
106 
107 private:
108  static TypeHandle _type_handle;
109 };
110 
111 #include "sampleClass.I"
112 
113 #endif
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Definition: typedObject.cxx:52
A basic description of the function and purpose of SampleClass.
Definition: sampleClass.h:40
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:98
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85