ErrorSource Class Reference

ErrorSource is a common base for all classes that post row exceptions to an ErrorTarget. More...

#include <ErrorSource.h>

Inheritance diagram for ErrorSource:

ExecStream JavaTransformExecStream SingleInputExecStream SingleOutputExecStream ConduitExecStream DiffluenceExecStream JavaSinkExecStream MockConsumerExecStream BTreeExecStream ConduitExecStream ConfluenceExecStream FlatFileExecStream MockProducerExecStream MockResourceExecStream ValuesExecStream List of all members.

Public Member Functions

virtual ~ErrorSource ()
virtual void initErrorSource (SharedErrorTarget pErrorTarget, const std::string &name)
 For use when initialization has to be deferred until after construction.
void postError (ErrorLevel level, const std::string &message, void *address, long capacity, int index)
 Posts an exception, such as a row exception.
void postError (ErrorLevel level, const std::string &message, const TupleDescriptor &errorDesc, const TupleData &errorTuple, int index)
 Posts an exception, such as a row exception.
bool hasTarget () const
 
Returns:
true iff an error target has been set

ErrorTargetgetErrorTarget () const
 
Returns:
the ErrorTarget for this source

SharedErrorTarget getSharedErrorTarget () const
 
Returns:
the SharedErrorTarget for this source

std::string getErrorSourceName () const
 Gets the name of this source.
void setErrorSourceName (std::string const &n)
 Sets the name of this source.
void disableTarget ()

Protected Member Functions

 ErrorSource ()
 Constructs a new uninitialized ErrorSource.
 ErrorSource (SharedErrorTarget pErrorTarget, const std::string &name)
 Constructs a new ErrorSource.

Private Attributes

SharedErrorTarget pErrorTarget
std::string name
TupleAccessor errorAccessor
 Tuple accessor for error records handed by this error source.
boost::shared_ptr< FixedBufferpErrorBuf
 A buffer for error records.

Detailed Description

ErrorSource is a common base for all classes that post row exceptions to an ErrorTarget.

An ErrorSource generally corresponds to an ExecStream. Fennel data is typiclly interpreted as external data via separate metadata, so it is usually required for an ErrorSource to be preregistered with the external system. (For example, a Fennel long might map to a decimal or datetime type.)

Definition at line 42 of file ErrorSource.h.


Constructor & Destructor Documentation

ErrorSource::ErrorSource (  )  [explicit, protected]

Constructs a new uninitialized ErrorSource.

Definition at line 29 of file ErrorSource.cpp.

References pErrorTarget.

00030 {
00031     pErrorTarget.reset();
00032 }

ErrorSource::ErrorSource ( SharedErrorTarget  pErrorTarget,
const std::string &  name 
) [explicit, protected]

Constructs a new ErrorSource.

Parameters:
pErrorTarget the ErrorTarget to which errors will be posted, or NULL to ignore errors.
name the unique name of this source, such as the name of a Fennel ExecStream

Definition at line 34 of file ErrorSource.cpp.

References initErrorSource(), and pErrorTarget.

00037 {
00038     pErrorTarget.reset();
00039     initErrorSource(pErrorTargetInit, nameInit);
00040 }

ErrorSource::~ErrorSource (  )  [virtual]

Definition at line 42 of file ErrorSource.cpp.

References pErrorTarget.

00043 {
00044     pErrorTarget.reset();
00045 }


Member Function Documentation

void ErrorSource::initErrorSource ( SharedErrorTarget  pErrorTarget,
const std::string &  name 
) [virtual]

For use when initialization has to be deferred until after construction.

Parameters:
pErrorTarget the ErrorTarget to which errors will be posted
name the name of this source

Definition at line 47 of file ErrorSource.cpp.

References name, and pErrorTarget.

Referenced by ErrorSource().

00050 {
00051     pErrorTarget = pErrorTargetInit;
00052     name = nameInit;
00053 }

void ErrorSource::postError ( ErrorLevel  level,
const std::string &  message,
void *  address,
long  capacity,
int  index 
)

Posts an exception, such as a row exception.

See also:
ErrorTarget for a description of the parameters

Definition at line 55 of file ErrorSource.cpp.

References getErrorTarget(), hasTarget(), name, and ErrorTarget::notifyError().

Referenced by FlatFileExecStreamImpl::logError(), postError(), and LbmSplicerExecStream::postViolation().

00058 {
00059     if (hasTarget()) {
00060         getErrorTarget().notifyError(
00061             name, level, message, address, capacity, index);
00062     }
00063 }

void ErrorSource::postError ( ErrorLevel  level,
const std::string &  message,
const TupleDescriptor errorDesc,
const TupleData errorTuple,
int  index 
)

Posts an exception, such as a row exception.

See also:
ErrorTarget for a description of the parameters

Definition at line 65 of file ErrorSource.cpp.

References TupleAccessor::compute(), errorAccessor, FixedBuffer, TupleAccessor::getByteCount(), TupleAccessor::getMaxByteCount(), hasTarget(), TupleAccessor::marshal(), pErrorBuf, and postError().

00068 {
00069     if (!hasTarget()) {
00070         return;
00071     }
00072 
00073     if (!pErrorBuf) {
00074         errorAccessor.compute(errorDesc);
00075         uint cbMax = errorAccessor.getMaxByteCount();
00076         pErrorBuf.reset(new FixedBuffer[cbMax]);
00077     }
00078 
00079     uint cbTuple = errorAccessor.getByteCount(errorTuple);
00080     errorAccessor.marshal(errorTuple, pErrorBuf.get());
00081     postError(level, message, pErrorBuf.get(), cbTuple, index);
00082 }

bool ErrorSource::hasTarget (  )  const [inline]

Returns:
true iff an error target has been set

Definition at line 112 of file ErrorSource.h.

Referenced by postError().

00113     {
00114         return pErrorTarget.get() ? true : false;
00115     }

ErrorTarget& ErrorSource::getErrorTarget (  )  const [inline]

Returns:
the ErrorTarget for this source

Definition at line 120 of file ErrorSource.h.

Referenced by postError().

00121     {
00122         assert(hasTarget());
00123         return *(pErrorTarget.get());
00124     }

SharedErrorTarget ErrorSource::getSharedErrorTarget (  )  const [inline]

Returns:
the SharedErrorTarget for this source

Definition at line 129 of file ErrorSource.h.

00130     {
00131         return pErrorTarget;
00132     }

std::string ErrorSource::getErrorSourceName (  )  const [inline]

Gets the name of this source.

Useful to construct nested names for subcomponents that are also ErrorSources.

Returns:
the name

Definition at line 139 of file ErrorSource.h.

00140     {
00141         return name;
00142     }

void ErrorSource::setErrorSourceName ( std::string const &  n  )  [inline]

Sets the name of this source.

Useful to construct dynamic names for fine-grained filtering.

Definition at line 148 of file ErrorSource.h.

00149     {
00150         name = n;
00151     }

void ErrorSource::disableTarget (  ) 

Definition at line 84 of file ErrorSource.cpp.

References pErrorTarget.

00085 {
00086     pErrorTarget.reset();
00087 }


Member Data Documentation

SharedErrorTarget ErrorSource::pErrorTarget [private]

Definition at line 44 of file ErrorSource.h.

Referenced by disableTarget(), ErrorSource(), initErrorSource(), and ~ErrorSource().

std::string ErrorSource::name [private]

Reimplemented in ExecStream.

Definition at line 45 of file ErrorSource.h.

Referenced by initErrorSource(), and postError().

TupleAccessor ErrorSource::errorAccessor [private]

Tuple accessor for error records handed by this error source.

Definition at line 50 of file ErrorSource.h.

Referenced by postError().

boost::shared_ptr<FixedBuffer> ErrorSource::pErrorBuf [private]

A buffer for error records.

Definition at line 55 of file ErrorSource.h.

Referenced by postError().


The documentation for this class was generated from the following files:
Generated on Mon Jun 22 04:00:30 2009 for Fennel by  doxygen 1.5.1