Skip to content

Commit

Permalink
works
Browse files Browse the repository at this point in the history
  • Loading branch information
sahrkm committed Oct 24, 2023
1 parent db82666 commit 888dec1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
42 changes: 41 additions & 1 deletion src/lib/dglib/include/dglib/DgDataField.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DgDistanceBase;

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
template <class T> class DgDataField : public DgDataFieldBase {
template <typename T> class DgDataField : public DgDataFieldBase {

public:

Expand All @@ -58,8 +58,46 @@ template <class T> class DgDataField : public DgDataFieldBase {
{ return stream << value_; }

T value_;

};

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
template<>
class DgDataField<long int> : public DgDataFieldBase {

public:

DgDataField (void) {}
DgDataField (string _name, DgDataType _type, long int _value)
: DgDataFieldBase (_name, _type), value_ (_value)
{ }

void setValue (const long int& value) { value_ = value; }

long int& value (void) { return value_; }
const long int& value (void) const { return value_; }

virtual string valString (void) const {
return dgg::util::to_string(value_);
}

#ifdef USE_GDAL
virtual void setField (OGRFeature* feature) const
{ GIntBig v = value();
feature->SetField(name().c_str(), v); }
#endif

protected:

virtual ostream& writeTo (ostream& stream) const
{ return stream << value_; }

long int value_;

};

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
class DgDataFieldDouble : public DgDataField<double> {

Expand Down Expand Up @@ -163,6 +201,8 @@ class DgDataFieldString : public DgDataField<char*> {
};

////////////////////////////////////////////////////////////////////////////////
//template class DgDataField<long int>;

////////////////////////////////////////////////////////////////////////////////

#endif
3 changes: 1 addition & 2 deletions src/lib/dglib/include/dglib/DgDataFieldBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ class DgDataFieldBase {

public:

DgDataFieldBase (string _name = "value",
DgDataType _fieldType = FIELD_DOUBLE)
DgDataFieldBase (string _name, DgDataType _fieldType = FIELD_DOUBLE)
: name_ (_name), fieldType_ (_fieldType)
{ }

Expand Down

0 comments on commit 888dec1

Please sign in to comment.