* ./crlcore:
- New: The Measure extension (on any DBo) that allows to save measurement and print them later into a file. Mainly to supply gnuplot with datas. Obsoletes the "statsExtract.py" script from statistics, and much more reliable.
This commit is contained in:
parent
b985e8c96f
commit
9a90f87c65
|
@ -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
|
||||
|
|
|
@ -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 <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
|
||||
#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<typename Data>
|
||||
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<typename Data>
|
||||
inline Measure<Data>::Measure ( const Name& name, const Data& data )
|
||||
: BaseMeasure(name), _data(data) { }
|
||||
|
||||
|
||||
template<typename Data>
|
||||
inline const Data& Measure<Data>::getData () const { return _data; }
|
||||
|
||||
template<typename Data>
|
||||
inline void Measure<Data>::setData ( const Data& data ) { _data=data; }
|
||||
|
||||
template<typename Data>
|
||||
std::string Measure<Data>::toString () const
|
||||
{ std::ostringstream s; s << std::fixed << std::setprecision(2) << _data; return s.str(); }
|
||||
|
||||
|
||||
class MeasuresSet : public std::map<Name,BaseMeasure*> {
|
||||
public:
|
||||
~MeasuresSet ();
|
||||
std::string toStringHeaders ( const std::vector<Name>& ) const;
|
||||
std::string toStringDatas ( const std::vector<Name>& ) const;
|
||||
};
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Class : "CRL::MeasuresDatas".
|
||||
|
||||
|
||||
class MeasuresDatas {
|
||||
public:
|
||||
MeasuresDatas ();
|
||||
public:
|
||||
MeasuresSet _measures;
|
||||
};
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Class : "CRL::Measures".
|
||||
|
||||
|
||||
class Measures {
|
||||
public:
|
||||
typedef StandardPrivateProperty<MeasuresDatas> Extension;
|
||||
public:
|
||||
template<typename Data> friend void addMeasure ( DBo*, const Name&, const Data& );
|
||||
template<typename Data> friend const Measure<Data>* getMeasure ( const DBo*, const Name& );
|
||||
static const MeasuresSet* get ( const DBo* );
|
||||
private:
|
||||
static Extension* _getOrCreate ( DBo* );
|
||||
};
|
||||
|
||||
|
||||
template<typename Data>
|
||||
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<Data>(name,data)) );
|
||||
}
|
||||
|
||||
|
||||
template<typename Data>
|
||||
static Measure<Data>* 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<Data>* >( (*imeasure).second );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
} // End of CRL namespace.
|
||||
|
||||
|
||||
#endif // __STATISTICS_PROPERTY__
|
|
@ -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
|
||||
//
|
||||
// ===================================================================
|
||||
//
|
||||
|
|
|
@ -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 <iomanip>
|
||||
|
||||
#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<MeasuresDatas>::_name = "CRL::Measures";
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Class : "CRL::MeasuresSet".
|
||||
|
||||
|
||||
MeasuresSet::~MeasuresSet ()
|
||||
{
|
||||
iterator imeasure = begin();
|
||||
for ( ; imeasure != end() ; ++imeasure )
|
||||
delete (*imeasure).second;
|
||||
}
|
||||
|
||||
|
||||
string MeasuresSet::toStringHeaders ( const vector<Name>& names ) const
|
||||
{
|
||||
ostringstream out;
|
||||
out << "#";
|
||||
|
||||
for ( size_t i=0 ; i<names.size() ; ++i ) {
|
||||
const_iterator imeasure = find ( names[i] );
|
||||
if ( imeasure == end() ) continue;
|
||||
|
||||
const BaseMeasure* measure = (*imeasure).second;
|
||||
out << setw(8) << right << measure->getName();
|
||||
}
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
||||
string MeasuresSet::toStringDatas ( const vector<Name>& names ) const
|
||||
{
|
||||
ostringstream out;
|
||||
out << " ";
|
||||
|
||||
for ( size_t i=0 ; i<names.size() ; ++i ) {
|
||||
const_iterator imeasure = find ( names[i] );
|
||||
if ( imeasure == end() ) continue;
|
||||
|
||||
const BaseMeasure* measure = (*imeasure).second;
|
||||
out << setw(8) << right << measure->toString();
|
||||
}
|
||||
|
||||
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.
|
|
@ -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
|
||||
//
|
||||
// ===================================================================
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue