From fbc38a3e01359bf8050019a1c31ff329397a5b8c Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 10 Nov 2008 23:54:45 +0000 Subject: [PATCH] collection operator + --- panda/src/event/asyncTaskCollection.I | 23 ++++++++++ panda/src/event/asyncTaskCollection.h | 2 + panda/src/ode/Sources.pp | 4 +- panda/src/ode/odeJointCollection.I | 46 +++++++++++++++++++ panda/src/ode/odeJointCollection.h | 6 ++- .../parametrics/parametricCurveCollection.h | 2 + panda/src/pgraph/internalNameCollection.I | 23 ++++++++++ panda/src/pgraph/internalNameCollection.h | 2 + panda/src/pgraph/materialCollection.I | 23 ++++++++++ panda/src/pgraph/materialCollection.h | 2 + panda/src/pgraph/nodePathCollection.I | 23 ++++++++++ panda/src/pgraph/nodePathCollection.h | 2 + panda/src/pgraph/textureCollection.I | 23 ++++++++++ panda/src/pgraph/textureCollection.h | 2 + panda/src/pgraph/textureStageCollection.I | 23 ++++++++++ panda/src/pgraph/textureStageCollection.h | 2 + panda/src/physics/physicsObjectCollection.I | 23 ++++++++++ panda/src/physics/physicsObjectCollection.h | 2 + 18 files changed, 230 insertions(+), 3 deletions(-) create mode 100644 panda/src/ode/odeJointCollection.I diff --git a/panda/src/event/asyncTaskCollection.I b/panda/src/event/asyncTaskCollection.I index 0e95db8ea8..9eb5a3fa04 100644 --- a/panda/src/event/asyncTaskCollection.I +++ b/panda/src/event/asyncTaskCollection.I @@ -21,3 +21,26 @@ INLINE AsyncTaskCollection:: ~AsyncTaskCollection() { } + +//////////////////////////////////////////////////////////////////// +// Function: AsyncTaskCollection::operator += +// Access: Published +// Description: Appends the other list onto the end of this one. +//////////////////////////////////////////////////////////////////// +INLINE void AsyncTaskCollection:: +operator += (const AsyncTaskCollection &other) { + add_tasks_from(other); +} + +//////////////////////////////////////////////////////////////////// +// Function: AsyncTaskCollection::operator + +// Access: Published +// Description: Returns a AsyncTaskCollection representing the +// concatenation of the two lists. +//////////////////////////////////////////////////////////////////// +INLINE AsyncTaskCollection AsyncTaskCollection:: +operator + (const AsyncTaskCollection &other) const { + AsyncTaskCollection a(*this); + a += other; + return a; +} diff --git a/panda/src/event/asyncTaskCollection.h b/panda/src/event/asyncTaskCollection.h index e3f99f67b6..29c743bc45 100644 --- a/panda/src/event/asyncTaskCollection.h +++ b/panda/src/event/asyncTaskCollection.h @@ -50,6 +50,8 @@ PUBLISHED: void remove_task(int index); AsyncTask *operator [] (int index) const; int size() const; + INLINE void operator += (const AsyncTaskCollection &other); + INLINE AsyncTaskCollection operator + (const AsyncTaskCollection &other) const; void output(ostream &out) const; void write(ostream &out, int indent_level = 0) const; diff --git a/panda/src/ode/Sources.pp b/panda/src/ode/Sources.pp index cf7e0cfffd..78195b12ef 100755 --- a/panda/src/ode/Sources.pp +++ b/panda/src/ode/Sources.pp @@ -38,7 +38,7 @@ odePlane2dJoint.I odePlane2dJoint.h \ odeSliderJoint.I odeSliderJoint.h \ odeUniversalJoint.I odeUniversalJoint.h \ - odeJointCollection.h \ + odeJointCollection.I odeJointCollection.h \ odeSimpleSpace.I odeSimpleSpace.h \ odeHashSpace.I odeHashSpace.h \ odeQuadTreeSpace.I odeQuadTreeSpace.h \ @@ -99,7 +99,7 @@ odePlane2dJoint.I odePlane2dJoint.h \ odeSliderJoint.I odeSliderJoint.h \ odeUniversalJoint.I odeUniversalJoint.h \ - odeJointCollection.h \ + odeJointCollection.I odeJointCollection.h \ odeSimpleSpace.I odeSimpleSpace.h \ odeHashSpace.I odeHashSpace.h \ odeQuadTreeSpace.I odeQuadTreeSpace.h \ diff --git a/panda/src/ode/odeJointCollection.I b/panda/src/ode/odeJointCollection.I new file mode 100644 index 0000000000..1150bbfd89 --- /dev/null +++ b/panda/src/ode/odeJointCollection.I @@ -0,0 +1,46 @@ +// Filename: odeJointCollection.I +// Created by: drose (10Nov08) +// +//////////////////////////////////////////////////////////////////// +// +// 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." +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: OdeJointCollection::Destructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE OdeJointCollection:: +~OdeJointCollection() { +} + +//////////////////////////////////////////////////////////////////// +// Function: OdeJointCollection::operator += +// Access: Published +// Description: Appends the other list onto the end of this one. +//////////////////////////////////////////////////////////////////// +INLINE void OdeJointCollection:: +operator += (const OdeJointCollection &other) { + add_joints_from(other); +} + +//////////////////////////////////////////////////////////////////// +// Function: OdeJointCollection::operator + +// Access: Published +// Description: Returns a OdeJointCollection representing the +// concatenation of the two lists. +//////////////////////////////////////////////////////////////////// +INLINE OdeJointCollection OdeJointCollection:: +operator + (const OdeJointCollection &other) const { + OdeJointCollection a(*this); + a += other; + return a; +} diff --git a/panda/src/ode/odeJointCollection.h b/panda/src/ode/odeJointCollection.h index e4f141b0b0..38bab187fd 100755 --- a/panda/src/ode/odeJointCollection.h +++ b/panda/src/ode/odeJointCollection.h @@ -26,7 +26,7 @@ PUBLISHED: OdeJointCollection(); OdeJointCollection(const OdeJointCollection ©); void operator = (const OdeJointCollection ©); - INLINE ~OdeJointCollection() {}; + INLINE ~OdeJointCollection(); void add_joint(const OdeJoint &joint); bool remove_joint(const OdeJoint &joint); @@ -42,10 +42,14 @@ PUBLISHED: MAKE_SEQ(get_joints, get_num_joints, get_joint); OdeJoint operator [] (int index) const; int size() const; + INLINE void operator += (const OdeJointCollection &other); + INLINE OdeJointCollection operator + (const OdeJointCollection &other) const; private: typedef PTA(OdeJoint) Joints; Joints _joints; }; +#include "odeJointCollection.I" + #endif diff --git a/panda/src/parametrics/parametricCurveCollection.h b/panda/src/parametrics/parametricCurveCollection.h index c03539a70c..b8612d5054 100644 --- a/panda/src/parametrics/parametricCurveCollection.h +++ b/panda/src/parametrics/parametricCurveCollection.h @@ -54,12 +54,14 @@ PUBLISHED: INLINE int get_num_curves() const; INLINE ParametricCurve *get_curve(int index) const; + MAKE_SEQ(get_curves, get_num_curves, get_curve); ParametricCurve *get_xyz_curve() const; ParametricCurve *get_hpr_curve() const; ParametricCurve *get_default_curve() const; int get_num_timewarps() const; ParametricCurve *get_timewarp_curve(int n) const; + MAKE_SEQ(get_timewarp_curves, get_num_timewarps, get_timewarp_curve); INLINE float get_max_t() const; diff --git a/panda/src/pgraph/internalNameCollection.I b/panda/src/pgraph/internalNameCollection.I index a148df13ea..67d217b351 100644 --- a/panda/src/pgraph/internalNameCollection.I +++ b/panda/src/pgraph/internalNameCollection.I @@ -21,3 +21,26 @@ INLINE InternalNameCollection:: ~InternalNameCollection() { } + +//////////////////////////////////////////////////////////////////// +// Function: InternalNameCollection::operator += +// Access: Published +// Description: Appends the other list onto the end of this one. +//////////////////////////////////////////////////////////////////// +INLINE void InternalNameCollection:: +operator += (const InternalNameCollection &other) { + add_names_from(other); +} + +//////////////////////////////////////////////////////////////////// +// Function: InternalNameCollection::operator + +// Access: Published +// Description: Returns a InternalNameCollection representing the +// concatenation of the two lists. +//////////////////////////////////////////////////////////////////// +INLINE InternalNameCollection InternalNameCollection:: +operator + (const InternalNameCollection &other) const { + InternalNameCollection a(*this); + a += other; + return a; +} diff --git a/panda/src/pgraph/internalNameCollection.h b/panda/src/pgraph/internalNameCollection.h index 9e66b56b68..48e0cf443f 100644 --- a/panda/src/pgraph/internalNameCollection.h +++ b/panda/src/pgraph/internalNameCollection.h @@ -43,6 +43,8 @@ PUBLISHED: MAKE_SEQ(get_names, get_num_names, get_name); InternalName *operator [] (int index) const; int size() const; + INLINE void operator += (const InternalNameCollection &other); + INLINE InternalNameCollection operator + (const InternalNameCollection &other) const; void output(ostream &out) const; void write(ostream &out, int indent_level = 0) const; diff --git a/panda/src/pgraph/materialCollection.I b/panda/src/pgraph/materialCollection.I index b88083e94e..041b01a64f 100644 --- a/panda/src/pgraph/materialCollection.I +++ b/panda/src/pgraph/materialCollection.I @@ -21,3 +21,26 @@ INLINE MaterialCollection:: ~MaterialCollection() { } + +//////////////////////////////////////////////////////////////////// +// Function: MaterialCollection::operator += +// Access: Published +// Description: Appends the other list onto the end of this one. +//////////////////////////////////////////////////////////////////// +INLINE void MaterialCollection:: +operator += (const MaterialCollection &other) { + add_materials_from(other); +} + +//////////////////////////////////////////////////////////////////// +// Function: MaterialCollection::operator + +// Access: Published +// Description: Returns a MaterialCollection representing the +// concatenation of the two lists. +//////////////////////////////////////////////////////////////////// +INLINE MaterialCollection MaterialCollection:: +operator + (const MaterialCollection &other) const { + MaterialCollection a(*this); + a += other; + return a; +} diff --git a/panda/src/pgraph/materialCollection.h b/panda/src/pgraph/materialCollection.h index a4f7ee6527..2b607f6513 100644 --- a/panda/src/pgraph/materialCollection.h +++ b/panda/src/pgraph/materialCollection.h @@ -44,6 +44,8 @@ PUBLISHED: Material *get_material(int index) const; Material *operator [] (int index) const; int size() const; + INLINE void operator += (const MaterialCollection &other); + INLINE MaterialCollection operator + (const MaterialCollection &other) const; void output(ostream &out) const; void write(ostream &out, int indent_level = 0) const; diff --git a/panda/src/pgraph/nodePathCollection.I b/panda/src/pgraph/nodePathCollection.I index b54901b969..2da5cee643 100644 --- a/panda/src/pgraph/nodePathCollection.I +++ b/panda/src/pgraph/nodePathCollection.I @@ -22,6 +22,29 @@ INLINE NodePathCollection:: ~NodePathCollection() { } +//////////////////////////////////////////////////////////////////// +// Function: NodePathCollection::operator += +// Access: Published +// Description: Appends the other list onto the end of this one. +//////////////////////////////////////////////////////////////////// +INLINE void NodePathCollection:: +operator += (const NodePathCollection &other) { + add_paths_from(other); +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePathCollection::operator + +// Access: Published +// Description: Returns a NodePathCollection representing the +// concatenation of the two lists. +//////////////////////////////////////////////////////////////////// +INLINE NodePathCollection NodePathCollection:: +operator + (const NodePathCollection &other) const { + NodePathCollection a(*this); + a += other; + return a; +} + //////////////////////////////////////////////////////////////////// // Function: NodePathCollection::ls // Access: Published diff --git a/panda/src/pgraph/nodePathCollection.h b/panda/src/pgraph/nodePathCollection.h index e9b4cf9952..11dba1e5e0 100644 --- a/panda/src/pgraph/nodePathCollection.h +++ b/panda/src/pgraph/nodePathCollection.h @@ -47,6 +47,8 @@ PUBLISHED: MAKE_SEQ(get_paths, get_num_paths, get_path); NodePath operator [] (int index) const; int size() const; + INLINE void operator += (const NodePathCollection &other); + INLINE NodePathCollection operator + (const NodePathCollection &other) const; // Handy operations on many NodePaths at once. INLINE void ls() const; diff --git a/panda/src/pgraph/textureCollection.I b/panda/src/pgraph/textureCollection.I index e6ed3a318f..fb871dd798 100644 --- a/panda/src/pgraph/textureCollection.I +++ b/panda/src/pgraph/textureCollection.I @@ -21,3 +21,26 @@ INLINE TextureCollection:: ~TextureCollection() { } + +//////////////////////////////////////////////////////////////////// +// Function: TextureCollection::operator += +// Access: Published +// Description: Appends the other list onto the end of this one. +//////////////////////////////////////////////////////////////////// +INLINE void TextureCollection:: +operator += (const TextureCollection &other) { + add_textures_from(other); +} + +//////////////////////////////////////////////////////////////////// +// Function: TextureCollection::operator + +// Access: Published +// Description: Returns a TextureCollection representing the +// concatenation of the two lists. +//////////////////////////////////////////////////////////////////// +INLINE TextureCollection TextureCollection:: +operator + (const TextureCollection &other) const { + TextureCollection a(*this); + a += other; + return a; +} diff --git a/panda/src/pgraph/textureCollection.h b/panda/src/pgraph/textureCollection.h index dc9f9458b8..7a7edbdbea 100644 --- a/panda/src/pgraph/textureCollection.h +++ b/panda/src/pgraph/textureCollection.h @@ -45,6 +45,8 @@ PUBLISHED: MAKE_SEQ(get_textures, get_num_textures, get_texture); Texture *operator [] (int index) const; int size() const; + INLINE void operator += (const TextureCollection &other); + INLINE TextureCollection operator + (const TextureCollection &other) const; void output(ostream &out) const; void write(ostream &out, int indent_level = 0) const; diff --git a/panda/src/pgraph/textureStageCollection.I b/panda/src/pgraph/textureStageCollection.I index 31b748b138..746f965b6d 100644 --- a/panda/src/pgraph/textureStageCollection.I +++ b/panda/src/pgraph/textureStageCollection.I @@ -21,3 +21,26 @@ INLINE TextureStageCollection:: ~TextureStageCollection() { } + +//////////////////////////////////////////////////////////////////// +// Function: TextureStageCollection::operator += +// Access: Published +// Description: Appends the other list onto the end of this one. +//////////////////////////////////////////////////////////////////// +INLINE void TextureStageCollection:: +operator += (const TextureStageCollection &other) { + add_texture_stages_from(other); +} + +//////////////////////////////////////////////////////////////////// +// Function: TextureStageCollection::operator + +// Access: Published +// Description: Returns a TextureStageCollection representing the +// concatenation of the two lists. +//////////////////////////////////////////////////////////////////// +INLINE TextureStageCollection TextureStageCollection:: +operator + (const TextureStageCollection &other) const { + TextureStageCollection a(*this); + a += other; + return a; +} diff --git a/panda/src/pgraph/textureStageCollection.h b/panda/src/pgraph/textureStageCollection.h index d8b7324c21..b13359c319 100644 --- a/panda/src/pgraph/textureStageCollection.h +++ b/panda/src/pgraph/textureStageCollection.h @@ -45,6 +45,8 @@ PUBLISHED: MAKE_SEQ(get_texture_stages, get_num_texture_stages, get_texture_stage); TextureStage *operator [] (int index) const; int size() const; + INLINE void operator += (const TextureStageCollection &other); + INLINE TextureStageCollection operator + (const TextureStageCollection &other) const; void sort(); diff --git a/panda/src/physics/physicsObjectCollection.I b/panda/src/physics/physicsObjectCollection.I index a1e2a65834..740f64db07 100755 --- a/panda/src/physics/physicsObjectCollection.I +++ b/panda/src/physics/physicsObjectCollection.I @@ -12,6 +12,7 @@ // //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// // Function: PhysicsObjectCollection::Destructor // Access: Published @@ -21,3 +22,25 @@ INLINE PhysicsObjectCollection:: ~PhysicsObjectCollection() { } +//////////////////////////////////////////////////////////////////// +// Function: PhysicsObjectCollection::operator += +// Access: Published +// Description: Appends the other list onto the end of this one. +//////////////////////////////////////////////////////////////////// +INLINE void PhysicsObjectCollection:: +operator += (const PhysicsObjectCollection &other) { + add_physics_objects_from(other); +} + +//////////////////////////////////////////////////////////////////// +// Function: PhysicsObjectCollection::operator + +// Access: Published +// Description: Returns a PhysicsObjectCollection representing the +// concatenation of the two lists. +//////////////////////////////////////////////////////////////////// +INLINE PhysicsObjectCollection PhysicsObjectCollection:: +operator + (const PhysicsObjectCollection &other) const { + PhysicsObjectCollection a(*this); + a += other; + return a; +} diff --git a/panda/src/physics/physicsObjectCollection.h b/panda/src/physics/physicsObjectCollection.h index 451e16ddc4..e2e2e4c993 100755 --- a/panda/src/physics/physicsObjectCollection.h +++ b/panda/src/physics/physicsObjectCollection.h @@ -46,6 +46,8 @@ PUBLISHED: MAKE_SEQ(get_physics_objects, get_num_physics_objects, get_physics_object); PT(PhysicsObject) operator [] (int index) const; int size() const; + INLINE void operator += (const PhysicsObjectCollection &other); + INLINE PhysicsObjectCollection operator + (const PhysicsObjectCollection &other) const; void output(ostream &out) const; void write(ostream &out, int indent_level = 0) const;