#include <NOX_Parameter_Arbitrary.H>
Inheritance diagram for NOX::Parameter::Arbitrary:
Public Member Functions | |
| Arbitrary () | |
| Default Constructor. | |
| virtual | ~Arbitrary () |
| Destructor. | |
| virtual Arbitrary * | clone () 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. | |
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.
|
|
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::DirectionConstructor, NOX::Parameter::DirectionConstructorT< T >, NOX::Parameter::LineSearchConstructor, NOX::Parameter::LineSearchConstructorT< T >, and NOX::EpetraNew::BroydenOperator. |
|
||||||||||||
|
Print out detailed information describing the Arbitrary object.
Each line of output should be indented by the number of spaces specified by Reimplemented in NOX::Parameter::DirectionConstructor, NOX::Parameter::DirectionConstructorT< T >, NOX::Parameter::LineSearchConstructor, and NOX::Parameter::LineSearchConstructorT< T >. |
1.3.9.1