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