* ./crlcore:

- New: In AllianceFramework, getInstancesCount() to count the number of
        instances in a Cell. The count can be recursive or not or ignore or
        not feed cells. This could be viewed as a very simple query, and has
        to be implemented here because we only new Feed Cell from the CATAL
        of the Alliance Framework.
This commit is contained in:
Jean-Paul Chaput 2010-04-23 13:12:51 +00:00
parent ca8de0d706
commit 448a345a26
4 changed files with 60 additions and 3 deletions

View File

@ -1,10 +1,34 @@
// -*- C++ -*- // -*- 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@asim.lip6.fr |
// | =============================================================== |
// | C++ Module : "./AllianceFramework.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include "hurricane/Warning.h" #include "hurricane/Warning.h"
#include "hurricane/Technology.h" #include "hurricane/Technology.h"
#include "hurricane/DataBase.h" #include "hurricane/DataBase.h"
#include "hurricane/Library.h" #include "hurricane/Library.h"
#include "hurricane/Cell.h"
#include "hurricane/Instance.h"
#include "hurricane/viewer/Graphics.h" #include "hurricane/viewer/Graphics.h"
#include "crlcore/Utilities.h" #include "crlcore/Utilities.h"
@ -23,6 +47,8 @@ namespace CRL {
using Hurricane::Warning; using Hurricane::Warning;
using Hurricane::tab; using Hurricane::tab;
using Hurricane::Graphics; using Hurricane::Graphics;
using Hurricane::ForEachIterator;
using Hurricane::Instance;
AllianceFramework* AllianceFramework::_singleton = NULL; AllianceFramework* AllianceFramework::_singleton = NULL;
@ -495,4 +521,27 @@ namespace CRL {
} }
size_t AllianceFramework::getInstancesCount ( Cell* cell, unsigned int flags )
{
size_t gates = 0;
forEach ( Instance*, iinstance, cell->getInstances() ) {
CatalogProperty *catalogProperty = static_cast<CatalogProperty*>
((*iinstance)->getMasterCell()->getProperty ( CatalogProperty::getPropertyName()) );
if ( catalogProperty != NULL ) {
Catalog::State* state = catalogProperty->getState ();
if ( (flags and IgnoreFeeds) and state->isFeed() ) continue;
}
++gates;
if ( flags & Recursive ) {
gates += getInstancesCount ( iinstance->getMasterCell(), flags );
}
}
return gates;
}
} // End of CRL namespace. } // End of CRL namespace.

View File

@ -2,7 +2,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved
// //
// =================================================================== // ===================================================================
// //
@ -43,7 +43,8 @@ namespace CRL {
class AllianceFramework { class AllianceFramework {
public:
enum InstancesCountFlags { Recursive=0x1, IgnoreFeeds=0x2 };
public: public:
// Constructors. // Constructors.
static AllianceFramework* create (); static AllianceFramework* create ();
@ -86,6 +87,7 @@ namespace CRL {
void saveCell ( Cell* cell , unsigned int mode ); void saveCell ( Cell* cell , unsigned int mode );
unsigned int loadLibraryCells ( Library* library ); unsigned int loadLibraryCells ( Library* library );
unsigned int loadLibraryCells ( const Name& name ); unsigned int loadLibraryCells ( const Name& name );
static size_t getInstancesCount ( Cell* cell, unsigned int flags );
// Internals - Attributes. // Internals - Attributes.
protected: protected:

View File

@ -61,7 +61,6 @@ namespace CRL {
}; };
BaseMeasure::~BaseMeasure () {}
inline BaseMeasure::BaseMeasure ( const Name& name ) : _name(name) {} inline BaseMeasure::BaseMeasure ( const Name& name ) : _name(name) {}
inline const Name& BaseMeasure::getName () const { return _name; } inline const Name& BaseMeasure::getName () const { return _name; }

View File

@ -42,6 +42,13 @@ namespace CRL {
using Hurricane::Error; using Hurricane::Error;
using Hurricane::ForEachIterator; using Hurricane::ForEachIterator;
// -------------------------------------------------------------------
// Class : "CRL::MeasuresSet".
BaseMeasure::~BaseMeasure () {}
const char* MissingMeasures = "Measures::%s(): %s missing the Measures extension."; const char* MissingMeasures = "Measures::%s(): %s missing the Measures extension.";