25 #define RDBColumnTmplt_cc 27 #include <rdbxx/RDBColumnTmplt.h> 36 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
57 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
75 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
91 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
107 if ( _group && 2 > _nelems )
108 throw(
RDBErr(
"RDBColumnTmplt::operator=(RDBColumnTmplt&): user supplied column must provide >= 2 data elements" ) );
122 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
129 convert( data, _data[_idx] );
131 }
catch (
RDBErr& rdberr ) {
132 rdberr.set_message(
"RDBColumnTmplt::operator=(Tmplt0&): " );
136 throw(
RDBErr(
"RDBColumnTmplt::operator=(Tmplt0&): unexpected exception caught" ) );
153 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
160 convert( data, _data[_idx] );
162 }
catch (
RDBErr& rdberr ) {
163 rdberr.set_message(
"RDBColumnTmplt::operator=(Tmplt1&): " );
167 throw(
RDBErr(
"RDBColumnTmplt::operator=(Tmplt1&): unexpected exception caught" ) );
184 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
191 convert( data, _data[_idx] );
193 }
catch (
RDBErr& rdberr ) {
194 rdberr.set_message(
"RDBColumnTmplt::operator=(Tmplt2&): " );
198 throw(
RDBErr(
"RDBColumnTmplt::operator=(Tmplt2&): unexpected exception caught" ) );
210 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
216 if ( _nelems == ++_idx ) {
226 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
240 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
251 _data =
new Tmplt0[_nelems];
252 _data[0] = tmp[_idx];
253 _data[1] = tmp[_idx];
256 }
else if ( 2 > _nelems ) {
257 throw(
RDBErr(
"RDBColumnTmplt::setGroup(bool): user supplied column must provide >= 2 data elements" ) );
266 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
273 _data[(_idx+1)%_nelems] = _groupvalue;
274 _groupvalue = _data[_idx];
283 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
292 _data[_idx] = _groupvalue;
293 _groupvalue = _data[(_idx+1)%_nelems];
294 return RDBColumn::CBOG;
297 int status = RDBColumn::CMOG;
299 if ( _data[_idx] != _groupvalue )
300 status |= RDBColumn::CBOG;
302 if ( _data[_idx] != _data[(_idx+1)%_nelems] )
303 status |= RDBColumn::CEOG;
305 _groupvalue = _data[_idx];
311 return RDBColumn::CMOG;
341 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
348 convert( data, _data[_idx] );
350 }
catch (
RDBErr& rdberr ) {
351 rdberr.set_message(
"RDBColumnTmplt::setData(Tmplt0&): " );
355 throw(
RDBErr(
"RDBColumnTmplt::setData(Tmplt0&): unexpected exception caught" ) );
374 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
381 convert( data, _data[_idx] );
383 }
catch (
RDBErr& rdberr ) {
384 rdberr.set_message(
"RDBColumnTmplt::setData(Tmplt1&): " );
388 throw(
RDBErr(
"RDBColumnTmplt::setData(Tmplt1&): unexpected exception caught" ) );
407 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
414 convert( data, _data[_idx] );
416 }
catch (
RDBErr& rdberr ) {
417 rdberr.set_message(
"RDBColumnTmplt::setData(Tmplt2&): " );
421 throw(
RDBErr(
"RDBColumnTmplt::setData(Tmplt2&): unexpected exception caught" ) );
438 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
449 _idx = _idx % _nelems;
452 if ( _group && 2 > _nelems )
453 throw(
RDBErr(
"RDBColumnTmplt::mapData: user supplied data must provide >= 2 data elements" ) );
464 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
470 return ((
void *) &_data[_idx]);
482 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
489 convert( _data[_idx], data );
491 }
catch (
RDBErr& rdberr ) {
492 rdberr.set_message(
"RDBColumnTmplt::getData(Tmplt0&): " );
496 throw(
RDBErr(
"RDBColumnTmplt::getData(Tmplt0&): unexpected exception caught" ) );
515 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
522 convert( _data[_idx], data );
524 }
catch (
RDBErr& rdberr ) {
525 rdberr.set_message(
"RDBColumnTmplt::getData(Tmplt1&): " );
529 throw(
RDBErr(
"RDBColumnTmplt::getData(Tmplt1&): unexpected exception caught" ) );
548 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
555 convert( _data[_idx], data );
557 }
catch (
RDBErr& rdberr ) {
558 rdberr.set_message(
"RDBColumnTmplt::getData(Tmplt2&): " );
562 throw(
RDBErr(
"RDBColumnTmplt::getData(Tmplt2&): unexpected exception caught" ) );
576 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
584 convert( _data[_idx], odata );
586 }
catch (
RDBErr& rdberr ) {
587 rdberr.set_message(
"RDBColumnTmplt::getDataDouble(void): " );
591 throw(
RDBErr(
"RDBColumnTmplt::getDataDouble(void): unexpected exception caught" ) );
606 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
614 convert( _data[_idx], odata );
616 }
catch (
RDBErr& rdberr ) {
617 rdberr.set_message(
"RDBColumnTmplt::getDataLong(void): " );
621 throw(
RDBErr(
"RDBColumnTmplt::getDataLong(void): unexpected exception caught" ) );
633 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
641 convert( _data[_idx], odata );
643 }
catch (
RDBErr& rdberr ) {
644 rdberr.set_message(
"RDBColumnTmplt::getDataString(void): " );
648 throw(
RDBErr(
"RDBColumnTmplt::getDataString(void): unexpected exception caught" ) );
664 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
671 extract( is, _data[_idx] );
673 }
catch (
RDBErr& rdberr ) {
674 rdberr.set_message(
"RDBColumnTmplt::read(istream&): " );
678 throw(
RDBErr(
"RDBColumnTmplt::read(istream&): unexpected exception caught" ) );
694 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
700 return insert( os, _data[_idx] );
708 template<
class Tmplt0,
class Tmplt1,
class Tmplt2>
714 if ( _mine && _data ) {
virtual istream & read(istream &is)
Called by the stream insertion operator.
virtual string getDataString(void)
Returns the value of the current data element, converting if necessary.
RDBColumn & operator=(const RDBColumn &col)
Copies RDBColumn object.
Tmplt0 * _data
Pointer to the data managed by object.
virtual void mapData(Tmplt0 data[], const size_t nelems)
Maps data to user-supplied memory.
virtual void rewind(void)
Rewinds index to the RDBColumn's data elements.
The parent class for all RDB related exceptions.
virtual bool setData(const Tmplt0 &data)
Sets the data value, converting as necessary.
void cleanup(void)
Deletes resources allocated by RDBColumnTmplt object.
virtual void setGroup(bool group)
Turn on/off group tracking for this column object.
bool _mine
Indicates that RDBColumnTmplt is responsible for deallocating the data.
void * getData(void)
Returns a pointer to the current data element.
size_t _idx
Index into the data.
~RDBColumnTmplt(void)
Deletes resources allocated by RDBColumnTmplt object.
RDBColumnTmplt(const string &name="", const string &def="")
Assigns name and definition.
virtual long getDataLong(void)
Returns the value of the current data element, converting if necessary.
virtual double getDataDouble(void)
Returns the value of the current data element, converting if necessary.
RDBColumn & operator=(const RDBColumnTmplt< Tmplt0, Tmplt1, Tmplt2 > &rdbcolumntmplt)
Copies RDBColumnTmplt object.
virtual void setGroup(bool group)
size_t _nelems
Number of elements of data.
virtual void advanceIdx(void)
Increments index to the RDBColumn's data elements.
virtual int newGroup(void)
Returns the group status of this column object.
virtual void setGroupValue(void)
Sets the group value to the current data value.
virtual ostream & write(ostream &os) const
Called by the stream extraction operator.
Parameterizes RDBColumn interface for many data types.
Provides interface for general column related methods.