Panda3D

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