coriolis/crlcore/src/LibraryManager/CellDatas.cpp

124 lines
3.0 KiB
C++
Raw Normal View History

New Library Manager Widget. Access with Tools menu or CTRL+M. * New: In CRL Core, created a LibraryManager widget. It provides a composite information based on what is present, for each Alliance library: 1. - A Cell in memory, without Catalog::State. 2. - A Catalog::State, with or whithout the Cell in memory. 3. - The files of the Cell in the librariy's directory. 4. - A file with a format referenced for one of the importers. File type recognition is based *only* on the file extension, so it may easily confused. Be careful about what you put in the library's directory. One of the big limitation is that it will not display Hurricane libraries that do not have the AllianceLibrary extension. This widget is put in a separate library <libmanager>, included in the default CRLCORE_LIBRARIES. * Change: In CRL Core, in State (through the loader), now sets the InMemory flag (event if nobody uses it yet...). Display it in the state _getString(). In AllianceFramework, new getAllianceLibraries() method. In CatalogExtension, make the static method "get()" publicly accessible, for sometimes we want the whole State. * Bug: In vlsisapd, in Path, the pathcache was not rebuild when it should, leading to incorrect results. * New: In vlsisapd, in Path, added a listdir() method to access the contents of a directory and a stat() method to poll the status of a file/directory. Rename the ".string()" method in ".toString()" to avoid tricky name resolution with std::string, refactor in all the other tools. * Change: In Hurricane, in Controller, no longer oversize the fonts of the table's headers. * New: In Unicorn, in UnicornGui, integrate LibraryManager.
2015-05-09 10:03:17 -05:00
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
2016-01-20 17:41:19 -06:00
// Copyright (c) UPMC 2015-2016, All Rights Reserved
New Library Manager Widget. Access with Tools menu or CTRL+M. * New: In CRL Core, created a LibraryManager widget. It provides a composite information based on what is present, for each Alliance library: 1. - A Cell in memory, without Catalog::State. 2. - A Catalog::State, with or whithout the Cell in memory. 3. - The files of the Cell in the librariy's directory. 4. - A file with a format referenced for one of the importers. File type recognition is based *only* on the file extension, so it may easily confused. Be careful about what you put in the library's directory. One of the big limitation is that it will not display Hurricane libraries that do not have the AllianceLibrary extension. This widget is put in a separate library <libmanager>, included in the default CRLCORE_LIBRARIES. * Change: In CRL Core, in State (through the loader), now sets the InMemory flag (event if nobody uses it yet...). Display it in the state _getString(). In AllianceFramework, new getAllianceLibraries() method. In CatalogExtension, make the static method "get()" publicly accessible, for sometimes we want the whole State. * Bug: In vlsisapd, in Path, the pathcache was not rebuild when it should, leading to incorrect results. * New: In vlsisapd, in Path, added a listdir() method to access the contents of a directory and a stat() method to poll the status of a file/directory. Rename the ".string()" method in ".toString()" to avoid tricky name resolution with std::string, refactor in all the other tools. * Change: In Hurricane, in Controller, no longer oversize the fonts of the table's headers. * New: In Unicorn, in UnicornGui, integrate LibraryManager.
2015-05-09 10:03:17 -05:00
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | Alliance / Hurricane Interface |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./CellDatas.cpp" |
// +-----------------------------------------------------------------+
#include <iostream>
#include "hurricane/Error.h"
#include "hurricane/Cell.h"
#include "crlcore/AllianceFramework.h"
#include "crlcore/Catalog.h"
#include "crlcore/CellDatas.h"
namespace CRL {
using namespace std;
using Hurricane::Error;
// -------------------------------------------------------------------
// Class : "CellLoaders".
CellLoaders* CellLoaders::_singleton = NULL;
unsigned int CellLoaders::_loaderBit = 16;
unsigned int CellLoaders::_loaderBitMask = 0xFFFF0000;
CellLoaders* CellLoaders::get ()
{
if (not _singleton) _singleton = new CellLoaders ();
return _singleton;
}
CellLoaders::CellLoaders ()
: _loaders()
{ }
CellLoaders::~CellLoaders ()
{ for ( auto iloader : _loaders ) delete iloader; }
unsigned int CellLoaders::lmask () { return _loaderBitMask; }
const CellLoader* CellLoaders::getLoader ( string format ) const
{
CellLoader key ( format, "", CellLoader::NoFlags, 0 );
auto iloader = _loaders.find( &key );
if (iloader == _loaders.end()) return NULL;
return *iloader;
}
const CellLoader* CellLoaders::getLoader ( unsigned int bit ) const
{
for ( auto iloader : _loaders ) {
if (iloader->getFlags() & bit) return iloader;
}
return NULL;
}
void CellLoaders::addLoader ( CellLoader* loader )
{
if (getLoader(loader->getFormat())) {
cerr << Error( "CellLoaders::addLoader(): Attemp to add multiple loaders for format <%s>."
, loader->getFormat().c_str()
) << endl;
return;
}
loader->setFlags( (1 << _loaderBit++) );
_loaders.insert( loader );
}
// -------------------------------------------------------------------
// Class : "CellDatas".
Utilities::Path CellDatas::_libraryPath;
CellDatas::CellDatas ( string name )
: _name (name)
, _flags (0)
, _activeFlags(0)
, _cell (NULL)
, _state (NULL)
{ }
CellDatas::CellDatas ( Cell* cell )
: _name ()
, _flags (0)
, _activeFlags(0)
, _cell (cell)
, _state (NULL)
{
if (cell) {
_name = getString(_cell->getName());
_state = CatalogExtension::get( cell );
}
else
_name = "[ERROR] NULL Cell";
}
} // CRL namespace.