/** \file
 *
 *  Contains the SimpleDataElement class definition.
 *
 *  Copyright (c) 2007,2008,2009 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 *
 */

#ifndef SIMPLEDATAELEMENT_H_
#define SIMPLEDATAELEMENT_H_

#include "DataElement.h"

/**
 *  A "Simple" DataElement.
 *
 *  Actually, this should be called a "normal" data element, which
 *  should make up the bulk of the slate.  Contains a single
 *  DataValue.
 *
 *  \ingroup data
 */
class SimpleDataElement : public DataElement
{
public:
    /// Constructor for a "Simple" DataElement.
    ///
    /// \param name The unique ElementURI of the element.
    /// \param initialValue The initial/default value for the element.
    /// \param accuracy The initial/default accuracy for the element.
    SimpleDataElement( const ElementURI& name,
                       DataValue* initialValue,
                       float accuracy );

    /// Destructor.
    virtual ~SimpleDataElement();

    /// Get the DataValue for this DataElement.
    /// Implements the pure virtual from DataElement.
    ///
    /// \return Pointer to the the DataValue.
    virtual DataValue* getDataValue( void ) const;

    /// Get the current DataElement accuracy.
    /// Implements the pure virtual from DataElement.
    ///
    /// \return Current accuracy metric for this DataValue.
    virtual float getAccuracy( const Unit& unit ) const
#ifndef __GAZEBO
    throw( UninitializedException )
#endif
    ;
    virtual float getAccuracySI() const
#ifndef __GAZEBO
    throw( UninitializedException )
#endif
    ;

    /// Set the current DataElement accuracy
    /// Implements the pure virtual from DataElement.
    ///
    /// \param unit Unit in which the new accuracy value is expressed.
    /// \param accuracy The new accuracy value.
    /// \return The current accuracy (should be the new accuracy)
    virtual float setAccuracy( const Unit& unit, float accuracy );


protected:

    /// The DataValue for this DataElement.
    DataValue* value_;

    /// The accuracy for this DataElement.
    float accuracy_;

    /// Returns the accuracy in base, unscaled SI units.
    virtual float getBaseAccuracy() const
    {
        return accuracy_;
    }

    virtual void setDataValue( DataValue* dataValue );

private:
    // Note that the copy constructor below is private and not given a body.
    // Any attempt to call it will return a compiler error.
    SimpleDataElement( const SimpleDataElement& old ); // disallow copy constructor

};

#endif /*SIMPLEDATAELEMENT_H_*/
