/* This software is distributed under the Lesser General Public License */
//
// Attributes.cpp
//
// This file implements the classes
//   GT_Attribute_Base
//   GT_Attribut<T>
//   GT_Attributes
//   GT_List_of_Attributes
//
//------------------------------------------ CVS
//
// CVS Headers -- The following headers are generated by the CVS
// version control system. Note that especially the attribute
// Author is not necessarily the author of the code.
//
// $Source: /home/br/CVS/graphlet/src/gt_base/Attribute_double.cpp,v $
// $Author: himsolt $
// $Revision: 1.2 $
// $Date: 1999/03/05 20:42:55 $
// $Locker:  $
// $State: Exp $
//
//------------------------------------------ CVS
//
// (C) University of Passau 1995-1999, graphlet Project
//

#include "Graphlet.h"
#include "GML.h"
#include "Key_description.h"

#include "Attribute_double.h"


//////////////////////////////////////////
//
// class GT_Attribute_double
//
//////////////////////////////////////////


GT_Attribute_double::GT_Attribute_double (const GT_Key key, const double& i,
    const int flags) :
	GT_Attribute_Base (key, flags)
{
    the_value = i;
    the_flags |= the_is_double;
}


GT_Attribute_double::~GT_Attribute_double()
{
}


//////////////////////////////////////////
//
// Cloning
//
//////////////////////////////////////////


void GT_Attribute_double::copy (const GT_Attribute_double* from,
    GT_Copy type)
{
    GT_Attribute_Base::copy (from, type);
    the_value = from->the_value;
}


GT_Attribute_Base* GT_Attribute_double::clone (GT_Copy /* type */) const
{
    if (the_flags | the_is_safe) {
	return new GT_Attribute_double (the_key, the_value, the_flags);
    } else {
	return 0;
    }
}


//////////////////////////////////////////
//
// Printing
//
//////////////////////////////////////////


void GT_Attribute_double::print (ostream &out) const
{
    if (the_key.description()->safe() || (the_flags & the_is_safe)) {
	baseclass::print (out);
	GT_print (out, the_value);
    }
}



//////////////////////////////////////////
//
// Value extraction
//
//////////////////////////////////////////


bool GT_Attribute_double::value_double (double& i) const
{
    i = the_value;
    return true;
}
