From e8a0cd972d3c92fe16959aa012074ad4e3abad5e Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Fri, 9 Feb 2007 21:46:03 +0000 Subject: [PATCH] Added typed skel --- panda/src/skel/config_skel.cxx | 7 +-- panda/src/skel/skel_composite1.cxx | 1 + panda/src/skel/typedSkel.I | 56 +++++++++++++++++++++++ panda/src/skel/typedSkel.cxx | 45 ++++++++++++++++++ panda/src/skel/typedSkel.h | 73 ++++++++++++++++++++++++++++++ 5 files changed, 179 insertions(+), 3 deletions(-) create mode 100644 panda/src/skel/typedSkel.I create mode 100644 panda/src/skel/typedSkel.cxx create mode 100644 panda/src/skel/typedSkel.h diff --git a/panda/src/skel/config_skel.cxx b/panda/src/skel/config_skel.cxx index 94c14a449d..3e27e914e8 100644 --- a/panda/src/skel/config_skel.cxx +++ b/panda/src/skel/config_skel.cxx @@ -17,6 +17,8 @@ //////////////////////////////////////////////////////////////////// #include "config_skel.h" +#include "basicSkel.h" +#include "typedSkel.h" #include "dconfig.h" Configure(config_skel); @@ -26,7 +28,7 @@ ConfigureFn(config_skel) { init_libskel(); } -ConfigVariableInt skel_number_of_monkeys +ConfigVariableInt skel_sample_config_variable ("skel-sample-config-variable", 3); //////////////////////////////////////////////////////////////////// @@ -45,7 +47,6 @@ init_libskel() { } initialized = true; - // There's no initialization necessary for the skel library. - // But if there were, we would put it here. + TypedSkel::init_type(); } diff --git a/panda/src/skel/skel_composite1.cxx b/panda/src/skel/skel_composite1.cxx index 2e5edf0f77..0494ed0717 100644 --- a/panda/src/skel/skel_composite1.cxx +++ b/panda/src/skel/skel_composite1.cxx @@ -1,2 +1,3 @@ #include "config_skel.cxx" #include "basicSkel.cxx" +#include "typedSkel.cxx" diff --git a/panda/src/skel/typedSkel.I b/panda/src/skel/typedSkel.I new file mode 100644 index 0000000000..00a6a51e2f --- /dev/null +++ b/panda/src/skel/typedSkel.I @@ -0,0 +1,56 @@ +// Filename: typedSkel.I +// Created by: jyelon (31Jan07) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: TypedSkel::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE TypedSkel:: +TypedSkel() { +} + +//////////////////////////////////////////////////////////////////// +// Function: TypedSkel::Destructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE TypedSkel:: +~TypedSkel() { +} + +//////////////////////////////////////////////////////////////////// +// Function: TypedSkel::set_value +// Access: Public +// Description: Stores an integer value. +//////////////////////////////////////////////////////////////////// +INLINE void TypedSkel:: +set_value(int n) { + _value = n; +} + +//////////////////////////////////////////////////////////////////// +// Function: TypedSkel::get_value +// Access: Public +// Description: Retreives a value that was previously stored. +//////////////////////////////////////////////////////////////////// +INLINE int TypedSkel:: +get_value() { + return _value; +} diff --git a/panda/src/skel/typedSkel.cxx b/panda/src/skel/typedSkel.cxx new file mode 100644 index 0000000000..ebb9fbbd2c --- /dev/null +++ b/panda/src/skel/typedSkel.cxx @@ -0,0 +1,45 @@ +// Filename: typedSkel.cxx +// Created by: jyelon (31Jan07) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "typedSkel.h" + +TypeHandle TypedSkel::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: TypedSkel::set_value_alt +// Access: Public +// Description: Stores an integer value. Exact same functionality +// as set_value, except that this isn't an inline +// function. +//////////////////////////////////////////////////////////////////// +void TypedSkel:: +set_value_alt(int n) { + _value = n; +} + +//////////////////////////////////////////////////////////////////// +// Function: TypedSkel::get_value +// Access: Public +// Description: Retreives a value that was previously stored. +// Exact same functionality as get_value, except +// that this isn't an inline function. +//////////////////////////////////////////////////////////////////// +int TypedSkel:: +get_value_alt() { + return _value; +} diff --git a/panda/src/skel/typedSkel.h b/panda/src/skel/typedSkel.h new file mode 100644 index 0000000000..a76ba73f93 --- /dev/null +++ b/panda/src/skel/typedSkel.h @@ -0,0 +1,73 @@ +// Filename: typedSkel.h +// Created by: jyelon (31Jan07) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef TYPEDSKEL_H +#define TYPEDSKEL_H + +#include "pandabase.h" +#include "typedObject.h" + +//////////////////////////////////////////////////////////////////// +// Class : TypedSkel +// Description : Skeleton object that inherits from TypedObject. +// Stores an integer, and will return it on request. +// +// The skeleton classes are intended to help you learn +// how to add C++ classes to panda. See also the manual, +// "Adding C++ Classes to Panda." +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDASKEL TypedSkel : public TypedObject { +PUBLISHED: + INLINE TypedSkel(); + INLINE ~TypedSkel(); + + // These inline functions allow you to get and set _value. + INLINE void set_value(int n); + INLINE int get_value(); + + // These do the same thing as the functions above. + void set_value_alt(int n); + int get_value_alt(); + +private: + int _value; + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedObject::init_type(); + register_type(_type_handle, "TypedSkel", + TypedObject::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + + static TypeHandle _type_handle; + +}; + +#include "typedSkel.I" + +#endif +