#ifndef ProtoGenWrapper_DValue_H
#define ProtoGenWrapper_DValue_H

#include <string>
#include <vector>

#include "TypeDefs.h"
#include "DDbDiagTroubleCode.h"

namespace ProtoGenWrapper
{
	class DValue;
	
	typedef std::vector<DValue> DValueCollection;
	
	class DValue
	{
	public:
		DValue();
		DValue(const DValue& other);
		virtual ~DValue();

		DValue& operator=(const DValue& other);
		bool operator==(const DValue& other) const;
		bool operator!=(const DValue& other) const;

		enum ValueType { vtInvalid = -1, vtUnknown, vtBool, vtByteField, vtAsciiString, vtInt32, vtInt64, vtFloat, vtDouble, vtUint32, vtUint64,  vtDtc, vtCollection};
		ValueType GetType() const;

		void SetBoolValue(bool value);
		void SetBytefieldValue(const std::string& value);
		void SetAsciistringValue(const std::string& value);
		void SetInt32Value(int32 value);
		void SetInt64Value(int64 value);
		void SetFloatValue(float value);
		void SetDoubleValue(double value);
		void SetUint32Value(uint32 value);
		void SetUint64Value(uint64 value);
		void SetDiagTroubleCode(const DDbDiagTroubleCode& dtc);
		void SetCollectionValue(const DValueCollection &collection);

		bool GetBoolValue() const;
		std::string GetBytefieldValue() const;
		std::string GetAsciistringValue() const;
		int32 GetInt32Value() const;
		int64 GetInt64Value() const;
		float GetFloatValue() const;
		double GetDoubleValue() const;
		uint32 GetUint32Value() const;
		uint64 GetUint64Value() const;
		const DDbDiagTroubleCode& GetDiagTroubleCode() const;
		const DValueCollection& GetCollectionValue() const;

		void SetValueAsString(const std::string& valueAsString);
		std::string GetValueAsString() const;

		void SetTypeInvalid();
		bool IsTypeValid() const;

	protected:
		bool _boolValue;
		std::string _bytefieldValue;
		std::string _asciistringValue;
		int32 _int32Value;	// OTX unterscheidet hier nicht - oder doch? (unsigned) int32 vs int64, float vs double
		int64 _int64Value;
		float _floatValue;
		double _doubleValue;
		uint32 _uint32Value;
		uint64 _uint64Value;
		DDbDiagTroubleCode _dtcValue;
		DValueCollection _valueCollection;

		std::string _valueAsString;
		
		ValueType _type;
		void ThrowIfNoMatch(ValueType type) const;
	};
}

#endif