SourceForge.net Logo timeSeries: timeSeries Class Library

BadType Class Reference
[timeSeries objects]

Type mismatch during construction. More...

#include <tsExceptions.h>

Inherits tsException.

Collaboration diagram for BadType:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 BadType (std::string nm, std::string type1, std::string type2)
void debug_print ()

Detailed Description

Type mismatch during construction.

Thrown when an attempt is made to construct a timeSeries object of one type from a data field containing another type. Implicit conversion in constructors is disallowed to ensure that the resulting memory and performance penalty does not occur without explicit authorization from the programmer. The same result can always be obtained by constructing a timeSeries object of the correct type and using an explicit conversion operator.


Constructor & Destructor Documentation

BadType::BadType ( std::string  nm,
std::string  type1,
std::string  type2 
) [inline]
Parameters:
nm the name of the object
type1 a string designating the type of timeSeries object
type2 a string designating the type of the underlying data

The information used to construct the BadType exception can be used by the debug_print method to generate readable error messages for the user


Member Function Documentation

void BadType::debug_print (  )  [inline, virtual]

error message

Example:

If the data definition (as determined in the .hdr or .dfm file) for field EFFORT specifies a type of "float" then the following code will generate a BadType exception:

        try {
            timeSeries<int> effort_int("EFFORT",data);
        }
        catch (tsException& tse) {
            tse.debug_print();
            cerr << "skipping to next file..." << endl;
        }

Results in this error message:

		Illegal Conversion: attempt to construct timeSeries object of type int
		 from data field "EFFORT" of type float
		skipping to next file...
		

The same effect can be achieved explicitly without causing an exception:

        timeSeries<float> effort_float("EFFORT",data);
        timeSeries<int> effort = timeSeries<int>(effort_float);

Reimplemented from tsException.

Generated on Tue Mar 16 15:10:52 2010 for timeSeries by  doxygen 1.6.3