Panda3D
|
00001 // Filename: sampleClass.h 00002 // Created by: drose (10Jun00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef SAMPLECLASS_H 00016 #define SAMPLECLASS_H 00017 00018 // This file shows some sample code that illustrates our general 00019 // naming and style conventions for Panda coding. Note that there is 00020 // generally one .h file per class, with the .h file named after the 00021 // class but the first letter lowercase. 00022 00023 #include "pandabase.h" 00024 00025 #include "localHeaderFile.h" 00026 #include "anotherLocalHeaderFile.h" 00027 00028 #include "typedObject.h" 00029 #include "anotherPandaHeaderFile.h" 00030 00031 #include <systemHeaderFile.h> 00032 00033 //////////////////////////////////////////////////////////////////// 00034 // Class : SampleClass 00035 // Description : A basic description of the function and purpose of 00036 // SampleClass. Note that class names are generally 00037 // mixed case, no underscore, beginning with a capital 00038 // letter. 00039 //////////////////////////////////////////////////////////////////// 00040 class EXPCL_PANDA SampleClass : public TypedObject { 00041 public: 00042 enum NestedEnum { 00043 NE_case_one, 00044 NE_case_two, 00045 }; 00046 00047 class EXPCL_PANDA NestedClass { 00048 public: 00049 int _data_member; 00050 }; 00051 00052 SampleClass(); 00053 INLINE SampleClass(const SampleClass ©); 00054 INLINE ~SampleClass(); 00055 00056 // Note that inline function bodies are generally not given here in 00057 // the .h file--they're defined in the associated .I file. 00058 00059 // Method names are generally lower case, with underscores 00060 // separating words. Accessors are generally of the form set_*() 00061 // and get_*(). Respect the const convention for methods which 00062 // should be const. 00063 00064 INLINE void set_flag(int flag); 00065 INLINE int get_flag() const; 00066 00067 int public_method(); 00068 00069 protected: 00070 bool protected_method(); 00071 00072 private: 00073 void private_method(); 00074 00075 00076 public: 00077 // Data members, whether private or public, are generally lower 00078 // case, with underscores separating words, and beginning with a 00079 // leading underscore. 00080 00081 bool _public_data_member; 00082 00083 private: 00084 00085 NestedEnumType _private_data_member; 00086 int _flag; 00087 00088 00089 // The TypeHandle stuff, below, need be present only for classes 00090 // that inherit from TypedObject. Classes that do not inherit from 00091 // TypedObject may optionally define just the non-virtual methods 00092 // below: get_class_type(), init_type(). 00093 public: 00094 static TypeHandle get_class_type() { 00095 return _type_handle; 00096 } 00097 static void init_type() { 00098 TypedObject::init_type(); 00099 register_type(_type_handle, "SampleClass", 00100 TypedObject::get_class_type()); 00101 } 00102 virtual TypeHandle get_type() const { 00103 return get_class_type(); 00104 } 00105 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00106 00107 private: 00108 static TypeHandle _type_handle; 00109 }; 00110 00111 #include "sampleClass.I" 00112 00113 #endif