NOX::Parameter::Arbitrary Class Reference

Support for Arbitrary parameters. More...

#include <NOX_Parameter_Arbitrary.H>

Inheritance diagram for NOX::Parameter::Arbitrary:

[legend]
List of all members.

Public Member Functions

 Arbitrary ()
 Default Constructor.
virtual ~Arbitrary ()
 Destructor.
virtual Arbitraryclone () const =0
 Clone a exact replica of yourself and pass back a pointer.
virtual const string & getType () const =0
 Get a short descriptive string describing the Arbitrary object.
virtual ostream & print (ostream &stream, int indent=0) const
 Print out detailed information describing the Arbitrary object.

Detailed Description

Support for Arbitrary parameters.

Any object which derives from this class may be passed as a parameter via a NOX::Parameter::List.

For example, we include a very basic instantiation to support the passing of a vector<double> object.

class DoubleVectorParameter : public NOX::Parameter::Arbitrary {

public:

DoubleVectorParameter(const vector<double>& x) { v = x; } ;
~DoubleVectorParameter() {};
Arbitrary* clone() const { return new DoubleVectorParameter(v); };
const string& getType() const { return "Double Vector"; };
const vector<double>& getDoubleVector() const {return v;};

private:

vector<double> v;

};

This paramater would be stored in a parameter list as follows.

vector<double> x;

// .... Fill in x here ...

NOX::Parameter::List params;
params.setParameter("My List of Doubles", DoubleVectorParameter(x));

This parameter could later be accessed as follows.

function foo (NOX::Parameter::List& params)
{
  const NOX::Parameter::Arbitrary& a = params.getArbitraryParameter("My List of Doubles");
  const DoubleVectorParameter& d = dynamic_cast<const DoubleVectorParameter&>(a);
  vector<double> x = d.getDoubleVector();

  // ... Use x here ...
}

This is a very simplistic example of what one could do with an Arbitrary parameter. For example, even in this case we are likely doing far too much copying of the vectors. Ideally, we would use a shared_ptr object to store the object and not actually copy it every time we did a clone.


Member Function Documentation

virtual Arbitrary* NOX::Parameter::Arbitrary::clone  )  const [pure virtual]
 

Clone a exact replica of yourself and pass back a pointer.

It's left to the implementer to decide precisely how clone should function. The main requirement is that the cloned copy should still be valid even if the original is destroyed and even if multiple cloned copies exist.

Implemented in NOX::Parameter::AnyPtr, NOX::Parameter::DirectionConstructor, NOX::Parameter::DirectionConstructorT< T >, NOX::Parameter::LineSearchConstructor, NOX::Parameter::LineSearchConstructorT< T >, NOX::Parameter::Rcp, and NOX::EpetraNew::BroydenOperator.

virtual ostream& NOX::Parameter::Arbitrary::print ostream &  stream,
int  indent = 0
const [inline, virtual]
 

Print out detailed information describing the Arbitrary object.

Each line of output should be indented by the number of spaces specified by indent.

Reimplemented in NOX::Parameter::AnyPtr, NOX::Parameter::DirectionConstructor, NOX::Parameter::DirectionConstructorT< T >, NOX::Parameter::LineSearchConstructor, NOX::Parameter::LineSearchConstructorT< T >, and NOX::Parameter::Rcp.


The documentation for this class was generated from the following file:
Generated on Thu Sep 18 12:40:51 2008 for NOX by doxygen 1.3.9.1