OpenSceneGraph/include/osgParticle/ModularProgram
2002-06-06 13:25:36 +00:00

91 lines
2.6 KiB
Plaintext

//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
//Distributed under the terms of the GNU Library General Public License (LGPL)
//as published by the Free Software Foundation.
//osgParticle - Copyright (C) 2002 Marco Jez
#ifndef OSGPARTICLE_MODULARPROGRAM_
#define OSGPARTICLE_MODULARPROGRAM_ 1
#include <osgParticle/Export>
#include <osgParticle/Program>
#include <osgParticle/Operator>
#include <osg/CopyOp>
#include <osg/Object>
#include <osg/Node>
#include <osg/NodeVisitor>
namespace osgParticle
{
/** A program class for performing operations on particles using a sequence of <I>operators</I>.
To use a <CODE>ModularProgram</CODE> you have to create some <CODE>Operator</CODE> objects and
add them to the program.
All operators will be applied to each particle in the same order they've been added to the program.
*/
class OSGPARTICLE_EXPORT ModularProgram: public Program {
public:
ModularProgram();
ModularProgram(const ModularProgram &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
META_Node(osgParticle,ModularProgram);
/// Get the number of operators.
inline int numOperators() const;
/// Add an operator to the list.
inline void addOperator(Operator *o);
/// Get a pointer to an operator in the list.
inline Operator *getOperator(int i);
/// Get a const pointer to an operator in the list.
inline const Operator *getOperator(int i) const;
/// Remove an operator from the list.
inline void removeOperator(int i);
protected:
virtual ~ModularProgram() {}
ModularProgram &operator=(const ModularProgram &) { return *this; }
void execute(double dt);
private:
typedef std::vector<osg::ref_ptr<Operator> > Operator_vector;
Operator_vector operators_;
};
// INLINE FUNCTIONS
inline int ModularProgram::numOperators() const
{
return static_cast<int>(operators_.size());
}
inline void ModularProgram::addOperator(Operator *o)
{
operators_.push_back(o);
}
inline Operator *ModularProgram::getOperator(int i)
{
return operators_[i].get();
}
inline const Operator *ModularProgram::getOperator(int i) const
{
return operators_[i].get();
}
inline void ModularProgram::removeOperator(int i)
{
operators_.erase(operators_.begin()+i);
}
}
#endif