idaeim studio
 PVL: Parameter Value Language

Public Member Functions
Assignment Class Reference

An Assignment implements a Parameter than contains a Value. More...

#include <Parameter.hh>

Inheritance diagram for Assignment:
Inheritance graph
[legend]
Collaboration diagram for Assignment:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Assignment (const std::string name="")
 Constructs an Assignment with a Default_Value.
 Assignment (const Assignment &assignment)
 Copy constructor.
 Assignment (Parser &parser, const std::string name="")
 Construct an Assignment from a Parser.
 Assignment (const Parameter &parameter)
 Copy constructor from a Parameter.
Assignmentclone () const
 Clones the Assignment by making a copy of itself.
int compare (const Parameter &parameter) const
 Compares this Assignment with another Parameter.
bool is (const Type type) const
 Test if the Parameter is of some Type.
bool is_Assignment () const
 Test if this is an Assignment.
bool is_Token () const
 Test if this is a token Parameter.
Assignmentoperator= (const Value &value)
 Assigns a Value to this Assignment.
Assignmentoperator= (const Parameter &parameter)
 Assigns a Parameter to this Assignment.
void read (Parser &parser)
 Assigns the next Parameter from a Parser to this Parameter.
void read (std::istream &in=std::cin)
 Reads an input stream parsed as PVL syntax into this Assignment.
Type type () const
 Gets the Type specification.
Assignmenttype (const int type)
 Sets the Type specification.
std::string type_name () const
 Gets the name for this Assignment's Type specification.
Valuevalue () const
 Gets the Value of the Assignment.
 ~Assignment ()
 Destructor: deletes the Assignment's Value.

Detailed Description

An Assignment implements a Parameter than contains a Value.

The Assignment class is very lightweight: Objects of this class only add the Type specification code and a pointer to the assigned Value obect to the base Parameter class characteristics. No new methods beyond those declared for the base Parameter class for implmentation or override are defined here.


Constructor & Destructor Documentation

Assignment ( const std::string  name = "") [explicit]

Constructs an Assignment with a Default_Value.

Parameters:
nameThe Parameter name string.
Assignment ( const Assignment assignment)

Copy constructor.

Copies the Type specification and clones the Value.

Parameters:
assignmentThe Assignment Parameter to be copied.
Assignment ( const Parameter parameter)

Copy constructor from a Parameter.

Parameters:
parameterThe Parameter to be copied.
Exceptions:
Invalid_ArgumentIf the Parameter to be copied is not an Assignment. The resulting Assignment is valid, but it will have a NULL Value.
Assignment ( Parser parser,
const std::string  name = "" 
)

Construct an Assignment from a Parser.

A single Assignment is read using the Paser's get_parameter method. If a valid Assignment Parameter is obtained from the Parser it is assigned to this newly constructed Assignment Parameter. Otherwise this Assignement is given the TOKEN Type specification and a Default_Value.

If a non-empty name is specified, the new Parameter is given that name.

Parameters:
parserThe Parser from which to read an Assignment definition.
nameA name for the new Parameter. [Default: the name of the parsed Parameter, or ""]
See also:
Parser::get_parameter(bool)
~Assignment ( ) [inline]

Destructor: deletes the Assignment's Value.


Member Function Documentation

Assignment* clone ( ) const [inline, virtual]

Clones the Assignment by making a copy of itself.

Returns:
A pointer to a copy of this Assignment.
See also:
Assignment::Assignment(const Assignment&)

Implements Parameter.

References Parameter::Assignment.

bool is_Assignment ( ) const [inline, virtual]

Test if this is an Assignment.

Returns:
Always returns true.

Reimplemented from Parameter.

bool is_Token ( ) const [inline, virtual]

Test if this is a token Parameter.

A token Parameter is an Assignment without an effective Value.

Returns:
true if the Type specification is TOKEN.

Reimplemented from Parameter.

References Parameter::TOKEN.

bool is ( const Type  type) const [inline]

Test if the Parameter is of some Type.

The test is the logical AND of the Parameter Subtype and the specified Type value. Thus, conceptually, the test is if the Parameter is any one of a possible combination of Types. For example, parameter.is (GROUP| OBJECT) will be false for any ASSIGNMENT parameter, which could just as easily be tested by parameter.is (AGGREGATE); and parameter.is (ASSIGNMENT | AGGREGATE) can be expected to always be true.

Parameters:
typeThe Type specification code against which to test the Parameter.
Returns:
true if the implementing class is of the specified Type. an OBJECT Type specification; false otherwise.

References Parameter::type().

Type type ( ) const [inline, virtual]

Gets the Type specification.

Returns:
This should be either the ASSIGNMENT or TOKEN code.

Implements Parameter.

Assignment& type ( const int  type) [virtual]

Sets the Type specification.

If the Type specification is ASSIGNMENT or TOKEN, then it applies to this Assignment. Otherwise the value is passed to the Assignment's Value.

Parameters:
typeThe Type specification for the Assignment or its Value.
Returns:
This Assignment.
Exceptions:
Invalid_ArgumentIf the type value is not valid for an an Assignment nor a Value.

Implements Parameter.

std::string type_name ( ) const [inline, virtual]

Gets the name for this Assignment's Type specification.

Returns:
The name string associated with the Assignment's Type specification.
See also:
Parameter::type_name(Type)

Implements Parameter.

References Parameter::type_name().

Value& value ( ) const [inline, virtual]

Gets the Value of the Assignment.

Returns:
A reference to the Assignment's Value.

Implements Parameter.

Assignment& operator= ( const Parameter parameter) [virtual]

Assigns a Parameter to this Assignment.

If the Parameter is an Assignment its name, comment and Type specification are copied, but not its parent. It's Value is cloned and replaces this Assignment's Value, which is deleted.

Nothing is done when assigning a Parameter to itself.

Parameters:
parameterThe Parameter to be assigned.
Returns:
This Assignment.
Exceptions:
Invalid_Argumentif the Parameter is not an Assignment.

Implements Parameter.

Assignment& operator= ( const Value value) [virtual]

Assigns a Value to this Assignment.

The current Value is deleted and the new value is cloned in its place. The Type specification is set to ASSIGNMENT.

Parameters:
valueThe Value to be assigned.
Returns:
This Assignment.

Implements Parameter.

int compare ( const Parameter parameter) const [virtual]

Compares this Assignment with another Parameter.

A Parameter compared with itself is, of course, identical.

The Parameter names are compared and, if they are different, the result of this comparison is returned.

When the Parameter names are the same, an Assignment is less than an Aggregate, and a TOKEN is less than an ASSIGNMENT.

When all else is the same (regardless of any comment) the result of comparing the Values is returned.

Parameters:
parameterThe Parameter to compare against.
Returns:
An int that is less than, equal to, or greater than 0 if this Assignment is logically less than, equal to, or greater than, respectively, the other Parameter.

Implements Parameter.

void read ( std::istream &  in = std::cin) [virtual]

Reads an input stream parsed as PVL syntax into this Assignment.

A Parser is constructed from the input stream and passed to the read(Parser&) method. A single Assignment Parameter is parsed from the input stream

Parameters:
inThe istream to be parsed for PVL syntax.

Implements Parameter.

void read ( Parser parser) [virtual]

Assigns the next Parameter from a Parser to this Parameter.

A single Assignment Parameter is obtained from the Parser and assigned to this Parameter. If no Assignment Parameter is obtained from the Parser, this Assignment Parameter remains unchanged.

N.B: Only an Assignment Parameter will be parsed even if the PVL syntax contains a name for the next parameter that is a special_type keyword. Thus, for example, where the PVL syntax defines a GROUP parameter which begins an Aggregate Parameter an Assignment Parameter will be obtained instead which will be named "GROUP" having a value that would otherwise be the name of the Aggregate Parameter. Similarly, where the end of PVL syntax is marked a TOKEN Assignment named "END" will be obtained instead. As a result it is possible for subsequent operations of the Parser to become confused about the structural context of the PVL syntax having lost track of a structural marker parameter. This method should only be used when direct, individual processing of each parameter defined in the PVL syntax is intended. In most cases use of the Parser::get_parameter method is preferable.

Parameters:
parserThe Parser from which to obtain a Parameter.
See also:
Parser::get_parameter(bool)
special_type

Implements Parameter.


The documentation for this class was generated from the following file: