diff --git a/crlcore/src/ccore/CMakeLists.txt b/crlcore/src/ccore/CMakeLists.txt index f08ab824..85ababb3 100644 --- a/crlcore/src/ccore/CMakeLists.txt +++ b/crlcore/src/ccore/CMakeLists.txt @@ -34,6 +34,7 @@ crlcore/LefDefExtension.h crlcore/Ioc.h crlcore/NetExtension.h + crlcore/Measures.h crlcore/RoutingGauge.h crlcore/RoutingLayerGauge.h crlcore/CellGauge.h @@ -92,7 +93,9 @@ toolbox/RoutingPads.cpp ) set ( vst_driver_cpps alliance/vst/VstDriver.cpp ) - set ( properties_cpps properties/NetExtension.cpp ) + set ( properties_cpps properties/NetExtension.cpp + properties/Measures.cpp + ) # set ( liberty_cpps liberty/CellPath.cpp # liberty/LuTableTemplate.cpp # liberty/LibertyTechnology.cpp diff --git a/crlcore/src/ccore/crlcore/Measures.h b/crlcore/src/ccore/crlcore/Measures.h new file mode 100644 index 00000000..54ced7e6 --- /dev/null +++ b/crlcore/src/ccore/crlcore/Measures.h @@ -0,0 +1,157 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | Alliance / Hurricane Interface | +// | | +// | Author : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./Measures.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#ifndef __STATISTICS_PROPERTY__ +#define __STATISTICS_PROPERTY__ + +#include +#include +#include +#include + +#include "hurricane/Property.h" + +namespace Hurricane { + class DBo; +} + + +namespace CRL { + + + using Hurricane::Name; + using Hurricane::StandardPrivateProperty; + using Hurricane::DBo; + + +// ------------------------------------------------------------------- +// Class : "CRL::BaseMeasure". + + + class BaseMeasure { + public: + inline BaseMeasure ( const Name& ); + virtual ~BaseMeasure (); + inline const Name& getName () const; + virtual std::string toString () const = 0; + private: + Name _name; + }; + + + BaseMeasure::~BaseMeasure () {} + inline BaseMeasure::BaseMeasure ( const Name& name ) : _name(name) {} + inline const Name& BaseMeasure::getName () const { return _name; } + + + template + class Measure : public BaseMeasure { + public: + inline Measure ( const Name&, const Data& ); + inline const Data& getData () const; + inline void setData ( const Data& ); + virtual std::string toString () const; + private: + Data _data; + }; + + + template + inline Measure::Measure ( const Name& name, const Data& data ) + : BaseMeasure(name), _data(data) { } + + + template + inline const Data& Measure::getData () const { return _data; } + + template + inline void Measure::setData ( const Data& data ) { _data=data; } + + template + std::string Measure::toString () const + { std::ostringstream s; s << std::fixed << std::setprecision(2) << _data; return s.str(); } + + + class MeasuresSet : public std::map { + public: + ~MeasuresSet (); + std::string toStringHeaders ( const std::vector& ) const; + std::string toStringDatas ( const std::vector& ) const; + }; + + +// ------------------------------------------------------------------- +// Class : "CRL::MeasuresDatas". + + + class MeasuresDatas { + public: + MeasuresDatas (); + public: + MeasuresSet _measures; + }; + + +// ------------------------------------------------------------------- +// Class : "CRL::Measures". + + + class Measures { + public: + typedef StandardPrivateProperty Extension; + public: + template friend void addMeasure ( DBo*, const Name&, const Data& ); + template friend const Measure* getMeasure ( const DBo*, const Name& ); + static const MeasuresSet* get ( const DBo* ); + private: + static Extension* _getOrCreate ( DBo* ); + }; + + + template + static void addMeasure ( DBo* object, const Name& name, const Data& data ) + { + Measures::Extension* extension = Measures::_getOrCreate ( object ); + extension->getValue()._measures.insert ( std::make_pair(name,new Measure(name,data)) ); + } + + + template + static Measure* getMeasure ( DBo* object, const Name& name ) + { + Measures::Extension* extension = Measures::_getOrCreate ( object ); + MeasuresSet::iterator imeasure = extension->getValue()._measures.find(name); + + if ( imeasure != extension->getValue()._measures.end() ) + return static_cast< Measure* >( (*imeasure).second ); + + return NULL; + } + + +} // End of CRL namespace. + + +#endif // __STATISTICS_PROPERTY__ diff --git a/crlcore/src/ccore/crlcore/NetExtension.h b/crlcore/src/ccore/crlcore/NetExtension.h index 780bb340..582ff476 100644 --- a/crlcore/src/ccore/crlcore/NetExtension.h +++ b/crlcore/src/ccore/crlcore/NetExtension.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // diff --git a/crlcore/src/ccore/properties/Measures.cpp b/crlcore/src/ccore/properties/Measures.cpp new file mode 100644 index 00000000..d4d469ff --- /dev/null +++ b/crlcore/src/ccore/properties/Measures.cpp @@ -0,0 +1,133 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | Alliance / Hurricane Interface | +// | | +// | Author : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./Measures.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#include + +#include "hurricane/Error.h" +#include "hurricane/DBo.h" + +#include "crlcore/Measures.h" + + +namespace CRL { + + + using std::string; + using std::vector; + using std::ostringstream; + using std::setw; + using std::right; + using Hurricane::Error; + using Hurricane::ForEachIterator; + + + const char* MissingMeasures = "Measures::%s(): %s missing the Measures extension."; + + + template<> + Name StandardPrivateProperty::_name = "CRL::Measures"; + + +// ------------------------------------------------------------------- +// Class : "CRL::MeasuresSet". + + + MeasuresSet::~MeasuresSet () + { + iterator imeasure = begin(); + for ( ; imeasure != end() ; ++imeasure ) + delete (*imeasure).second; + } + + + string MeasuresSet::toStringHeaders ( const vector& names ) const + { + ostringstream out; + out << "#"; + + for ( size_t i=0 ; igetName(); + } + + return out.str(); + } + + + string MeasuresSet::toStringDatas ( const vector& names ) const + { + ostringstream out; + out << " "; + + for ( size_t i=0 ; itoString(); + } + + return out.str(); + } + + +// ------------------------------------------------------------------- +// Class : "CRL::MeasuresDatas". + + + MeasuresDatas::MeasuresDatas () + : _measures() + { } + + +// ------------------------------------------------------------------- +// Class : "CRL::Measures". + + + const MeasuresSet* Measures::get ( const DBo* object ) + { + Extension* extension = Extension::get ( object ); + if ( extension != NULL ) + return &extension->getValue()._measures; + + return NULL; + } + + + Measures::Extension* Measures::_getOrCreate ( DBo* object ) + { + Extension* extension = Extension::get ( object ); + if ( extension == NULL ) { + extension = Extension::create (); + object->put ( extension ); + } + return extension; + } + + +} // End of CRL namespace. diff --git a/crlcore/src/ccore/properties/NetExtension.cpp b/crlcore/src/ccore/properties/NetExtension.cpp index d8b40c7b..b6a681ad 100644 --- a/crlcore/src/ccore/properties/NetExtension.cpp +++ b/crlcore/src/ccore/properties/NetExtension.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== //