* ./crlcore:

- New: Inspector support enabled for AllianceFramework and most of it's
        sub-objects. Attached as a property on the DataBase to be browsable
        through the Inspector.
    - Change: Now also read a <.coriolis2.configuration.xml> in the user's
        root account (before the directory specific one and after the system-
        wide).
    - Change: In verbose mode, also display what environment files are being
        read.
    - Change: No more reference to CRL_CATA_LIB in error messages.
    - Change: Suppress stratus2sxlib obsolete library.
This commit is contained in:
Jean-Paul Chaput 2010-11-17 15:40:39 +00:00
parent 928b3a0a2a
commit 7d49e75797
11 changed files with 267 additions and 78 deletions

View File

@ -25,7 +25,6 @@
<library>${CELL_TOP}/cells/rflib</library>
<library>${CELL_TOP}/cells/rf2lib</library>
<library>${CELL_TOP}/cells/pxlib</library>
<library>${CORIOLIS_TOP}/share/cells/stratus2sxlib</library>
</system>
</libraries>
<formats>

View File

@ -50,12 +50,82 @@ namespace CRL {
using Hurricane::Graphics;
using Hurricane::ForEachIterator;
using Hurricane::Instance;
using Hurricane::PrivateProperty;
// -------------------------------------------------------------------
// Class : "CRL::AllianceFrameworkProperty".
class AllianceFrameworkProperty : public PrivateProperty {
public:
static AllianceFrameworkProperty* create ( AllianceFramework* );
static Name getPropertyName ();
virtual Name getName () const;
inline AllianceFramework* getFramework () const;
virtual string _getTypeName () const;
virtual Record* _getRecord () const;
private:
static Name _name;
AllianceFramework* _framework;
private:
inline AllianceFrameworkProperty ( AllianceFramework* );
};
Name AllianceFrameworkProperty::_name = "AllianceFramework";
inline AllianceFrameworkProperty::AllianceFrameworkProperty ( AllianceFramework* af )
: PrivateProperty(), _framework(af)
{ }
inline AllianceFramework* AllianceFrameworkProperty::getFramework () const
{ return _framework; }
AllianceFrameworkProperty* AllianceFrameworkProperty::create ( AllianceFramework* af )
{
AllianceFrameworkProperty *property = new AllianceFrameworkProperty ( af );
property->_postCreate ();
return property;
}
Name AllianceFrameworkProperty::getPropertyName ()
{ return _name; }
Name AllianceFrameworkProperty::getName () const
{ return getPropertyName(); }
string AllianceFrameworkProperty::_getTypeName () const
{ return _TName ( "AllianceFrameworkProperty" ); }
Record* AllianceFrameworkProperty::_getRecord () const
{
Record* record = PrivateProperty::_getRecord();
if ( record ) {
record->add( getSlot("_name" ,_name ) );
record->add( getSlot("_framework",_framework) );
}
return record;
}
// -------------------------------------------------------------------
// Class : "CRL::AllianceFramework".
AllianceFramework* AllianceFramework::_singleton = NULL;
const Name AllianceFramework::_parentLibraryName = "AllianceFramework";
AllianceFramework::AllianceFramework ()
: _environment()
, _parsers()
@ -70,9 +140,13 @@ namespace CRL {
System::get ();
DataBase* db = DataBase::getDB ();
if ( !db )
if ( not db )
db = DataBase::create ();
db->put ( AllianceFrameworkProperty::create(this) );
cmess1 << " o Reading Alliance Environment." << endl;
_environment.loadFromShell ();
_environment.loadFromXml ();
@ -105,9 +179,9 @@ namespace CRL {
cmess2 << " o Loading libraries (working first)." << endl;
for ( unsigned i=0 ; i<LIBRARIES.getSize() ; i++ ) {
createLibrary ( LIBRARIES[i], flags );
createLibrary ( LIBRARIES[i].getPath(), flags, LIBRARIES[i].getName() );
cmess2 << " - \"" << LIBRARIES[i] << "\"";
cmess2 << " - \"" << LIBRARIES[i].getPath() << "\"";
cmess2.flush();
if ( flags&HasCatalog ) cmess2 << " [have CATAL]." << endl;
@ -286,19 +360,14 @@ namespace CRL {
}
AllianceLibrary* AllianceFramework::getAllianceLibrary ( const Name &path, unsigned int& flags )
AllianceLibrary* AllianceFramework::getAllianceLibrary ( const Name &libName, unsigned int& flags )
{
string spath = getString ( path );
size_t slash = spath.rfind ( '/' );
string sname = spath.substr ( (slash!=string::npos)?slash+1:0 );
for ( size_t ilib=0 ; ilib<_libraries.size() ; ++ilib ) {
if ( _libraries[ilib]->getLibrary()->getName() == sname )
if ( _libraries[ilib]->getLibrary()->getName() == libName )
return _libraries[ilib];
}
return (flags&CreateLibrary) ? createLibrary ( getString(path), flags ) : NULL;
return (flags&CreateLibrary) ? createLibrary ( getString(libName), flags ) : NULL;
}
@ -338,7 +407,6 @@ namespace CRL {
// Transmit all flags except thoses related to views.
loadMode |= (mode & (!Catalog::State::Views));
parser = & ( _parsers.getParserSlot ( name, loadMode, _environment ) );
// Try to open cell file (file extention is supplied by the parser).
@ -372,10 +440,9 @@ namespace CRL {
}
AllianceLibrary* AllianceFramework::createLibrary ( const string& path, unsigned int& flags )
AllianceLibrary* AllianceFramework::createLibrary ( const string& path, unsigned int& flags, string libName )
{
size_t slash = path.rfind ( '/' );
string libName = path.substr ( (slash!=string::npos)?slash+1:0 );
if ( libName.empty() ) libName = SearchPath::extractLibName(path);
flags &= ~HasCatalog;
@ -387,7 +454,7 @@ namespace CRL {
}
SearchPath& LIBRARIES = _environment.getLIBRARIES ();
if ( not (flags & InSearchPath) ) LIBRARIES.prepend ( path );
if ( not (flags & InSearchPath) ) LIBRARIES.prepend ( path, libName );
else LIBRARIES.select ( path );
library = new AllianceLibrary ( path, Library::create(getParentLibrary(),libName) );
@ -405,11 +472,8 @@ namespace CRL {
if ( not parser.loadByLib() ) return library;
if ( slash == path.npos ) return library;
string file = path.substr(slash+1,path.size()-slash);
// Load the whole library.
if ( ! _readLocate(file,Catalog::State::State::Logical,true) ) return library;
if ( ! _readLocate(libName,Catalog::State::State::Logical,true) ) return library;
// Call the parser function.
(parser.getParsLib())( _environment.getLIBRARIES().getSelected() , library->getLibrary() , _catalog );
@ -690,4 +754,18 @@ namespace CRL {
}
string AllianceFramework::_getString () const
{ return "<AllianceFramework>"; }
Record *AllianceFramework::_getRecord () const
{
Record* record = new Record ( "<AllianceFramework>" );
record->add ( getSlot ( "_environment", &_environment) );
record->add ( getSlot ( "_libraries" , &_libraries ) );
record->add ( getSlot ( "_catalog" , &_catalog ) );
return record;
}
} // End of CRL namespace.

View File

@ -210,6 +210,8 @@ namespace {
envPath = env.getCORIOLIS_TOP() + "/" + sysConfDir + "/coriolis2/environment.alliance.xml" ;
}
cmess1 << " - <" << envPath << ">." << endl;
return ep._load ( envPath, warnNotFound );
}
@ -391,6 +393,7 @@ namespace {
{
unsigned int mode = Environment::Append;
QString modeAttribute = _reader->attributes().value("mode").toString();
QString nameAttribute = _reader->attributes().value("name").toString();
if ( not modeAttribute.isEmpty() ) {
if ( modeAttribute == "append" ) mode = Environment::Append;
@ -403,9 +406,13 @@ namespace {
string library = readTextAsString().toStdString();
expandVariables ( library );
string libName = nameAttribute.toStdString();
if ( libName.empty() ) libName = SearchPath::extractLibName ( library );
switch ( _state ) {
case WorkingLibrary: _environment.setWORKING_LIBRARY ( library.c_str() ); break;
case SystemLibrary: _environment.addSYSTEM_LIBRARY ( library.c_str(), mode ); break;
case SystemLibrary: _environment.addSYSTEM_LIBRARY ( library.c_str(), libName.c_str(), mode ); break;
}
}
@ -651,14 +658,14 @@ namespace CRL {
s << " o Libraries.\n"
<< " - Catalog := \"" << _CATALOG << "\"\n"
<< " - Working Library:\n"
<< " 0:\"" << _LIBRARIES[0] << "\"\n"
<< " 0:\"" << _LIBRARIES[0].getPath() << "\"\n"
<< " - System Libraries:\n";
if ( _LIBRARIES.getSize() <= 1 ) {
s << " <not set or empty>.\n";
} else {
for ( size_t i = 1; i < _LIBRARIES.getSize() ; i++ ) {
s << " " << setw(2) << i << ":\"" << _LIBRARIES[i] << "\"\n";
s << " " << setw(2) << i << ":\"" << _LIBRARIES[i].getPath() << "\"\n";
}
}
@ -737,26 +744,44 @@ namespace CRL {
}
void Environment::addSYSTEM_LIBRARY ( const char* value, unsigned int mode )
void Environment::addSYSTEM_LIBRARY ( const char* value, const char* libName, unsigned int mode )
{
if ( mode == Prepend ) { _LIBRARIES.prepend(value); return; }
if ( mode == Append ) { _LIBRARIES.append (value); return; }
if ( mode == Prepend ) { _LIBRARIES.prepend(value,libName); return; }
if ( mode == Append ) { _LIBRARIES.append (value,libName); return; }
string newLibName = _getLibraryName ( value );
string newLibName = libName;
for ( size_t i=0 ; i < _LIBRARIES.getSize() ; ++i ) {
if ( newLibName == _getLibraryName(_LIBRARIES[i]) ) {
_LIBRARIES.replace ( value, i );
if ( newLibName == _LIBRARIES[i].getName() ) {
_LIBRARIES.replace ( value, newLibName, i );
return;
}
}
_LIBRARIES.append (value);
_LIBRARIES.append (value,libName);
}
string Environment::_getLibraryName ( const std::string& path )
string Environment::_getString () const
{ return "<Environment>"; }
Record *Environment::_getRecord () const
{
size_t slash = path.rfind ( '/' );
return path.substr ( (slash!=string::npos)?slash+1:0 );
Record* record = new Record ( "<Environment>" );
record->add ( getSlot ( "_CORIOLIS_TOP" , &_CORIOLIS_TOP ) );
record->add ( getSlot ( "_displayStyle" , &_displayStyle ) );
record->add ( getSlot ( "_SCALE_X" , &_SCALE_X ) );
record->add ( getSlot ( "_SYMBOLIC_TECHNOLOGY", &_SYMBOLIC_TECHNOLOGY ) );
record->add ( getSlot ( "_REAL_TECHNOLOGY" , &_REAL_TECHNOLOGY ) );
record->add ( getSlot ( "_DISPLAY" , &_DISPLAY ) );
record->add ( getSlot ( "_IN_LO" , &_IN_LO ) );
record->add ( getSlot ( "_IN_PH" , &_IN_PH ) );
record->add ( getSlot ( "_POWER" , &_POWER ) );
record->add ( getSlot ( "_GROUND" , &_GROUND ) );
record->add ( getSlot ( "_CLOCK" , &_CLOCK ) );
record->add ( getSlot ( "_OBSTACLE" , &_OBSTACLE ) );
record->add ( getSlot ( "_pad" , &_pad ) );
record->add ( getSlot ( "_LIBRARIES" , &_LIBRARIES ) );
return record;
}

View File

@ -38,6 +38,24 @@ namespace CRL {
using namespace std;
string SearchPath::Element::_getString () const
{
ostringstream s;
s << "<SearchPath::Element " << _name << ":" << _path << ">";
return s.str();
}
Record *SearchPath::Element::_getRecord () const
{
Record* record = new Record ( "<SearchPath::Element>" );
record->add ( getSlot ( "_path", &_path ) );
record->add ( getSlot ( "_name", &_name ) );
return record;
}
const size_t SearchPath::npos = (size_t)-1;
const string SearchPath::_selectFailed = "<File or directory not found>";
@ -49,9 +67,16 @@ namespace CRL {
{ }
bool SearchPath::_canOpen ( const string& directory, const string& file, ios::openmode mode )
string SearchPath::extractLibName ( const string& path )
{
_selected = directory + "/" + file;
size_t slash = path.rfind ( '/' );
return path.substr ( (slash!=string::npos) ? slash+1 : 0 );
}
bool SearchPath::_canOpen ( const SearchPath::Element& directory, const string& file, ios::openmode mode )
{
_selected = directory.getPath() + "/" + file;
fstream filestream ( _selected.c_str(), mode );
if ( filestream.is_open() ) {
filestream.close ();
@ -62,30 +87,30 @@ namespace CRL {
}
void SearchPath::prepend ( const std::string& path )
void SearchPath::prepend ( const std::string& path, const std::string& name )
{
vector<string>::iterator ipath = _paths.begin();
vector<Element>::iterator ipath = _paths.begin();
_index = 0;
if ( ipath != _paths.end() ) { ++ipath; ++_index; }
_paths.insert ( ipath, path );
_paths.insert ( ipath, Element(path,name) );
}
void SearchPath::replace ( const string& path, size_t index )
void SearchPath::replace ( const string& path, const std::string& name, size_t index )
{
_index = index;
if ( index < _paths.size() )
_paths[index] = path;
_paths[index] = Element(path,name);
}
void SearchPath::select ( const string& path )
{
for ( size_t ipath=0 ; ipath < _paths.size() ; ++ipath ) {
if ( _paths[ipath] == path ) {
_selected = _paths[ipath];
if ( _paths[ipath].getPath() == path ) {
_selected = _paths[ipath].getPath();
_index = ipath;
return;
}
@ -113,17 +138,17 @@ namespace CRL {
size_t SearchPath::hasPath ( const string& path ) const
{
for ( size_t i=0 ; i < _paths.size() ; i++ )
if ( _paths[i] == path ) return i;
if ( _paths[i].getPath() == path ) return i;
return npos;
}
const string& SearchPath::operator[] ( size_t index ) const
const SearchPath::Element& SearchPath::operator[] ( size_t index ) const
{
static const string OutOfBound = "<index out of bound>";
static Element nullElement;
if ( index < _paths.size() ) return _paths[index];
return OutOfBound;
return nullElement;
}

View File

@ -99,7 +99,8 @@ namespace {
std::string environmentMapper ( std::string environmentName )
{
if ( environmentName == "CORIOLIS_TOP" ) return "coriolis_top";
if ( environmentName == "HOME" ) return "home";
else if ( environmentName == "CORIOLIS_TOP" ) return "coriolis_top";
else if ( environmentName == "STRATUS_MAPPING_NAME" ) return "stratus_mapping_name";
return "";
}
@ -236,6 +237,8 @@ namespace CRL {
// Environment variables reading.
boptions::options_description options ("Environment Variables");
options.add_options()
( "home" , boptions::value<string>()
, "User's home directory." )
( "coriolis_top" , boptions::value<string>()->default_value(CORIOLIS_TOP)
, "The root directory of the Coriolis installation tree." )
( "stratus_mapping_name", boptions::value<string>()
@ -260,7 +263,7 @@ namespace CRL {
bfs::path sysConfDir ( SYS_CONF_DIR );
if ( not sysConfDir.has_root_path() ) {
if ( arguments.count("coriolis_top") ) {
const boptions::variable_value& value = arguments["coriolis_top"];
// const boptions::variable_value& value = arguments["coriolis_top"];
// cerr << "value:"
// << " empty:" << boolalpha << value.empty()
// << " defaulted:" << boolalpha << value.defaulted()
@ -320,6 +323,14 @@ namespace CRL {
,systemConfFile.string().c_str()) << endl;
}
bool homeConfFound = false;
bfs::path homeConfFile = arguments["home"].as<string>();
homeConfFile /= ".coriolis2.configuration.xml";
if ( bfs::exists(homeConfFile) ) {
homeConfFound = true;
conf->readFromFile ( homeConfFile.string() );
}
bool dotConfFound = false;
bfs::path dotConfFile = "./.coriolis2.configuration.xml";
if ( bfs::exists(dotConfFile) ) {
@ -340,6 +351,7 @@ namespace CRL {
if ( cmess1.enabled() ) {
cmess1 << " o Reading Configuration. " << endl;
if (systemConfFound) cmess1 << " - <" << systemConfFile.string() << ">." << endl;
if (homeConfFound) cmess1 << " - <" << homeConfFile.string() << ">." << endl;
if (dotConfFound) cmess1 << " - <" << dotConfFile.string() << ">." << endl;
}
}

View File

@ -1282,7 +1282,7 @@ void vstParser ( const string cellPath, Cell *cell )
, Catalog::State::Views
, __ys->_state->getDepth()-1) ) {
throw Error ( "CParsVst():\n"
" Unable to find cell \"%s\", please check your CRL_CATA_LIB.\n"
" Unable to find cell \"%s\", please check your <.environment.alliance.xml>.\n"
, getString(__ys->_cellQueue.front()).c_str()
);
}

View File

@ -79,9 +79,9 @@ namespace CRL {
inline Library* getParentLibrary ();
Library* getLibrary ( unsigned int index );
AllianceLibrary* getAllianceLibrary ( unsigned int index );
AllianceLibrary* getAllianceLibrary ( const Name& path, unsigned int& flags );
AllianceLibrary* getAllianceLibrary ( const Name& libName, unsigned int& flags );
AllianceLibrary* getAllianceLibrary ( Library* );
AllianceLibrary* createLibrary ( const string& path, unsigned int& flags );
AllianceLibrary* createLibrary ( const string& path, unsigned int& flags, string libName="" );
void saveLibrary ( Library* );
void saveLibrary ( AllianceLibrary* );
RoutingGauge* getRoutingGauge ( const Name& name="" );
@ -99,6 +99,10 @@ namespace CRL {
unsigned int loadLibraryCells ( Library* );
unsigned int loadLibraryCells ( const Name& );
static size_t getInstancesCount ( Cell*, unsigned int flags );
// Hurricane Managment.
inline string _getTypeName () const;
string _getString () const;
Record* _getRecord () const;
// Internals - Attributes.
protected:
@ -154,9 +158,13 @@ namespace CRL {
// TEMPORARY.
inline const Name AllianceFramework::getDefaultCGPinLayerName
() const { return "CALU1"; }
inline string AllianceFramework::_getTypeName () const { return "AllianceFramework"; }
} // End of CRL namespace.
INSPECTOR_P_SUPPORT(CRL::AllianceFramework);
#endif // __CRL_ALLIANCE_FRAMEWORK__

View File

@ -118,4 +118,7 @@ namespace CRL {
} // End of CRL namespace.
INSPECTOR_P_SUPPORT(CRL::AllianceLibrary);
#endif

View File

@ -123,8 +123,8 @@ namespace CRL {
inline void setDepth ( unsigned int depth );
// Hurricane Management.
inline string _getTypeName () const;
inline string _getString () const;
inline Record* _getRecord () const;
string _getString () const;
Record* _getRecord () const;
private:
// Internal - Attributes.
@ -389,5 +389,8 @@ namespace CRL {
inline std::string getPrint ( const CRL::Catalog &CATAL ) { return CATAL._getPrint(); }
INSPECTOR_P_SUPPORT(CRL::Catalog);
INSPECTOR_P_SUPPORT(CRL::Catalog::State);
#endif

View File

@ -29,7 +29,6 @@
#include <regex.h>
#include <string>
#include <crlcore/SearchPath.h>
@ -92,10 +91,13 @@ namespace CRL {
void setPad ( const char* value );
inline void setCATALOG ( const char* value );
inline void setWORKING_LIBRARY ( const char* value );
void addSYSTEM_LIBRARY ( const char* value, unsigned int mode=Append );
void addSYSTEM_LIBRARY ( const char* value, const char* libName, unsigned int mode=Append );
// Methods.
std::string getPrint () const;
inline std::string _getTypeName () const;
std::string _getString () const;
Record* _getRecord () const;
protected:
// Internal: Attributes.
@ -126,7 +128,6 @@ namespace CRL {
private:
void _setRegex ( regex_t* regex, const std::string& pattern, const char* name );
void _check () const;
static std::string _getLibraryName ( const std::string& path );
};
@ -159,10 +160,14 @@ namespace CRL {
inline void Environment::setOUT_LO ( const char* value ) { _OUT_LO = value; }
inline void Environment::setOUT_PH ( const char* value ) { _OUT_PH = value; }
inline void Environment::setCATALOG ( const char* value ) { _CATALOG = value; }
inline void Environment::setWORKING_LIBRARY ( const char* value ) { _LIBRARIES.replace(value,0); }
inline void Environment::setWORKING_LIBRARY ( const char* value ) { _LIBRARIES.replace(value,"working",0); }
inline std::string Environment::_getTypeName () const { return "Environment"; }
} // End of CRL namespace.
INSPECTOR_P_SUPPORT(CRL::Environment);
# endif

View File

@ -43,32 +43,47 @@ namespace CRL {
class SearchPath {
public:
static const size_t npos;
SearchPath ();
class Element {
public:
inline Element ( const std::string& path="", const std::string& name="" );
inline bool empty () const;
inline const std::string& getPath () const;
inline const std::string& getName () const;
inline std::string _getTypeName () const;
std::string _getString () const;
Record* _getRecord () const;
private:
std::string _path;
std::string _name;
};
public:
inline void reset ();
inline void append ( const std::string& path );
void prepend ( const std::string& path );
void replace ( const std::string& path, size_t index );
size_t locate ( const std::string& file
, std::ios::openmode mode =std::ios::in
, int first=0
, int last =64 );
void select ( const std::string& );
inline size_t getSize () const;
inline const std::string& getSelected () const;
inline size_t getIndex () const;
inline bool hasSelected () const;
size_t hasPath ( const std::string& path ) const;
const std::string& operator[] ( size_t index ) const;
static const size_t npos;
static std::string extractLibName ( const std::string& );
SearchPath ();
public:
inline void reset ();
inline void append ( const std::string& path, const std::string& name="" );
void prepend ( const std::string& path, const std::string& name="");
void replace ( const std::string& path, const std::string&, size_t index );
size_t locate ( const std::string& file
, std::ios::openmode mode =std::ios::in
, int first=0
, int last =64 );
void select ( const std::string& );
inline size_t getSize () const;
inline const std::string& getSelected () const;
inline size_t getIndex () const;
inline bool hasSelected () const;
size_t hasPath ( const std::string& path ) const;
const Element& operator[] ( size_t index ) const;
private:
static const std::string _selectFailed;
std::vector<std::string> _paths;
std::vector<Element> _paths;
size_t _index;
std::string _selected;
private:
SearchPath ( const SearchPath& );
bool _canOpen ( const std::string& directory
bool _canOpen ( const Element& directory
, const std::string& file
, std::ios::openmode mode
);
@ -81,16 +96,32 @@ namespace CRL {
// Inline Functions.
inline void SearchPath::reset () { _paths.resize(1); }
inline void SearchPath::append ( const std::string& path ) { _paths.push_back(path); }
inline size_t SearchPath::getSize () const { return _paths.size(); }
inline const std::string& SearchPath::getSelected () const { return _selected; }
inline size_t SearchPath::getIndex () const { return _index; }
inline bool SearchPath::hasSelected () const { return _index != npos; }
inline std::string SearchPath::_getTypeName () const { return _TName("SearchPath"); }
inline void SearchPath::append ( const std::string& path, const std::string& name ) {
_paths.push_back ( Element ( path, name.empty()?extractLibName(path):name ) );
}
inline SearchPath::Element::Element ( const std::string& path, const std::string& name )
: _path(path)
, _name(name.empty()?SearchPath::extractLibName(path):name)
{ }
inline bool SearchPath::Element::empty () const { return _path.empty() and _name.empty(); }
inline const std::string& SearchPath::Element::getPath () const { return _path; }
inline const std::string& SearchPath::Element::getName () const { return _name; }
inline std::string SearchPath::Element::_getTypeName () const { return "SearchPath::Element"; }
} // End of CRL namespace.
INSPECTOR_P_SUPPORT(CRL::SearchPath);
INSPECTOR_V_SUPPORT(CRL::SearchPath::Element);
# endif