Rename EventStoreValue to ParamValue to make it more generic,

in anticipation of new parameter system
This commit is contained in:
rdb 2014-12-10 00:26:26 +01:00
parent 3fbdc43fbb
commit 40a40b20cf
16 changed files with 579 additions and 416 deletions

View File

@ -2596,11 +2596,11 @@ CopyAllHeaders('panda/src/downloader')
CopyAllHeaders('panda/metalibs/pandaexpress')
CopyAllHeaders('panda/src/pipeline')
CopyAllHeaders('panda/src/linmath')
CopyAllHeaders('panda/src/putil')
CopyAllHeaders('dtool/src/prckeys')
CopyAllHeaders('panda/src/audio')
CopyAllHeaders('panda/src/event')
CopyAllHeaders('panda/src/linmath')
CopyAllHeaders('panda/src/mathutil')
CopyAllHeaders('panda/src/gsgbase')
CopyAllHeaders('panda/src/pnmimage')
@ -3036,6 +3036,25 @@ if (not RUNTIME):
TargetAdd('libp3pipeline.in', opts=['IMOD:panda3d.core', 'ILIB:libp3pipeline', 'SRCDIR:panda/src/pipeline'])
TargetAdd('libp3pipeline_igate.obj', input='libp3pipeline.in', opts=["DEPENDENCYONLY"])
#
# DIRECTORY: panda/src/linmath/
#
if (not RUNTIME):
OPTS=['DIR:panda/src/linmath', 'BUILDING:PANDA']
TargetAdd('p3linmath_composite1.obj', opts=OPTS, input='p3linmath_composite1.cxx')
TargetAdd('p3linmath_composite2.obj', opts=OPTS, input='p3linmath_composite2.cxx')
IGATEFILES=GetDirectoryContents('panda/src/linmath', ["*.h", "*_composite*.cxx"])
for ifile in IGATEFILES[:]:
if "_src." in ifile:
IGATEFILES.remove(ifile)
IGATEFILES.remove('cast_to_double.h')
IGATEFILES.remove('lmat_ops.h')
IGATEFILES.remove('cast_to_float.h')
TargetAdd('libp3linmath.in', opts=OPTS, input=IGATEFILES)
TargetAdd('libp3linmath.in', opts=['IMOD:panda3d.core', 'ILIB:libp3linmath', 'SRCDIR:panda/src/linmath'])
TargetAdd('libp3linmath_igate.obj', input='libp3linmath.in', opts=["DEPENDENCYONLY"])
#
# DIRECTORY: panda/src/putil/
#
@ -3076,25 +3095,6 @@ if (not RUNTIME):
TargetAdd('libp3event.in', opts=['IMOD:panda3d.core', 'ILIB:libp3event', 'SRCDIR:panda/src/event'])
TargetAdd('libp3event_igate.obj', input='libp3event.in', opts=["DEPENDENCYONLY"])
#
# DIRECTORY: panda/src/linmath/
#
if (not RUNTIME):
OPTS=['DIR:panda/src/linmath', 'BUILDING:PANDA']
TargetAdd('p3linmath_composite1.obj', opts=OPTS, input='p3linmath_composite1.cxx')
TargetAdd('p3linmath_composite2.obj', opts=OPTS, input='p3linmath_composite2.cxx')
IGATEFILES=GetDirectoryContents('panda/src/linmath', ["*.h", "*_composite*.cxx"])
for ifile in IGATEFILES[:]:
if "_src." in ifile:
IGATEFILES.remove(ifile)
IGATEFILES.remove('cast_to_double.h')
IGATEFILES.remove('lmat_ops.h')
IGATEFILES.remove('cast_to_float.h')
TargetAdd('libp3linmath.in', opts=OPTS, input=IGATEFILES)
TargetAdd('libp3linmath.in', opts=['IMOD:panda3d.core', 'ILIB:libp3linmath', 'SRCDIR:panda/src/linmath'])
TargetAdd('libp3linmath_igate.obj', input='libp3linmath.in', opts=["DEPENDENCYONLY"])
#
# DIRECTORY: panda/src/mathutil/
#

View File

@ -34,7 +34,7 @@ class DatagramIterator;
// but it may be used anywhere a list of ButtonEvents
// is desired.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_EVENT ButtonEventList : public EventStoreValueBase {
class EXPCL_PANDA_EVENT ButtonEventList : public ParamValueBase {
public:
INLINE ButtonEventList();
INLINE ButtonEventList(const ButtonEventList &copy);
@ -64,15 +64,15 @@ protected:
public:
void fillin(DatagramIterator &scan, BamReader *manager);
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
EventStoreValueBase::init_type();
ParamValueBase::init_type();
register_type(_type_handle, "ButtonEventList",
EventStoreValueBase::get_class_type());
ParamValueBase::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();

View File

@ -42,12 +42,8 @@ ConfigureFn(config_event) {
PointerEventList::init_type();
Event::init_type();
EventHandler::init_type();
EventStoreValueBase::init_type();
EventStoreInt::init_type("EventStoreInt");
EventStoreDouble::init_type("EventStoreDouble");
EventStoreString::init_type("EventStoreString");
EventStoreWstring::init_type("EventStoreWstring");
EventStoreTypedRefCount::init_type();
GenericAsyncTask::init_type();
#ifdef HAVE_PYTHON
PythonTask::init_type();
@ -56,6 +52,4 @@ ConfigureFn(config_event) {
ButtonEventList::register_with_read_factory();
EventStoreInt::register_with_read_factory();
EventStoreDouble::register_with_read_factory();
EventStoreString::register_with_read_factory();
}

View File

@ -13,10 +13,6 @@
////////////////////////////////////////////////////////////////////
template<class Type>
TypeHandle EventStoreValue<Type>::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: EventParameter::Default constructor
// Access: Published
@ -299,175 +295,3 @@ operator << (ostream &out, const EventParameter &param) {
param.output(out);
return out;
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreValueBase::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE EventStoreValueBase::
EventStoreValueBase() {
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreTypedRefCount::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE EventStoreTypedRefCount::
EventStoreTypedRefCount(const TypedReferenceCount *value) :
_value((TypedReferenceCount *)value)
{
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreTypedRefCount::set_value
// Access: Published
// Description: Changes the value stored in the parameter. It is
// dangerous to do this for a parameter already added to
// an event, since the parameters may be shared.
////////////////////////////////////////////////////////////////////
INLINE void EventStoreTypedRefCount::
set_value(const TypedReferenceCount *value) {
_value = (TypedReferenceCount *)value;
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreTypedRefCount::get_value
// Access: Published
// Description: Retrieves the value stored in the parameter.
////////////////////////////////////////////////////////////////////
INLINE TypedReferenceCount *EventStoreTypedRefCount::
get_value() const {
return _value;
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreValue::Default Constructor
// Access: Private
// Description: This constructor is only for make_from_bam().
////////////////////////////////////////////////////////////////////
template<class Type>
EventStoreValue<Type>::
EventStoreValue() {
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreValue::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
template<class Type>
EventStoreValue<Type>::
EventStoreValue(const Type &value) :
_value(value)
{
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreValue::Destructor
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
template<class Type>
EventStoreValue<Type>::
~EventStoreValue() {
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreValue::set_value
// Access: Public
// Description: Changes the value stored in the parameter. It is
// dangerous to do this for a parameter already added to
// an event, since the parameters may be shared.
////////////////////////////////////////////////////////////////////
template<class Type>
INLINE void EventStoreValue<Type>::
set_value(const Type &value) {
_value = value;
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreValue::get_value
// Access: Public
// Description: Retrieves the value stored in the parameter.
////////////////////////////////////////////////////////////////////
template<class Type>
INLINE const Type &EventStoreValue<Type>::
get_value() const {
return _value;
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreValue::output
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
template<class Type>
void EventStoreValue<Type>::
output(ostream &out) const {
out << _value;
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreValue::register_with_read_factory
// Access: Public, Static
// Description: Tells the BamReader how to create objects of type
// Lens.
////////////////////////////////////////////////////////////////////
template<class Type>
void EventStoreValue<Type>::
register_with_read_factory() {
BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreValue::write_datagram
// Access: Public, Virtual
// Description: Writes the contents of this object to the datagram
// for shipping out to a Bam file.
////////////////////////////////////////////////////////////////////
template<class Type>
void EventStoreValue<Type>::
write_datagram(BamWriter *manager, Datagram &dg) {
TypedWritable::write_datagram(manager, dg);
generic_write_datagram(dg, _value);
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreValue::make_from_bam
// Access: Protected, Static
// Description: This function is called by the BamReader's factory
// when a new object of type Lens is encountered
// in the Bam file. It should create the Lens
// and extract its information from the file.
////////////////////////////////////////////////////////////////////
template<class Type>
TypedWritable *EventStoreValue<Type>::
make_from_bam(const FactoryParams &params) {
EventStoreValue<Type> *esv = new EventStoreValue<Type>;
DatagramIterator scan;
BamReader *manager;
parse_params(params, scan, manager);
esv->fillin(scan, manager);
return esv;
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreValue::fillin
// Access: Protected
// Description: This internal function is called by make_from_bam to
// read in all of the relevant data from the BamFile for
// the new Lens.
////////////////////////////////////////////////////////////////////
template<class Type>
void EventStoreValue<Type>::
fillin(DatagramIterator &scan, BamReader *manager) {
TypedWritable::fillin(scan, manager);
generic_read_datagram(_value, scan);
}

View File

@ -20,21 +20,18 @@
#pragma implementation
#endif
TypeHandle EventStoreValueBase::_type_handle;
TypeHandle EventStoreTypedRefCount::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: EventParameter::output
// Access: Published
// Description:
// Description:
////////////////////////////////////////////////////////////////////
void EventParameter::
output(ostream &out) const {
if (_ptr == (TypedWritableReferenceCount *)NULL) {
out << "(empty)";
} else if (_ptr->is_of_type(EventStoreValueBase::get_class_type())) {
const EventStoreValueBase *sv_ptr;
} else if (_ptr->is_of_type(ParamValueBase::get_class_type())) {
const ParamValueBase *sv_ptr;
DCAST_INTO_V(sv_ptr, _ptr);
sv_ptr->output(out);
@ -42,36 +39,3 @@ output(ostream &out) const {
out << _ptr->get_type();
}
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreValueBase::Destructor
// Access: Published, Virtual
// Description:
////////////////////////////////////////////////////////////////////
EventStoreValueBase::
~EventStoreValueBase() {
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreTypedRefCount::Destructor
// Access: Published, Virtual
// Description:
////////////////////////////////////////////////////////////////////
EventStoreTypedRefCount::
~EventStoreTypedRefCount() {
}
////////////////////////////////////////////////////////////////////
// Function: EventStoreTypedRefCount::output
// Access: Published, Virtual
// Description:
////////////////////////////////////////////////////////////////////
void EventStoreTypedRefCount::
output(ostream &out) const {
if (_value == (TypedReferenceCount *)NULL) {
out << "(empty)";
} else {
out << _value->get_type();
}
}

View File

@ -23,6 +23,7 @@
#include "pointerTo.h"
#include "bamReader.h"
#include "bamWriter.h"
#include "paramValue.h"
////////////////////////////////////////////////////////////////////
// Class : EventParameter
@ -32,8 +33,7 @@
// object, which of course could be pretty much
// anything. To store a simple value like a double or a
// string, the EventParameter constructors transparently
// use the EventStoreValue template class, defined
// below.
// use the ParamValue template class from paramValue.h.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_EVENT EventParameter {
PUBLISHED:
@ -77,138 +77,15 @@ private:
INLINE ostream &operator << (ostream &out, const EventParameter &param);
////////////////////////////////////////////////////////////////////
// Class : EventStoreValueBase
// Description : A non-template base class of EventStoreValue (below),
// which serves mainly to define the placeholder for the
// virtual output function.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_EVENT EventStoreValueBase : public TypedWritableReferenceCount {
public:
INLINE EventStoreValueBase();
typedef ParamTypedRefCount EventStoreTypedRefCount;
PUBLISHED:
virtual ~EventStoreValueBase();
virtual void output(ostream &out) const=0;
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, ParamValue<int>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, ParamValue<double>);
public:
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
TypedWritableReferenceCount::init_type();
register_type(_type_handle, "EventStoreValueBase",
TypedWritableReferenceCount::get_class_type());
}
private:
static TypeHandle _type_handle;
};
////////////////////////////////////////////////////////////////////
// Class : EventStoreTypedRefCount
// Description : A class object for storing specifically objects of
// type TypedReferenceCount, which is different than
// TypedWritableReferenceCount.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_EVENT EventStoreTypedRefCount : public EventStoreValueBase {
PUBLISHED:
INLINE EventStoreTypedRefCount(const TypedReferenceCount *value);
virtual ~EventStoreTypedRefCount();
INLINE void set_value(const TypedReferenceCount *value);
INLINE TypedReferenceCount *get_value() const;
virtual void output(ostream &out) const;
public:
PT(TypedReferenceCount) _value;
public:
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
EventStoreValueBase::init_type();
register_type(_type_handle, "EventStoreTypedRefCount",
EventStoreValueBase::get_class_type());
}
private:
static TypeHandle _type_handle;
};
////////////////////////////////////////////////////////////////////
// Class : EventStoreValue
// Description : A handy class object for storing simple values (like
// integers or strings) passed along with an Event.
// This is essentially just a wrapper around whatever
// data type you like, to make it a
// TypedWritableReferenceCount object which can be
// passed along inside an EventParameter.
////////////////////////////////////////////////////////////////////
template<class Type>
class EventStoreValue : public EventStoreValueBase {
private:
INLINE EventStoreValue();
public:
INLINE EventStoreValue(const Type &value);
virtual ~EventStoreValue();
INLINE void set_value(const Type &value);
INLINE const Type &get_value() const;
virtual void output(ostream &out) const;
Type _value;
public:
static void register_with_read_factory();
virtual void write_datagram(BamWriter *manager, Datagram &dg);
protected:
static TypedWritable *make_from_bam(const FactoryParams &params);
void fillin(DatagramIterator &scan, BamReader *manager);
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type(const string &type_name = "UndefinedEventStoreValue") {
EventStoreValueBase::init_type();
_type_handle = register_dynamic_type
(type_name, EventStoreValueBase::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {
// In this case, we can't do anything, since we don't have the
// class' type_name.
return get_class_type();
}
private:
static TypeHandle _type_handle;
};
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, EventStoreValue<int>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, EventStoreValue<double>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, EventStoreValue<std::string>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, EventStoreValue<std::wstring>);
typedef EventStoreValue<int> EventStoreInt;
typedef EventStoreValue<double> EventStoreDouble;
typedef EventStoreValue<string> EventStoreString;
typedef EventStoreValue<wstring> EventStoreWstring;
typedef ParamValue<int> EventStoreInt;
typedef ParamValue<double> EventStoreDouble;
typedef ParamString EventStoreString;
typedef ParamWstring EventStoreWstring;
#include "eventParameter.I"
@ -218,4 +95,3 @@ typedef EventStoreValue<wstring> EventStoreWstring;
#endif
#endif

View File

@ -34,7 +34,7 @@ class DatagramIterator;
// but it may be used anywhere a list of PointerEvents
// is desired.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_EVENT PointerEventList : public EventStoreValueBase {
class EXPCL_PANDA_EVENT PointerEventList : public ParamValueBase {
PUBLISHED:
INLINE PointerEventList();
@ -53,16 +53,15 @@ PUBLISHED:
INLINE void clear();
INLINE void pop_front();
void add_event(bool in_win, int xpos, int ypos, int seq, double time);
bool encircles(int x, int y) const;
double total_turns(double sec) const;
double match_pattern(const string &pattern, double rot, double seglen);
public:
INLINE PointerEventList(const PointerEventList &copy);
INLINE void operator = (const PointerEventList &copy);
virtual void output(ostream &out) const;
void write(ostream &out, int indent_level = 0) const;
@ -76,9 +75,9 @@ public:
return _type_handle;
}
static void init_type() {
EventStoreValueBase::init_type();
ParamValueBase::init_type();
register_type(_type_handle, "PointerEventList",
EventStoreValueBase::get_class_type());
ParamValueBase::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();

View File

@ -24,7 +24,6 @@
#include "boundingPlane.h"
#include "unionBoundingVolume.h"
#include "intersectionBoundingVolume.h"
#include "linmath_events.h"
#include "dconfig.h"
#include "pandaSystem.h"
@ -80,17 +79,9 @@ init_libmathutil() {
IntersectionBoundingVolume::init_type();
BoundingLine::init_type();
BoundingPlane::init_type();
EventStoreVec2::init_type("EventStoreVec2");
EventStoreVec3::init_type("EventStoreVec3");
EventStoreMat4::init_type("EventStoreMat4");
EventStoreVec2::register_with_read_factory();
EventStoreVec3::register_with_read_factory();
EventStoreMat4::register_with_read_factory();
#ifdef HAVE_FFTW
PandaSystem *ps = PandaSystem::get_global_ptr();
ps->add_system("fftw");
#endif // FFTW
}

View File

@ -17,29 +17,22 @@
#include "pandabase.h"
#include "eventParameter.h"
#include "paramValue.h"
#include "luse.h"
////////////////////////////////////////////////////////////////////
//
// This file defines a few more EventStore classes for storing linmath
// objects in an EventParameter. We can't define this with the other
// EventStore classes, because linmath hasn't been defined yet at that
// point.
// objects in an EventParameter. These are just for backward
// compatibility; they are defined as typedefs to ParamVecBase types.
//
// See eventParameter.h.
// See paramValue.h.
//
////////////////////////////////////////////////////////////////////
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, EventStoreValue<LVecBase2>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, EventStoreValue<LVecBase3>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, EventStoreValue<LMatrix4>);
typedef EventStoreValue<LVecBase2> EventStoreVec2;
typedef EventStoreValue<LVecBase3> EventStoreVec3;
typedef EventStoreValue<LMatrix4> EventStoreMat4;
typedef ParamVecBase2 EventStoreVec2;
typedef ParamVecBase3 EventStoreVec3;
typedef ParamMatrix4 EventStoreMat4;
// Tell GCC that we'll take care of the instantiation explicitly here.
#ifdef __GNUC__

View File

@ -24,7 +24,7 @@
// Description : A class object for storing specifically objects of
// type PandaNode.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH EventStorePandaNode : public EventStoreValueBase {
class EXPCL_PANDA_PGRAPH EventStorePandaNode : public ParamValueBase {
PUBLISHED:
INLINE EventStorePandaNode(const PandaNode *value);
virtual ~EventStorePandaNode();
@ -46,9 +46,9 @@ public:
return _type_handle;
}
static void init_type() {
EventStoreValueBase::init_type();
ParamValueBase::init_type();
register_type(_type_handle, "EventStorePandaNode",
EventStoreValueBase::get_class_type());
ParamValueBase::get_class_type());
}
private:

View File

@ -1,6 +1,6 @@
#define OTHER_LIBS p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \
p3dtoolutil:c p3dtoolbase:c p3dtool:m p3prc:c
#define LOCAL_LIBS p3pipeline p3express p3pandabase
#define LOCAL_LIBS p3pipeline p3linmath p3express p3pandabase
#define USE_PACKAGES zlib
#begin lib_target
@ -57,6 +57,7 @@
modifierButtons.I modifierButtons.h mouseButton.h \
mouseData.I mouseData.h nameUniquifier.I nameUniquifier.h \
nodeCachedReferenceCount.h nodeCachedReferenceCount.I \
paramValue.I paramValue.h \
pbitops.I pbitops.h \
portalMask.h \
pta_ushort.h \
@ -107,6 +108,7 @@
modifierButtons.cxx mouseButton.cxx mouseData.cxx \
nameUniquifier.cxx \
nodeCachedReferenceCount.cxx \
paramValue.cxx \
pbitops.cxx \
pta_ushort.cxx \
pythonCallbackObject.cxx \
@ -167,8 +169,9 @@
modifierButtons.h mouseButton.h mouseData.I mouseData.h \
nameUniquifier.I nameUniquifier.h \
nodeCachedReferenceCount.h nodeCachedReferenceCount.I \
portalMask.h \
paramValue.I paramValue.h \
pbitops.I pbitops.h \
portalMask.h \
pta_ushort.h \
pythonCallbackObject.h pythonCallbackObject.I \
simpleHashMap.I simpleHashMap.h \

View File

@ -34,6 +34,7 @@
#include "factoryParam.h"
#include "namable.h"
#include "nodeCachedReferenceCount.h"
#include "paramValue.h"
#include "pythonCallbackObject.h"
#include "referenceCount.h"
#include "sparseArray.h"
@ -62,7 +63,7 @@ ConfigVariableEnum<BamEnums::BamEndian> bam_endian
"particular platform."));
ConfigVariableBool bam_stdfloat_double
("bam-stdfloat-double",
("bam-stdfloat-double",
#ifdef STDFLOAT_DOUBLE
true,
#else
@ -70,7 +71,7 @@ ConfigVariableBool bam_stdfloat_double
#endif
PRC_DESC("The default width of floating-point numbers to write to a bam "
"file. Set this true to force doubles (64-bit floats), or false "
"to force sinles (32-bit floats). The default is whichever width "
"to force singles (32-bit floats). The default is whichever width "
"Panda has been compiled to use natively. Normally, this setting "
"should not be changed from the default."));
@ -79,8 +80,6 @@ ConfigVariableEnum<BamEnums::BamTextureMode> bam_texture_mode
PRC_DESC("Set this to specify how textures should be written into Bam files."
"See the panda source or documentation for available options."));
ConfigureFn(config_util) {
init_libputil();
}
@ -200,6 +199,23 @@ init_libputil() {
FactoryParam::init_type();
Namable::init_type();
NodeCachedReferenceCount::init_type();
ParamMatrix3d::init_type("ParamMatrix3d");
ParamMatrix3f::init_type("ParamMatrix3f");
ParamMatrix4d::init_type("ParamMatrix4d");
ParamMatrix4f::init_type("ParamMatrix4f");
ParamString::init_type("ParamString");
ParamTypedRefCount::init_type();
ParamValueBase::init_type();
ParamVecBase2d::init_type("ParamVecBase2d");
ParamVecBase2f::init_type("ParamVecBase2f");
ParamVecBase2i::init_type("ParamVecBase2i");
ParamVecBase3d::init_type("ParamVecBase3d");
ParamVecBase3f::init_type("ParamVecBase3f");
ParamVecBase3i::init_type("ParamVecBase3i");
ParamVecBase4f::init_type("ParamVecBase4f");
ParamVecBase4d::init_type("ParamVecBase4d");
ParamVecBase4i::init_type("ParamVecBase4i");
ParamWstring::init_type("ParamWstring");
#ifdef HAVE_PYTHON
PythonCallbackObject::init_type();
#endif
@ -218,4 +234,19 @@ init_libputil() {
BamCacheIndex::register_with_read_factory();
BamCacheRecord::register_with_read_factory();
ParamMatrix3d::register_with_read_factory();
ParamMatrix3f::register_with_read_factory();
ParamMatrix4d::register_with_read_factory();
ParamMatrix4f::register_with_read_factory();
ParamString::register_with_read_factory();
ParamVecBase2d::register_with_read_factory();
ParamVecBase2f::register_with_read_factory();
ParamVecBase2i::register_with_read_factory();
ParamVecBase3d::register_with_read_factory();
ParamVecBase3f::register_with_read_factory();
ParamVecBase3i::register_with_read_factory();
ParamVecBase4d::register_with_read_factory();
ParamVecBase4f::register_with_read_factory();
ParamVecBase4i::register_with_read_factory();
ParamWstring::register_with_read_factory();
}

View File

@ -12,6 +12,7 @@
#include "mouseData.cxx"
#include "nameUniquifier.cxx"
#include "nodeCachedReferenceCount.cxx"
#include "paramValue.cxx"
#include "pbitops.cxx"
#include "pta_ushort.cxx"
#include "pythonCallbackObject.cxx"

View File

@ -0,0 +1,209 @@
// Filename: paramValue.I
// Created by: drose (08Feb99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
template<class Type>
TypeHandle ParamValue<Type>::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: ParamValueBase::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE ParamValueBase::
ParamValueBase() {
}
////////////////////////////////////////////////////////////////////
// Function: ParamValueBase::get_value_type
// Access: Published, Virtual
// Description: Returns the type of the underlying value.
////////////////////////////////////////////////////////////////////
INLINE TypeHandle ParamValueBase::
get_value_type() const {
return TypeHandle::none();
}
////////////////////////////////////////////////////////////////////
// Function: ParamTypedRefCount::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE ParamTypedRefCount::
ParamTypedRefCount(const TypedReferenceCount *value) :
_value((TypedReferenceCount *)value)
{
}
////////////////////////////////////////////////////////////////////
// Function: ParamTypedRefCount::get_value_type
// Access: Published
// Description: Retrieves the type of the value stored in the
// parameter.
////////////////////////////////////////////////////////////////////
INLINE TypeHandle ParamTypedRefCount::
get_value_type() const {
if (_value == NULL) {
return TypeHandle::none();
} else {
return _value->get_type();
}
}
////////////////////////////////////////////////////////////////////
// Function: ParamTypedRefCount::get_value
// Access: Published
// Description: Retrieves the value stored in the parameter.
////////////////////////////////////////////////////////////////////
INLINE TypedReferenceCount *ParamTypedRefCount::
get_value() const {
return _value;
}
////////////////////////////////////////////////////////////////////
// Function: ParamValue::Constructor
// Access: Protected
// Description:
////////////////////////////////////////////////////////////////////
template<class Type>
INLINE ParamValue<Type>::
ParamValue() {}
////////////////////////////////////////////////////////////////////
// Function: ParamValue::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
template<class Type>
INLINE ParamValue<Type>::
ParamValue(const Type &value) :
_value(value)
{
}
////////////////////////////////////////////////////////////////////
// Function: ParamValue::Destructor
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
template<class Type>
INLINE ParamValue<Type>::
~ParamValue() {
}
////////////////////////////////////////////////////////////////////
// Function: ParamValue::get_value_type
// Access: Public, Virtual
// Description: Retrieves the type of the value stored in the
// parameter.
////////////////////////////////////////////////////////////////////
template<class Type>
INLINE TypeHandle ParamValue<Type>::
get_value_type() const {
return get_type_handle(Type);
}
////////////////////////////////////////////////////////////////////
// Function: ParamValue::set_value
// Access: Public, Virtual
// Description: Changes the value stored in the parameter.
////////////////////////////////////////////////////////////////////
template<class Type>
INLINE void ParamValue<Type>::
set_value(const Type &type) {
_value = type;
mark_bam_modified();
}
////////////////////////////////////////////////////////////////////
// Function: ParamValue::get_value
// Access: Public
// Description: Retrieves the value stored in the parameter.
////////////////////////////////////////////////////////////////////
template<class Type>
INLINE const Type &ParamValue<Type>::
get_value() const {
return _value;
}
////////////////////////////////////////////////////////////////////
// Function: ParamValue::output
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
template<class Type>
INLINE void ParamValue<Type>::
output(ostream &out) const {
out << _value;
}
////////////////////////////////////////////////////////////////////
// Function: ParamValue::register_with_read_factory
// Access: Public, Static
// Description: Tells the BamReader how to create objects of type
// ParamValue.
////////////////////////////////////////////////////////////////////
template<class Type>
INLINE void ParamValue<Type>::
register_with_read_factory() {
BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
}
////////////////////////////////////////////////////////////////////
// Function: ParamValue::write_datagram
// Access: Public, Virtual
// Description: Writes the contents of this object to the datagram
// for shipping out to a Bam file.
////////////////////////////////////////////////////////////////////
template<class Type>
INLINE void ParamValue<Type>::
write_datagram(BamWriter *manager, Datagram &dg) {
TypedWritable::write_datagram(manager, dg);
generic_write_datagram(dg, _value);
}
////////////////////////////////////////////////////////////////////
// Function: ParamValue::make_from_bam
// Access: Protected, Static
// Description: This function is called by the BamReader's factory
// when a new object of type ParamValue is encountered
// in the Bam file. It should create the ParamValue
// and extract its information from the file.
////////////////////////////////////////////////////////////////////
template<class Type>
INLINE TypedWritable *ParamValue<Type>::
make_from_bam(const FactoryParams &params) {
ParamValue<Type> *esv = new ParamValue<Type>;
DatagramIterator scan;
BamReader *manager;
parse_params(params, scan, manager);
esv->fillin(scan, manager);
return esv;
}
////////////////////////////////////////////////////////////////////
// Function: ParamValue::fillin
// Access: Protected
// Description: This internal function is called by make_from_bam to
// read in all of the relevant data from the BamFile for
// the new ParamValue.
////////////////////////////////////////////////////////////////////
template<class Type>
INLINE void ParamValue<Type>::
fillin(DatagramIterator &scan, BamReader *manager) {
TypedWritable::fillin(scan, manager);
generic_read_datagram(_value, scan);
}

View File

@ -0,0 +1,57 @@
// Filename: paramValue.cxx
// Created by: drose (08Feb99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#include "paramValue.h"
#include "dcast.h"
// Tell GCC that we'll take care of the instantiation explicitly here.
#ifdef __GNUC__
#pragma implementation
#endif
TypeHandle ParamValueBase::_type_handle;
TypeHandle ParamTypedRefCount::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: ParamValueBase::Destructor
// Access: Published, Virtual
// Description:
////////////////////////////////////////////////////////////////////
ParamValueBase::
~ParamValueBase() {
}
////////////////////////////////////////////////////////////////////
// Function: ParamTypedRefCount::Destructor
// Access: Published, Virtual
// Description:
////////////////////////////////////////////////////////////////////
ParamTypedRefCount::
~ParamTypedRefCount() {
}
////////////////////////////////////////////////////////////////////
// Function: ParamTypedRefCount::output
// Access: Published, Virtual
// Description:
////////////////////////////////////////////////////////////////////
void ParamTypedRefCount::
output(ostream &out) const {
if (_value == (TypedReferenceCount *)NULL) {
out << "(empty)";
} else {
out << _value->get_type();
}
}

View File

@ -0,0 +1,221 @@
// Filename: paramValue.h
// Created by: drose (08Feb99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef PARAMVALUE_H
#define PARAMVALUE_H
#include "pandabase.h"
#include "typedef.h"
#include "typedObject.h"
#include "typedWritableReferenceCount.h"
#include "pointerTo.h"
#include "bamReader.h"
#include "bamWriter.h"
#include "luse.h"
////////////////////////////////////////////////////////////////////
// Class : ParamValueBase
// Description : A non-template base class of ParamValue (below),
// which serves mainly to define the placeholder for the
// virtual output function.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PUTIL ParamValueBase : public TypedWritableReferenceCount {
public:
INLINE ParamValueBase();
PUBLISHED:
virtual ~ParamValueBase();
INLINE virtual TypeHandle get_value_type() const;
virtual void output(ostream &out) const=0;
public:
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
TypedWritableReferenceCount::init_type();
register_type(_type_handle, "ParamValueBase",
TypedWritableReferenceCount::get_class_type());
}
private:
static TypeHandle _type_handle;
};
////////////////////////////////////////////////////////////////////
// Class : ParamTypedRefCount
// Description : A class object for storing specifically objects of
// type TypedReferenceCount, which is different than
// TypedWritableReferenceCount.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PUTIL ParamTypedRefCount : public ParamValueBase {
PUBLISHED:
INLINE ParamTypedRefCount(const TypedReferenceCount *value);
virtual ~ParamTypedRefCount();
INLINE virtual TypeHandle get_value_type() const;
INLINE TypedReferenceCount *get_value() const;
virtual void output(ostream &out) const;
private:
PT(TypedReferenceCount) _value;
public:
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
ParamValueBase::init_type();
register_type(_type_handle, "ParamTypedRefCount",
ParamValueBase::get_class_type());
}
private:
static TypeHandle _type_handle;
};
////////////////////////////////////////////////////////////////////
// Class : ParamValue
// Description : A handy class object for storing simple values (like
// integers or strings) passed along with an Event
// or to be used as a shader input.
// This is essentially just a wrapper around whatever
// data type you like, to make it a
// TypedWritableReferenceCount object which can be
// passed along inside an EventParameter or ShaderInput.
////////////////////////////////////////////////////////////////////
template<class Type>
class ParamValue : public ParamValueBase {
protected:
INLINE ParamValue();
PUBLISHED:
INLINE ParamValue(const Type &value);
INLINE virtual ~ParamValue();
INLINE virtual TypeHandle get_value_type() const;
INLINE void set_value(const Type &value);
INLINE const Type &get_value() const;
INLINE virtual void output(ostream &out) const;
private:
Type _value;
public:
INLINE static void register_with_read_factory();
INLINE virtual void write_datagram(BamWriter *manager, Datagram &dg);
protected:
INLINE static TypedWritable *make_from_bam(const FactoryParams &params);
INLINE void fillin(DatagramIterator &scan, BamReader *manager);
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type(const string &type_name = "UndefinedParamValue") {
ParamValueBase::init_type();
_type_handle = register_dynamic_type
(type_name, ParamValueBase::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {
// In this case, we can't do anything, since we don't have the
// class' type_name.
return get_class_type();
}
private:
static TypeHandle _type_handle;
};
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<std::string>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<std::wstring>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<LVecBase2d>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<LVecBase2f>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<LVecBase2i>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<LVecBase3d>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<LVecBase3f>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<LVecBase3i>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<LVecBase4d>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<LVecBase4f>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<LVecBase4i>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<LMatrix3d>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<LMatrix3f>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<LMatrix4d>);
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue<LMatrix4f>);
typedef ParamValue<string> ParamString;
typedef ParamValue<wstring> ParamWstring;
typedef ParamValue<LVecBase2d> ParamVecBase2d;
typedef ParamValue<LVecBase2f> ParamVecBase2f;
typedef ParamValue<LVecBase2i> ParamVecBase2i;
typedef ParamValue<LVecBase3d> ParamVecBase3d;
typedef ParamValue<LVecBase3f> ParamVecBase3f;
typedef ParamValue<LVecBase3i> ParamVecBase3i;
typedef ParamValue<LVecBase4d> ParamVecBase4d;
typedef ParamValue<LVecBase4f> ParamVecBase4f;
typedef ParamValue<LVecBase4i> ParamVecBase4i;
typedef ParamValue<LMatrix3d> ParamMatrix3d;
typedef ParamValue<LMatrix3f> ParamMatrix3f;
typedef ParamValue<LMatrix4d> ParamMatrix4d;
typedef ParamValue<LMatrix4f> ParamMatrix4f;
#ifdef STDFLOAT_DOUBLE
typedef ParamVecBase2d ParamVecBase2;
typedef ParamVecBase3d ParamVecBase3;
typedef ParamVecBase4d ParamVecBase4;
typedef ParamMatrix3d ParamMatrix3;
typedef ParamMatrix4d ParamMatrix4;
#else
typedef ParamVecBase2f ParamVecBase2;
typedef ParamVecBase3f ParamVecBase3;
typedef ParamVecBase4f ParamVecBase4;
typedef ParamMatrix3f ParamMatrix3;
typedef ParamMatrix4f ParamMatrix4;
#endif
#include "paramValue.I"
// Tell GCC that we'll take care of the instantiation explicitly here.
#ifdef __GNUC__
#pragma interface
#endif
#endif