[Opentrep-svn] SF.net SVN: opentrep:[154] trunk/opentrep/opentrep
Status: Beta
Brought to you by:
denis_arnaud
From: <den...@us...> - 2009-07-21 05:54:19
|
Revision: 154 http://opentrep.svn.sourceforge.net/opentrep/?rev=154&view=rev Author: denis_arnaud Date: 2009-07-21 05:54:17 +0000 (Tue, 21 Jul 2009) Log Message: ----------- [Dev] Added a structure for the scale of distance errors. Modified Paths: -------------- trunk/opentrep/opentrep/OPENTREP_Service.hpp trunk/opentrep/opentrep/sources.mk Added Paths: ----------- trunk/opentrep/opentrep/DistanceErrorRule.hpp Added: trunk/opentrep/opentrep/DistanceErrorRule.hpp =================================================================== --- trunk/opentrep/opentrep/DistanceErrorRule.hpp (rev 0) +++ trunk/opentrep/opentrep/DistanceErrorRule.hpp 2009-07-21 05:54:17 UTC (rev 154) @@ -0,0 +1,98 @@ +#ifndef __OPENTREP_DISTANCEERRORRULE_HPP +#define __OPENTREP_DISTANCEERRORRULE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <istream> +#include <ostream> +#include <string> +#include <map> +// OpenTrep +#include <opentrep/OPENTREP_Types.hpp> +#include <opentrep/OPENTREP_Abstract.hpp> + +namespace OPENTREP { + + /** Number of letters in a word or phrase. */ + typedef unsigned int NbOfLetters_T; + + /** Number of errors. */ + typedef unsigned short NbOfErrors_T; + + /** List of names for a given (geographical) distanceerrorrule. */ + typedef std::map<NbOfLetters_T, NbOfErrors_T> DistanceErrorScale_T; + + + /** Structure modelling a (geographical) distanceerrorrule. */ + struct DistanceErrorRule : public OPENTREP_Abstract { + public: + // ///////// Getters //////// + /** Get the DistanceErrorRule code. */ + const DistanceErrorScale_T& getDistanceErrorScale() const { + return _scale; + } + + + // ///////// Setters ////////// + + + public: + // ///////// Display methods //////// + /** Dump a structure into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const { + ioOut << toString(); + } + + /** Read a structure from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream&) { + } + + /** Get a short display of the DistanceErrorRule structure. */ + std::string toShortString() const { + std::ostringstream oStr; + NbOfLetters_T idx = 0; + for (DistanceErrorScale_T::const_iterator itError = _scale.begin(); + itError != _scale.end(); ++itError, ++idx) { + if (idx != 0) { + oStr << ", "; + } + oStr << itError->second << ": " << itError->first; + } + return oStr.str(); + } + + /** Get the serialised version of the DistanceErrorRule structure. */ + std::string toString() const { + std::ostringstream oStr; + oStr << toShortString(); + return oStr.str(); + } + + + public: + /** Main Constructor. */ + DistanceErrorRule (const DistanceErrorScale_T& iScale) + : _scale (iScale) { + } + + /** Default Constructor. */ + // DistanceErrorRule (); + /** Default copy constructor. */ + // DistanceErrorRule (const DistanceErrorRule&); + + /** Destructor. */ + virtual ~DistanceErrorRule() {} + + + private: + // /////// Attributes ///////// + /** Scale of distance errors. */ + DistanceErrorScale_T _scale; + }; + +} +#endif // __OPENTREP_DISTANCEERRORRULE_HPP Modified: trunk/opentrep/opentrep/OPENTREP_Service.hpp =================================================================== --- trunk/opentrep/opentrep/OPENTREP_Service.hpp 2009-07-20 22:41:55 UTC (rev 153) +++ trunk/opentrep/opentrep/OPENTREP_Service.hpp 2009-07-21 05:54:17 UTC (rev 154) @@ -11,6 +11,7 @@ #include <opentrep/OPENTREP_Types.hpp> #include <opentrep/DBParams.hpp> #include <opentrep/Location.hpp> +#include <opentrep/DistanceErrorRule.hpp> namespace OPENTREP { Modified: trunk/opentrep/opentrep/sources.mk =================================================================== --- trunk/opentrep/opentrep/sources.mk 2009-07-20 22:41:55 UTC (rev 153) +++ trunk/opentrep/opentrep/sources.mk 2009-07-21 05:54:17 UTC (rev 154) @@ -3,5 +3,6 @@ $(top_srcdir)/opentrep/OPENTREP_Abstract.hpp \ $(top_srcdir)/opentrep/DBParams.hpp \ $(top_srcdir)/opentrep/Location.hpp \ + $(top_srcdir)/opentrep/DistanceErrorRule.hpp \ $(top_srcdir)/opentrep/OPENTREP_Service.hpp service_cc_sources = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |