diff --git a/hurricane/src/CMakeLists.txt b/hurricane/src/CMakeLists.txt new file mode 100644 index 00000000..345d802a --- /dev/null +++ b/hurricane/src/CMakeLists.txt @@ -0,0 +1,13 @@ +project(HURRICANE) + +cmake_minimum_required(VERSION 2.4.0) + +set(CMAKE_MODULE_PATH "cmake_modules/") + +find_package(Qt4 REQUIRED) # find and setup Qt4 for this project +FIND_PACKAGE(BISON REQUIRED) +FIND_PACKAGE(FLEX REQUIRED) + +add_subdirectory(hurricane) +add_subdirectory(analogic) +add_subdirectory(figures) diff --git a/hurricane/src/analogic/AnalogicalCommons.h b/hurricane/src/analogic/AnalogicalCommons.h new file mode 100644 index 00000000..172521ba --- /dev/null +++ b/hurricane/src/analogic/AnalogicalCommons.h @@ -0,0 +1,45 @@ +// **************************************************************************************************** +// File: AnalogicalCommons.h +// Authors: Wu YiFei +// Date : 21/12/2006 +// **************************************************************************************************** + +#ifndef HURRICANE_ANALOGICALCOMMONS +#define HURRICANE_ANALOGICALCOMMONS + + + +// ********************************************************************* +// Macros Declaration. +// ********************************************************************* + +# define TRANSN 'N' +# define TRANSP 'P' + + +# define MAXNBCONTACT 8 + +# define IF_DEBUG_HUR_ANALOG \ + if(getenv("DEBUG_HUR_ANALOG")) { + +# ifndef END_IF +# define END_IF \ + } +# endif + + +// ********************************************************************* +// Analogical Unit declaration. +// ********************************************************************* +# if !defined(__DOXYGEN_PROCESSOR__) + +typedef double Micro; +typedef double MicroPower2; +typedef long Nano; + +# endif + +#include "TwoSpaces.h" + + +#endif // HURRICANE_ANALOGICALCOMMONS diff --git a/hurricane/src/analogic/CMakeLists.txt b/hurricane/src/analogic/CMakeLists.txt new file mode 100644 index 00000000..ba6e24a0 --- /dev/null +++ b/hurricane/src/analogic/CMakeLists.txt @@ -0,0 +1,43 @@ +set(includes RdsUnit.h) + +include_directories(${HURRICANE_SOURCE_DIR}/hurricane) + +add_custom_target(DTRParser echo "Creating DTRParser") + +add_custom_command( +SOURCE ${HURRICANE_SOURCE_DIR}/analogic/ParserDtrScan.ll +COMMAND ${FLEX_EXECUTABLE} +ARGS -Pdtr -o${HURRICANE_BINARY_DIR}/analogic/ParserDtrScan.cpp +${HURRICANE_SOURCE_DIR}/analogic/ParserDtrScan.ll +TARGET DTRParser +OUTPUTS ${HURRICANE_BINARY_DIR}/analogic/ParserDtrScan.cpp) + +add_custom_command( +SOURCE ${HURRICANE_SOURCE_DIR}/analogic/ParserDtrGram.yy +COMMAND ${BISON_EXECUTABLE} +ARGS -d -v -p dtr -y ${HURRICANE_SOURCE_DIR}/analogic/ParserDtrGram.yy +-o ${HURRICANE_BINARY_DIR}/analogic/ParserDtrGram.cpp +TARGET DSTParser +DEPENDS ${HURRICANE_BINARY_DIR}/analogic/ParserDtrScan.cpp +OUTPUTS ${HURRICANE_BINARY_DIR}/analogic/ParserDtrGram.cpp) + +set(DST_SRCS ${DST_SRCS} ${HURRICANE_BINARY_DIR}/analogic/ParserDtrGram.cpp +${HURRICANE_BINARY_DIR}/analogic/ParserDtrScan.cpp) + +SET_SOURCE_FILES_PROPERTIES(${HURRICANE_BINARY_DIR}/analogic/ParserDtrGram.cpp GENERATED) +SET_SOURCE_FILES_PROPERTIES(${HURRICANE_BINARY_DIR}/analogic/ParserDtrScan.cpp GENERATED) + +INCLUDE_DIRECTORIES(${HURRICANE_BINARY_DIR}/analogic/) + +add_library(analogic SHARED +${DST_SRCS} +DtrAccess.cpp +GenericDtrAccess.cpp +GenV1Trans.cpp +MetaTransistor.cpp +RdsUnit.cpp +Transistor.cpp +TwoSpaces.cpp) + +install(FILES ${includes} DESTINATION /include/hurricane) +install(TARGETS analogic DESTINATION /lib) diff --git a/hurricane/src/analogic/DtrAccess.cpp b/hurricane/src/analogic/DtrAccess.cpp new file mode 100644 index 00000000..27edf511 --- /dev/null +++ b/hurricane/src/analogic/DtrAccess.cpp @@ -0,0 +1,307 @@ +// **************************************************************************************************** +// File: DtrAccess.cpp +// Authors: Wu YiFei +// Date : 21/12/2006 +// **************************************************************************************************** + +#include "DtrAccess.h" +#include "RdsUnit.h" +#include "Error.h" + +#include "DataBase.h" +#include "Technology.h" + +extern void ParseDtr(const char*, Hurricane::DtrAccess*); + + +BEGIN_NAMESPACE_HURRICANE + + +// **************************************************************************************************** +// DtrAccess implementation +// **************************************************************************************************** + + +// static data defintion +// ********************* +DtrAccess* DtrAccess::_instance = NULL; + +map DtrAccess::_registry; + +DtrAccess::DtrAccess() +// ******************* +{ +} + + +DtrAccess * DtrAccess::Create() +// ***************************** +{ + DtrAccess * dtraccess = new DtrAccess(); + + dtraccess->_PostCreate(); + + return dtraccess; +} + + +void DtrAccess::_PostCreate() +// ************************** +{ + const char * dtrfilename = getenv("DTR_FILE"); + if(!dtrfilename) { + throw Error("Can't not get Macro DTR_FILE."); + } + + // Use API of DtrParser for get technology informations + // **************************************************** + ParseDtr(dtrfilename, this); + + // Traduit Micro to RdsUnit + // ************************ + map >::iterator it_rulemap = _label2ruleMap.begin(), + it_end_rulemap = _label2ruleMap.end(); + + while(it_rulemap!=it_end_rulemap) { + + list::iterator m = ((*it_rulemap).second).begin() + , n = ((*it_rulemap).second).end(); + + while(m!=n) { + _label2RdsRuleMap[(*it_rulemap).first].push_back(ConvertRealToRdsUnit(*m)); + m++; + } + it_rulemap++; + } + + // Get Objet Layer from Technology with its name. + // ********************************************** + + DataBase * db = GetDataBase(); + + if(!db) throw Error("In GetV1Trans::Generate : can't find DataBase."); + + Technology * tech = db->GetTechnology(); + + map >::iterator it_layermap = _label2layerNameMap.begin(), + it_end_layermap = _label2layerNameMap.end(); + + while(it_layermap != it_end_layermap) { + + list::iterator m = (*it_layermap).second.begin(), + n = (*it_layermap).second.end(); + + while(m!=n) { + Layer * layer = tech->GetLayer(Name(*m)); + if(!layer) { + throw Error("Error : in function DtrAccess::_PostCreate , Can't find Layer " + + GetString(*m) + " in technology file when parser DtrFile."); +// cerr << Warning("In function DtrAccess::_PostCreate , Can't find Layer " +// + GetString(*m) + " in technology file when parser DtrFile"); + } + + _label2layerMap[(*it_layermap).first].push_back(layer); + m++; + } + it_layermap++; + } + +} + + +DtrAccess * DtrAccess::Instance() +// ***************************** +{ + // User or environnement supplies this at startup + // ********************************************** + const char * singleton_name = getenv("DTRACCESS_SINGLETON"); + + if(!singleton_name) { // if MACRO IS INVALID + if(!_instance) { + _instance = DtrAccess::Create(); + } + } + else { + if(!_instance){ + if( !(_instance=LookUp(string(singleton_name))) ) // if singleton hasn't been registered + _instance = DtrAccess::Create(); + } + } + + return _instance; +} + + +void DtrAccess::_PreDelete() +// *********************** +{ + // Do something + // ************ +} + + +void DtrAccess::Delete() +// ******************** +{ + _PreDelete(); + delete this; +} + + +GenericCollection DtrAccess::GetRuleByLabel(const string& label) const +// *************************************************************************** +{ + map >::const_iterator i = _label2ruleMap.find(label); + + if(i==_label2ruleMap.end()) + throw Error("Can't find in DtrFile rule the label : " + GetString(label)); + + return GetCollection((*i).second); +} + + +GenericCollection DtrAccess::GetRdsRuleByLabel(const string& label) const +// ****************************************************************************** +{ + map >::const_iterator i = _label2RdsRuleMap.find(label); + + if(i==_label2RdsRuleMap.end()) + throw Error("Can't find in DtrFile The Rds Value of Rule by label : " + GetString(label)); + + return GetCollection((*i).second); +} + + +GenericCollection DtrAccess::GetLayerNamesByLabel(const string& label) const +// ********************************************************************************* +{ + map >::const_iterator i = _label2layerNameMap.find(label); + + if(i==_label2layerNameMap.end()) + throw Error("Can't find in DtrFile layers the label : " + label); + + return GetCollection((*i).second); +} + + +GenericCollection DtrAccess::GetLayersByLabel(const string& label) const +// ****************************************************************************** +{ + map >::const_iterator i = _label2layerMap.find(label); + + if(i==_label2layerMap.end()) + throw Error("Can't find in DtrFile objet Layer by label : " + label ); + + return GetCollection((*i).second); +} + + +GenericCollection DtrAccess::GetElectricalsByLabel(const string& label) const +// ********************************************************************************** +{ + map >::const_iterator i = _label2electricalMap.find(label); + + if(i==_label2electricalMap.end()) + throw Error("Can't find in DtrFile electricals by label : " + label); + + return GetCollection((*i).second); +} + + +int DtrAccess::GetModellingByLabel(const string& label) const +// ********************************************************** +{ + map::const_iterator i = _label2modellingMap.find(label); + + if(i==_label2modellingMap.end()) + throw Error("Can't find in DtrFile modelling by label : " + GetString(label)); + + return (*i).second; +} + + +double DtrAccess::GetSimpleCapaMimByLabel(const string& label) const +// **************************************************************** +{ + map::const_iterator i = _label2simplecapamimMap.find(label); + + if(i==_label2simplecapamimMap.end()) + throw Error("Can't find in DtrFile simple capa mim by label : " + GetString(label)); + + return (*i).second; +} + + +// ------------------------------------------------------ +// Function "DtrAccess::LookUp(const string&)". +// + + /* \static DtrAccess* DtrAccess::LookUp(const string& singletonname) + * \param singletonname normally the name of derive class of DtrAccess. + * \return addresse of objet singleton of derive class if success. + * NULL if failure. + * + * Find the singleton objet if it exist according to the singletonname. + * + */ + +DtrAccess* DtrAccess::LookUp(const string& singletonname) +// ****************************************************** +{ + map::iterator i = _registry.find(singletonname); + + if(i==_registry.end()) + return NULL; + + return (*i).second; +} + + +// ------------------------------------------------------------------------ +// Function Register(const string&, DtrAccess*) + + /* \void DtrAccess::Register(const string& singletonname, DtrAccess* dtraccess) + * \param singletonname the name of derive class. + * \param dtraccess addresse of objet singleton of derive class. + * + * + * This function is to be called when the singleton objet of derive class is + * created. + * + */ + +void DtrAccess::Register(const string& singletonname, DtrAccess* dtraccess) +// ************************************************************************* +{ + _registry[singletonname]=dtraccess; +} + + +string DtrAccess::_GetString() const +// ********************************** +{ + string s("Singleton DtrAccess"); + return s; +} + + +Record* DtrAccess::_GetRecord() const +// ********************************** +{ + Record* record = new Record(_GetString()); + return record; +} + +END_NAMESPACE_HURRICANE + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +string GetString(const H::DtrAccess& access) +// ********************************************** +{ + return access._GetString(); +} + + diff --git a/hurricane/src/analogic/DtrAccess.h b/hurricane/src/analogic/DtrAccess.h new file mode 100644 index 00000000..fe660bbe --- /dev/null +++ b/hurricane/src/analogic/DtrAccess.h @@ -0,0 +1,187 @@ +// **************************************************************************************************** +// File: DtrAccess.h +// Authors: Wu YiFei +// Date : 21/12/2006 +// **************************************************************************************************** + +#ifndef HURRICANE_DTRACCESS +#define HURRICANE_DTRACCESS + +#include "Layer.h" +#include "Layers.h" + +//BEGIN_NAMESPACE_HURRICANE + + +namespace Hurricane { + +class DtrAccess { +// ************** + +// Types +// ***** + +# if !defined(__DOXYGEN_PROCESSOR__) +// Attributes +// ********** + private : static DtrAccess * _instance; + + private : map > _label2ruleMap; + private : map > _label2layerNameMap; + private : map > _label2electricalMap; + private : map _label2modellingMap; + private : map _label2simplecapamimMap; + + private : map > _label2RdsRuleMap; + private : map > _label2layerMap; + + + // For reusability of software + // *************************** + private : static map _registry; + + +// Constructors +// ************ + protected : DtrAccess(); + private : DtrAccess(const DtrAccess&); + private : DtrAccess& operator=(const DtrAccess&); + + protected : static DtrAccess * Create(); + protected : virtual void _PostCreate(); +# endif + + public : static DtrAccess* Instance(); + +// Destructors +// *********** +# if !defined(__DOXYGEN_PROCESSOR__) + protected : virtual ~DtrAccess() {}; + protected : virtual void _PreDelete(); +# endif + + + public : virtual void Delete(); + + +// Accessors +// ********* + + // If can't find data , throw Hurricane::Error + // ******************************************* + public : GenericCollection GetRuleByLabel(const string&) const; + public : GenericCollection GetRdsRuleByLabel(const string&) const; + public : GenericCollection GetLayerNamesByLabel(const string&) const; + public : Layers GetLayersByLabel(const string&) const; + public : GenericCollection GetElectricalsByLabel(const string& ) const; + public : int GetModellingByLabel(const string&) const; + public : double GetSimpleCapaMimByLabel(const string&) const; + + +# if !defined(__DOXYGEN_PROCESSOR__) + public : double GetSingleRealRuleByLabel(const string& s) const + // ************************************************* + { + GenericLocator locator = GetRuleByLabel(s).GetLocator(); + return locator.GetElement(); + } + + public : long GetSingleRdsRuleByLabel(const string& s) const + // ************************************************ + { + GenericLocator locator = GetRdsRuleByLabel(s).GetLocator(); + return locator.GetElement(); + } + + public : string GetSingleLayerNameByLabel(const string& s) const + // **************************************************** + { + GenericLocator locator = GetLayerNamesByLabel(s).GetLocator(); + return locator.GetElement(); + } + + public : Layer* GetSingleLayerByLabel(const string& s) const + // ************************************************ + { + LayerLocator locator = GetLayersByLabel(s).GetLocator(); + return locator.GetElement(); + } + + public : double GetSingleRealRuleByLabel(char* prefix, const string& type, char* suffix) const + // ********************************************************************************** + { + return GetSingleRealRuleByLabel(prefix + type + suffix); + } + + public : long GetSingleRdsRuleByLabel(char* prefix, const string& type, char* suffix) const + // ******************************************************************************* + { + return GetSingleRdsRuleByLabel(prefix + type + suffix); + } + + public : string GetSingleLayerNameByLabel(char* prefix, const string& type, const string& suffix) const + // ************************************************************************************ + { + return GetSingleLayerNameByLabel(prefix + type + suffix); + } + + + public : Layer* GetSingleLayerByLabel(char* prefix, const string& type, const string& suffix) const + // *************************************************************************************** + { + return GetSingleLayerByLabel(prefix + type + suffix); + } + +# endif + +// Updators +// ******** + public : void AddRuleByLabel(const string& label, const list& rule){ _label2ruleMap[label]=rule; }; + public : void AddLayersByLabel(const string& label, const list& layers) { _label2layerNameMap[label]=layers; }; + public : void AddElectricalsByLabel(const string& label, const list& electricals) + { _label2electricalMap[label]=electricals; }; + + public : void AddModellingByLabel(const string& label, const int modelling) { _label2modellingMap[label]=modelling; }; + public : void AddSimpleCapaMimByLabel(const string& label, const double capamim) { _label2simplecapamimMap[label]=capamim; }; + +// Operations +// ********** + + // For reusability of software + // *************************** + protected : static DtrAccess* LookUp(const string&); + protected : static void Register(const string& , DtrAccess* ); + + +# if !defined(__DOXYGEN_PROCESSOR__) +// Others +// ****** + public: virtual string _GetTypeName() const {return _TName("DtrAccess");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: map >& _GetLabel2RuleMap() { return _label2ruleMap; }; + public: map >& _GetLabel2LayerNameMap() { return _label2layerNameMap; }; + public: map >& _GetLabel2ElectricalMap() + { return _label2electricalMap; }; + public: map& _GetLabel2ModellingMap() { return _label2modellingMap; }; + public: map& _GetLabel2SimpleCapaMimMap() + { return _label2simplecapamimMap; }; +# endif + +}; + +} + + +//END_NAMESPACE_HURRICANE + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +string GetString(const H::DtrAccess&); + + +#endif // HURRICANE_DTRACCESS diff --git a/hurricane/src/analogic/GenTrans.h b/hurricane/src/analogic/GenTrans.h new file mode 100644 index 00000000..fa56ae80 --- /dev/null +++ b/hurricane/src/analogic/GenTrans.h @@ -0,0 +1,220 @@ +// **************************************************************************************************** +// File: GenTrans.h +// Authors: Wu YiFei +// Date : 04/04/2007 +// **************************************************************************************************** + + +#ifndef HURRICANE_GENTRANS +#define HURRICANE_GENTRANS + + +#include "Transistor.h" +#include "Box.h" + + +// -------------------------------------------------------------------- +// Macro Method : "MAXLONG(a,b), MINLONG(a,b)" +// Comparaison Method Macro For Calculate Rectangles. + +# define MAXLONG(a,b) (a>b?a:b) +# define MINLONG(a,b) (a>b?b:a) + + +// -------------------------------------------------------------------- +// Macro Method : "GET_RULE(s)" +// This Method Macro is For Geting The Value in RdsUnit of a DRM Rule. +// To Use This Macro, you must predefine Pointeur dtraccess. + +# define GET_RULE(s) \ + dtraccess->GetSingleRdsRuleByLabel(string(s)) + + + +// -------------------------------------------------------------------- +// Macro Method "GET_RULE_BYNP(prefix, type, suffix)" +// This Method Macro is For Geting The Value in RdsUnit of a DRM Rule +// selected by string type which is mostype . + + /* \prefix must be a chain character. + * \type mos type('N'/'P'), must be a string. + * \suffix must be a chain character. + */ + +// To Use This Macro, you must Predefine Pointeur dtraccess. + +# define GET_RULE_BYNP(prefix, type, suffix) \ + dtraccess->GetSingleRdsRuleByLabel(prefix, type, suffix) + + + +// -------------------------------------------------------------------- +// Macro Method : "Get_LAYER_BYNP(prefix, type, suffix)" +// This Method Macro is For Geting the Layer of a Layer Rule Selected +// by string type which is mostype. To Use This Macro, you must predefine +// Pointeur dtraccess. + + /* \prefix must be a chain of character. + * \type mos type('N'/'P'), must be a string. + * \suffix must be a string. + */ + +// To Use This Macro, you must Predefine Pointeur dtraccess. + +# define GET_LAYER_BYNP(prefix, type, suffix) \ + dtraccess->GetSingleLayerByLabel(prefix, type, suffix) + + + +// -------------------------------------------------------------------- +// Macro Method : "SAVE_RECTANGLE(S, x, y, dx, dy)" +// This Method Macro is For Saving A Rectangle in a map . + + /* \s name of rectangle, must be a chain of character. + * \x xmin, must be a long. + * \y ymin, must be a long. + * \dx width, must be a long. + * \dy height, must be a long. + */ + +// This Method Macro must be used in Membre Function Calculate. + +# define SAVE_RECTANGLE(s, x, y, dx, dy) \ + _mapString2Box[string(s)] = Box(GetUnit(x), GetUnit(y), GetUnit(x+dx), GetUnit(y+dy)); \ + xmin = MINLONG(xmin, GetUnit(x)); \ + ymin = MINLONG(ymin, GetUnit(y)); + + +// -------------------------------------------------------------------- +// Macro Method : "GET_BOX(s)" +// This Method Macro is For Get the box According to the its name. + + /* + * \s name of rectangle, must be a string. + */ + +// This Method Macro must be used in member function of Class GenTrans. +// + +# define GET_BOX(s) \ + _mapString2Box[s] + + +// --------------------------------------------------------------------- +// Macro Method : "CREATE_CONTACT_MATRIX_UNDER(boxname, nbcolumn, layer, net)" +// This Method Macro is For Create a matrix of Contact under a zone for +// a net specified. + + /* \underbox A rectangle under which contacts will be placed, must be a objet Box. + * \nbcolumn the number of column, must be a integer. + * \layer the layer of contact, must be a pointer of type Layer*. + * \net the net to be hooked, must be a pointer of type Net*. + */ + +// To use this Macro Function. You Must also définir variable nbcontact, +// tmp_xcenter, tmp_ycenter, rw_cont, rd_cont. +// + +# define CREATE_CONTACT_MATRIX_UNDER(underbox, nbcolumn, layer, net) \ + \ + if(underbox.GetHeight() _mapString2Box; + + +// Constructors +// ************* + public : GenTrans() {}; + +// Destructors +// *********** + public : virtual ~GenTrans() {}; + +// Operators +// ********** + public : virtual void Calculate(Transistor*) = 0; + public : virtual void Generate(Transistor*) = 0; + +}; + + +class GenV1Trans : public GenTrans { +// ********************************* + +// Types +// ***** + public : typedef GenTrans Inherit; + +// Attributs +// ********* + public : const Transistor::MaskV1Info* _masqueV1Info; + +// Constructors +// ************ + public : GenV1Trans(Transistor::MaskV1Info*); + +// Destructors +// ************ + public : virtual ~GenV1Trans() {}; + +// Operators +// ********* + public : virtual void Calculate(Transistor*) ; + public : virtual void Generate(Transistor*) ; + +}; + + +END_NAMESPACE_HURRICANE + +#endif diff --git a/hurricane/src/analogic/GenV1Trans.cpp b/hurricane/src/analogic/GenV1Trans.cpp new file mode 100644 index 00000000..5db3f615 --- /dev/null +++ b/hurricane/src/analogic/GenV1Trans.cpp @@ -0,0 +1,539 @@ +// **************************************************************************************************** +// File: GenV1Trans.cpp +// Authors: Wu YiFei +// Date : 04/04/2007 +// **************************************************************************************************** + +#include "Collection.h" +#include "RdsUnit.h" +#include "GenTrans.h" +#include "DtrAccess.h" +#include "GenericDtrAccess.h" + +#include "Technology.h" +#include "UpdateSession.h" + +#include "DataBase.h" + + + +BEGIN_NAMESPACE_HURRICANE + + + +// **************************************************************************************************** +// Globals Datas +// **************************************************************************************************** +string segsforsource[] = {string("20"), string("23")}; +string segsfordrain[] = {string("40"), string("43")}; +string segsforgrid[] = {string("00"), string("01"), string("30"), string("31")}; +//string segsforgrid[] = {string("00"), string("30") }; +string segsforanonym[] = {string("10"), string("11"), string("12"), string("50")}; + + +// **************************************************************************************************** +// Class GetV1Trans implementation +// **************************************************************************************************** +GenV1Trans::GenV1Trans(Transistor::MaskV1Info* masqueinfo) +// ********************************************************* +: _masqueV1Info(masqueinfo) +{ +} + + +void GenV1Trans::Calculate(Transistor* transistor) +// ********************************************** +{ + DtrAccess * dtraccess = DtrAccess::Instance(); + + // Check out mask param. + // ********************* + if(_masqueV1Info->GetL() < dtraccess->GetSingleRealRuleByLabel("L_TRANS") || + _masqueV1Info->GetL() > dtraccess->GetSingleRealRuleByLabel("L_TRANS_MAX") || + _masqueV1Info->GetW() < dtraccess->GetSingleRealRuleByLabel("W_TRANS") || + _masqueV1Info->GetW() > dtraccess->GetSingleRealRuleByLabel("W_TRANS_MAX") ) + + throw Error("Can't launch function GenV1Trans::Calculate for " + GetString(transistor) + + " the L " + GetString(_masqueV1Info->GetL()) + + " or the W " + GetString(_masqueV1Info->GetW()) + + " of this transistor is invalid." + ); + + if(_masqueV1Info->GetNbSourceColumn() < 1 || _masqueV1Info->GetNbSourceColumn() > MAXNBCONTACT || + _masqueV1Info->GetNbDrainColumn() < 1 || _masqueV1Info->GetNbDrainColumn() > MAXNBCONTACT ) + + throw Error("Can't launch function GenV1Trans::Calculate for " + GetString(transistor) + + " the nbsourcecolumn " + GetString(_masqueV1Info->GetNbSourceColumn()) + + " or the nbdraincolumn " + GetString(_masqueV1Info->GetNbDrainColumn()) + + " of this transistor is invalid." + ); + + IF_DEBUG_HUR_ANALOG + cout << ts << GetString(transistor) + " 's masqueinfo is " + GetString(_masqueV1Info) + << endl; + END_IF + + + // Tempory Variable. + // ************************** + long x00, y00, dx00, dy00; + long x10, y10, dx10, dy10; + long x11, y11, dx11, dy11; + long x12, y12, dx12, dy12; + long x20, y20, dx20, dy20; + long x23, y23, dx23, dy23; + long x30, y30, dx30, dy30; + long x31, y31, dx31, dy31; + long x01, y01, dx01, dy01; + long x40, y40, dx40, dy40; + long x43, y43, dx43, dy43; + long x50, y50, dx50, dy50; + + long xmin = 999999L, ymin = 999999L; + long realw = 0; + + // Tempory Variable. + // ************************** + long extension1 = 0; + long extension2 = 0; + long extension3 = 0; + long extension4 = 0; + long ymax = 0; + string mostype; // Get Mos Type (N/P). + + if(transistor->IsNmos()) + mostype='N'; + else + mostype='P'; + + //string mostype; // Get Mos Type (N/P). + //mostype=transistor->GetType(); + + // ------------------------------------------------------------- + // Begin Calculate. + + //long re_imp_acti = GET_RULE_BYNP("RE_", mostype, "IMP_ACTI"); + long re_imp_acti = GET_RULE_BYNP("RE_", mostype, "IMP_ACTI"); + long re_imp_poly = GET_RULE_BYNP("RE_", mostype, "IMP_POLY"); + long re_imp_cont = GET_RULE_BYNP("RE_", mostype, "IMP_CONT"); + long re_imp_gate = GET_RULE_BYNP("RE_", mostype, "IMP_GATE"); + //long re_well_acti = GET_RULE_BYNP("RE_", mostype, "WELL_ACTI"); + + // Calculate Rectangle 00 + // ********************** + x00 = 0; + y00 = -( GET_RULE("RE_GATE_ACTI") ); + + dx00 = ConvertRealToRdsUnit(_masqueV1Info->GetL()); + realw = ConvertRealToRdsUnit(_masqueV1Info->GetW()); + + dy00 = realw + 2*(-y00); + + SAVE_RECTANGLE("00", x00, y00, dx00, dy00) + + + // Calculate Rectangle 30 + // ********************** + +// cout << "RD_ACTI_CONT is " << GET_RULE("RD_ACTI_CONT")<= dx00) { + dx30 = GET_RULE("RW_CONT"); + dy30 = dx30; + y30 = 0 + realw + MAXLONG(GET_RULE("RD_ACTI_CONT"), GET_RULE("RD_ACTI_POLY") + GET_RULE("RE_POLY_CONT")); + } + else { + dx30 = dx00 - 2*GET_RULE("RE_POLY_CONT"); + dy30 = GET_RULE("RW_CONT"); + y30 = 0 + realw + GET_RULE("RD_ACTI_CONT"); + } + + x30 = x00 + dx00/2 - dx30/2; + + SAVE_RECTANGLE("30", x30, y30, dx30, dy30) + + + // Calculate Rectangle 31 + // ********************** + dx31 = dx30 + 2*GET_RULE("RE_POLY_CONT"); + dy31 = dy30 + 2*GET_RULE("RE_POLY_CONT"); + x31 = x30 - GET_RULE("RE_POLY_CONT"); + y31 = y30 - GET_RULE("RE_POLY_CONT"); + + SAVE_RECTANGLE("31", x31, y31, dx31, dy31) + + + // Calculate Rectangle 01 + // ********************** + if ( y31 <= (y00+dy00) ) { + x01 = 0; y01 = 0; dx01 = 0; dy01 = 0; + } + else { + x01 = x00; + y01 = y00 + dy00; + dx01 = dx00; + dy01 = y31 - (y00 + dy00); + } + + SAVE_RECTANGLE("01", x01, y01, dx01, dy01) + + + // Calculate Rectangle 12 + // ********************** + x12 = MINLONG(x31, x00) - re_imp_poly; + y12 = MINLONG(0 - re_imp_acti, y00 - re_imp_poly); + dx12 = MAXLONG(dx31, dx00) + 2 * re_imp_poly; + + ymax = MAXLONG( MAXLONG( y30 + dy30 + re_imp_cont + , MAXLONG(y31 + dy31, y00 + dy00) + re_imp_poly ) + , realw + re_imp_acti ); + + dy12 = ymax - y12 ; + + SAVE_RECTANGLE("12", x12, y12, dx12, dy12) + + + // Calculate Rectangle 20 + // ********************** + y20 = 0 + GET_RULE("RE_ACTI_CONT"); + dy20 = realw - 2 * GET_RULE("RE_ACTI_CONT"); + dx20 = (_masqueV1Info->GetNbSourceColumn()) * GET_RULE("RW_CONT") + + ((_masqueV1Info->GetNbSourceColumn()) - 1) * GET_RULE("RD_CONT"); + x20 = 0 - ( dx20 + GET_RULE("RD_CONT_GATE") ); + + SAVE_RECTANGLE("20", x20, y20, dx20, dy20) + + + // Calculate Rectangle 40 + // ********************** + y40 = y20; + x40 = x00 + dx00 + GET_RULE("RD_CONT_GATE"); + dx40 = (_masqueV1Info->GetNbDrainColumn()) * GET_RULE("RW_CONT") + + ((_masqueV1Info->GetNbDrainColumn()) - 1) * GET_RULE("RD_CONT"); + dy40 = dy20; + + SAVE_RECTANGLE("40", x40, y40, dx40, dy40) + + // Calculate Rectangle 10 + // ********************** + y10 = 0; + x10 = MINLONG(x20 - GET_RULE("RE_ACTI_CONT"), 0 - GET_RULE("RE_ACTI_GATE")); + dy10 = realw; + + extension1 = MAXLONG(0 + x40 + dx40 + GET_RULE("RE_ACTI_CONT"), dx00 + GET_RULE("RE_ACTI_GATE")); + + dx10 = 0 - x10 + extension1; + + SAVE_RECTANGLE("10", x10, y10, dx10, dy10) + + + // Calculate Rectangle 23 + // *********************** + x23 = x10; + y23 = y10; + dx23 = 0 - x10; + dy23 = realw; + + SAVE_RECTANGLE("23", x23, y23, dx23, dy23) + + + // Calculate Rectangle 43 + // ********************** + x43 = x00 + dx00 ; + y43 = y10; + dx43 = x10 + dx10 - (x00 + dx00); + dy43 = realw; + + SAVE_RECTANGLE("43", x43, y43, dx43, dy43) + + + // Calculate Rectangle 11 + // ********************** + extension1 = re_imp_gate; + extension2 = re_imp_cont + 0 - x20; + extension3 = re_imp_acti + 0 - x10; + + extension4 = MAXLONG(MAXLONG(extension1, extension2), extension3); + + x11 = 0 - extension4; + + extension1 = re_imp_gate + x00 + dx00; + extension2 = re_imp_cont + x40 + dx40; + extension3 = re_imp_acti + x10 + dx10; + + extension4 = MAXLONG(MAXLONG(extension1, extension2), extension3); + + dx11 = 0 - x11 + extension4; + + y11 = MINLONG(y20 - re_imp_cont, y23 - re_imp_acti); + + ymax = MAXLONG(y20 + dy20 + re_imp_cont, y23 + dy23 + re_imp_acti); + + dy11 = ymax - y11; + + SAVE_RECTANGLE("11", x11, y11, dx11, dy11); + + + // Calculate Rectangle 50 just for PMOS. + // ------------------------------------------------------------- + if (transistor->IsPmos()) { // Calculate Rectangle 50 for PMos. + x50 = x10 - GET_RULE("RE_NWELL_ACTI"); + y50 = y10 - GET_RULE("RE_NWELL_ACTI"); + dx50 = dx10 + 2 * GET_RULE("RE_NWELL_ACTI"); + dy50 = dy10 + 2 * GET_RULE("RE_NWELL_ACTI"); + + SAVE_RECTANGLE("50", x50, y50, dx50, dy50); + } + + // End Calculate. + // ------------------------------------------------------------- + + // Translate rectangles. + // ********************* + map::iterator i = _mapString2Box.begin(), + j = _mapString2Box.end(); + + while(i!=j) { + _mapString2Box[(*i).first] = (*i).second.Translate(-xmin, -ymin); + + IF_DEBUG_HUR_ANALOG + cout << ts << (*i).first <<" " << GetString((*i).second) << endl; + END_IF + + assert(BOX_IS_VALID((*i).second)); + i++; + } + +} + + +void GenV1Trans::Generate(Transistor* transistor) +// ********************************************* +{ + OpenUpdateSession(); + + Net* source = transistor->GetNet(Name(transistor->GetSourceName())); + Net* drain = transistor->GetNet(Name(transistor->GetDrainName()) ); + Net* grid = transistor->GetNet(Name(transistor->GetGridName()) ); + + DtrAccess * dtraccess = DtrAccess::Instance(); + //string mostype(1, transistor->GetType()); // Get Mos Type (N/P). + + string mostype; // Get Mos Type (N/P). + + if(transistor->IsNmos()) + mostype='N'; + else + mostype='P'; + + long rw_cont = GetUnit(GET_RULE("RW_CONT")); + long rd_cont = GetUnit(GET_RULE("RD_CONT")); + unsigned nbcontact = 0; + long tmp_xcenter = 0; + long tmp_ycenter = 0; + + DataBase * db = GetDataBase(); + + if(!db) throw Error("In GetV1Trans::Generate : can't find DataBase"); + + //Technology * tech = db->GetTechnology(); + + Layer * layer_20 = GET_LAYER_BYNP("TRANS_",mostype,"_LAYER_20"); + Layer * layer_30 = GET_LAYER_BYNP("TRANS_",mostype,"_LAYER_30"); + Layer * layer_40 = GET_LAYER_BYNP("TRANS_",mostype,"_LAYER_40"); + + + // ------------------------------------------------------------- + // Begin Generation. + + // Cenerate Components For Net Source. + // *********************************** +IF_DEBUG_HUR_ANALOG + cout << ts << "Begin for create components for net Source of " << GetString(transistor) << endl; +END_IF + + for(size_t i=0; iGetNbSourceColumn(), layer_20, source) + //cout << ts << " Finish create contact for source " <GetNbDrainColumn(), layer_40, drain) + //cout << ts << " Finish create contact for drain" <IsNmos() && segsforanonym[i]=="50") + continue; + + Contact::Create(anonym, GET_LAYER_BYNP("TRANS_",mostype,"_LAYER_"+segsforanonym[i]) + , GET_BOX(segsforanonym[i]).GetXCenter() + , GET_BOX(segsforanonym[i]).GetYCenter() + , GET_BOX(segsforanonym[i]).GetWidth() + , GET_BOX(segsforanonym[i]).GetHeight() + ); + } + +IF_DEBUG_HUR_ANALOG + cout << ts << "End for create components for net Anonyme of " << GetString(transistor) << endl; +END_IF + + // End Generation. + // ------------------------------------------------------------- + + CloseUpdateSession(); + + // Set Transistor::_mapNet2Box. + // **************************** + (*(transistor->_GetMapNet2Box()))[grid] = _mapString2Box[string("30")]; + (*(transistor->_GetMapNet2Box()))[source] = _mapString2Box[string("20")]; + (*(transistor->_GetMapNet2Box()))[drain] = _mapString2Box[string("40")]; + + cout<< GetString(_mapString2Box[string("30")]) <GetAbutmentType().GetCode()) { + + case Transistor::Type::INTERNAL : + transistor->SetAbutmentBox( Box(GET_BOX(string("20")).GetXCenter() + , transistor->GetBoundingBox().GetYMin() + , GET_BOX(string("40")).GetXCenter() + , transistor->GetBoundingBox().GetYMax() + ) + ); + break; + + case Transistor::Type::LEFT: + transistor->SetAbutmentBox( Box(GET_BOX(string("11")).GetXMin() + , transistor->GetBoundingBox().GetYMin() + , GET_BOX(string("40")).GetXCenter() + , transistor->GetBoundingBox().GetYMax() + ) + ); + break ; + + case Transistor::Type::RIGHT: + transistor->SetAbutmentBox( Box(GET_BOX(string("20")).GetXCenter() + , transistor->GetBoundingBox().GetYMin() + , GET_BOX(string("11")).GetXMax() + , transistor->GetBoundingBox().GetYMax() + ) + ); + break ; + + case Transistor::Type::SINGLE: + transistor->SetAbutmentBox( Box(GET_BOX(string("11")).GetXMin() + , transistor->GetBoundingBox().GetYMin() + , GET_BOX(string("11")).GetXMax() + , transistor->GetBoundingBox().GetYMax() + ) + ); + break ; + + default : + break; + } + + +} + + +END_NAMESPACE_HURRICANE diff --git a/hurricane/src/analogic/GenericDtrAccess.cpp b/hurricane/src/analogic/GenericDtrAccess.cpp new file mode 100644 index 00000000..875592e4 --- /dev/null +++ b/hurricane/src/analogic/GenericDtrAccess.cpp @@ -0,0 +1,61 @@ +// **************************************************************************************************** +// File: GenericDtrAccess.cpp +// Authors: Wu YiFei +// Date : 21/12/2006 +// **************************************************************************************************** + +#include "DtrAccess.h" +#include "GenericDtrAccess.h" +//#include "DtrAccess.h" + +BEGIN_NAMESPACE_HURRICANE + + +// **************************************************************************************************** +// GenericDtrAccess implementation +// **************************************************************************************************** + +GenericDtrAccess GenericDtrAccess::instance(NULL); + +GenericDtrAccess::GenericDtrAccess(DtrAccess* dtraccess):_dtrAccess(dtraccess) +// ************************************************************************** +{ +} + +void GenericDtrAccess::Instance(DtrAccess* dtraccess) +// ************************************************** +{ + if(!(instance._dtrAccess)) + instance._dtrAccess = dtraccess; +} + +GenericDtrAccess::~GenericDtrAccess() +// ********************************* +{ + if(_dtrAccess) { cout<Delete();} +} + + +string GenericDtrAccess::_GetString() const +// **************************************** +{ + string s("Singleton GenericDtrAccess"); + return s; + +} + +END_NAMESPACE_HURRICANE + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +string GetString(const H::GenericDtrAccess& access) +// ************************************************ +{ + return access._GetString(); +} + + diff --git a/hurricane/src/analogic/GenericDtrAccess.h b/hurricane/src/analogic/GenericDtrAccess.h new file mode 100644 index 00000000..33ddc368 --- /dev/null +++ b/hurricane/src/analogic/GenericDtrAccess.h @@ -0,0 +1,80 @@ +// **************************************************************************************************** +// File: GenericDtrAccess.h +// Authors: Wu YiFei +// Date : 21/12/2006 +// **************************************************************************************************** + + +#ifndef HURRICANE_GENERICDTRACCESS +#define HURRICANE_GENERICDTRACCESS + + +//BEGIN_NAMESPACE_HURRICANE + +namespace Hurricane { + +class DtrAccess; + +class GenericDtrAccess { +// ********************* + +// Types +// ***** + +# if !defined(__DOXYGEN_PROCESSOR__) +// Attributes +// ********** + private : static GenericDtrAccess instance; + + private : DtrAccess * _dtrAccess; + + +// Constructors +// ************ + protected : GenericDtrAccess(DtrAccess*); + private : GenericDtrAccess(const GenericDtrAccess&); + private : GenericDtrAccess& operator=(const GenericDtrAccess&); + +# endif + + public : static void Instance(DtrAccess*); + +// Destructors +// *********** + protected : virtual ~GenericDtrAccess(); + +// Accessors +// ********* + + +// Updators +// ******** + +// Operations +// ********** + +# if !defined(__DOXYGEN_PROCESSOR__) +// Others +// ****** + public: virtual string _GetTypeName() const {return _TName("GenericDtrAccess");}; + public: virtual string _GetString() const; +# endif + +}; + + +//END_NAMESPACE_HURRICANE + +} + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +string GetString(const H::GenericDtrAccess&); + + +#endif // HURRICANE_GENERICDTRACCESS + + + diff --git a/hurricane/src/analogic/MetaTransistor.cpp b/hurricane/src/analogic/MetaTransistor.cpp new file mode 100644 index 00000000..ee764e40 --- /dev/null +++ b/hurricane/src/analogic/MetaTransistor.cpp @@ -0,0 +1,184 @@ +// **************************************************************************************************** +// File: MetaTransistor.cpp +// Authors: Wu YiFei +// Date : 21/12/2006 +// **************************************************************************************************** + + +#include "MetaTransistor.h" +#include "Transistor.h" +#include "Instances.h" +#include "UpdateSession.h" +#include "Vertical.h" + + +BEGIN_NAMESPACE_HURRICANE + +// **************************************************************************************************** +// MetaTransistor implementation +// **************************************************************************************************** + +MetaTransistor::MetaTransistor(Library* library, const Name& name, char type) +// ************************************************************************** +: Inherit(library, name), + _type(type), + _m(1), + _le(0.0), + _we(0.0) +{ +} + + +MetaTransistor* MetaTransistor::Create(Library* library, const Name& name, char type) +// ********************************************************************************** +{ + MetaTransistor* metatransistor = new MetaTransistor(library, name, type); + + metatransistor->_PostCreate(); + + return metatransistor; +} + + +void MetaTransistor::_PreDelete() +// ****************************** +{ + // do something + // ************ + + Inherit::_PreDelete(); +} + + +void MetaTransistor::_PostCreate() +// ******************************* +{ + Inherit::_PostCreate(); + + (Net::Create(this, Name("DRAIN")))->SetExternal(true); + (Net::Create(this, Name("SOURCE")))->SetExternal(true); + (Net::Create(this, Name("GRID")))->SetExternal(true); + (Net::Create(this, Name("BULK")))->SetExternal(true); +} + + +void MetaTransistor::CreateConnection() +// *********************************** +{ + for_each_instance(instance, this->GetInstances()) + Cell * mastercell = instance->GetMasterCell(); + + // Assurance of unique instanciation + // ********************************* + if(mastercell->_GetSlaveInstanceSet()._GetSize()!=1) { + string err_msg = "Can't create connection : " + GetString(mastercell) + " hasn't only one slave instance"; + assert(err_msg.c_str()); + } + + instance->GetPlug(mastercell->GetNet(Name("DRAIN")))->SetNet(GetNet(Name("DRAIN"))); + instance->GetPlug(mastercell->GetNet(Name("SOURCE")))->SetNet(GetNet(Name("SOURCE"))); + instance->GetPlug(mastercell->GetNet(Name("GRID")))->SetNet(GetNet(Name("GRID"))); + instance->GetPlug(mastercell->GetNet(Name("BULK")))->SetNet(GetNet(Name("BULK"))); + end_for +} + + +void MetaTransistor::CreateLayout() +// ******************************** +{ +// OpenUpdateSession(); + + if((_le == 0.0) || (_we == 0.0)) { + throw Error("Can't generate layout : " + GetString(this) + " hasn't been dimensionned"); + } + + SetTerminal(false); + + Transistor * internal_ref = NULL; + Transistor * left_ref = NULL; + Transistor * right_ref = NULL; + + for_each_instance(instance, this->GetInstances()) + Cell * mastercell = instance->GetMasterCell(); + + // Assurance of unique instanciation + // ********************************* + if(mastercell->_GetSlaveInstanceSet()._GetSize()!=1) { + string err_msg = "Can't generate layout : " + GetString(mastercell) + " hasn't only one slave instance"; + assert(err_msg.c_str()); + } + + Transistor * trans = dynamic_cast(mastercell); + if(!trans){ + string err_msg = "Can't genrate layout : " + GetString(mastercell) + " isn't a Transistor"; + } + + if(trans->IsInternal()) { + if(!internal_ref) { + trans->CreateLayout(); + internal_ref = trans; + } + else { + trans->DuplicateLayout(internal_ref); + } + } + else if(trans->IsLeft()) { + if(!left_ref) { + trans->CreateLayout(); + left_ref=trans; + } + else + trans->DuplicateLayout(left_ref); + } + else if(trans->IsRight()) { + if(!right_ref) { + trans->CreateLayout(); + right_ref=trans; + } + else + trans->DuplicateLayout(right_ref); + } + else + trans->CreateLayout(); + end_for + + + Materialize(); + // CloseUpdateSession(); + +} + + +void MetaTransistor::Flush() +// ************************* +{ + OpenUpdateSession(); + for_each_instance(instance, this->GetInstances()) + Cell * mastercell = instance->GetMasterCell(); + instance->Delete(); + mastercell->Delete(); + end_for + CloseUpdateSession(); +} + + + +string MetaTransistor::_GetString() const +// *************************************** +{ + string s= Inherit::_GetString(); + s.insert(s.length()-1, " " + GetString(GetType()) ); + s.insert(s.length()-1, " " + GetString(GetM()) ); + return s; +} + +Record* MetaTransistor::_GetRecord() const +// *************************************** +{ + Record* record = Inherit::_GetRecord(); + return record; +} + +END_NAMESPACE_HURRICANE + + diff --git a/hurricane/src/analogic/MetaTransistor.h b/hurricane/src/analogic/MetaTransistor.h new file mode 100644 index 00000000..1e617b6f --- /dev/null +++ b/hurricane/src/analogic/MetaTransistor.h @@ -0,0 +1,133 @@ +// **************************************************************************************************** +// File: MetaTransistor.h +// Authors: Wu YiFei +// Date : 21/12/2006 +// **************************************************************************************************** + +#ifndef HURRICANE_METATRANSISTOR +#define HURRICANE_METATRANSISTOR + +#include "Cell.h" +#include "AnalogicalCommons.h" + + +//BEGIN_NAMESPACE_HURRICANE + +namespace Hurricane { + +class Library; +class Name; +class Symbol; +class Record; + +class MetaTransistor: public Cell { +// ******************************** + + +// Types +// ***** + public : typedef Cell Inherit; + +# if !defined(__DOXYGEN_PROCESSOR__) + +// Logicals Attributes +// ******************* + private : char _type; + private : unsigned _m; + private : Micro _le, _we; // length and width expected + private : Micro _lr, _wr; // real length and real width + private : unsigned _nSex, _nDex, nSin, _nDin, _nSsh, _nDsh; + private : Micro _dgg, _de; + private : MicroPower2 _as, _ad; + private : Micro _ps, _pd; + private : double _capaDrain, _capaGate, _capaSource; + private : double _cgb, _cgs, _cdb, _cds, _csb, _cgd; + + +// Behaviorals attributes +// ********************** + private : double _temp, _vds, _vgs; // DC + private : double _vg, _vd, _vs, _vb; + private : char _region; + private : double _ids; + private : double _vth, _vdsat; // AC + +# endif + +// Constructors +// ************ +# if !defined(__DOXYGEN_PROCESSOR__) + protected : MetaTransistor(Library* library, const Name& name, char type); +# endif + + public : static MetaTransistor* Create(Library* library, const Name& name, char type); + +# if !defined(__DOXYGEN_PROCESSOR__) + protected : virtual void _PostCreate(); + + +// Destructors +// *********** + protected : ~MetaTransistor() {}; + protected : virtual void _PreDelete(); +# endif + +// Operations +// ********** + + // Create the connection between all instances. + // ******************************************** + public : void CreateConnection(); + + // Create the layout of all motifs in this metatransistor. + // ******************************************************* + public : void CreateLayout(); + + +# if !defined(__DOXYGEN_PROCESSOR__) + // Get all paramters after generation of Layout (capa..). + // ***************************************************** + public : void GetParameterOfGeneration() { /* to do */}; + + // Delete all instances and all motifs in this metatransistor. + // *********************************************************** + public : void Flush(); +# endif + + +// Accessors +// ********* + public : const Micro& GetLe() const { return _le; }; + public : const Micro& GetWe() const { return _we; }; + public : const char GetType() const { return _type; }; + public : const unsigned GetM() const { return _m; }; + + +// Updators +// ******** + public : void SetLe (const Micro le) { _le=le; }; + public : void SetWe (const Micro we) { _we=we; }; + public : void SetType(const char type) { _type=type; }; + public : void SetM (const unsigned m) { _m=m; }; + + +//#endif + +# if !defined(__DOXYGEN_PROCESSOR__) +// Others +// ****** + public: virtual string _GetTypeName() const {return _TName("MetaTransistor");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; +# endif + +}; + + +} + +//END_NAMESPACE_HURRICANE + +#endif // HURRICANE_METATRANSISTOR + + diff --git a/hurricane/src/analogic/MetaTransistors.h b/hurricane/src/analogic/MetaTransistors.h new file mode 100644 index 00000000..786abf96 --- /dev/null +++ b/hurricane/src/analogic/MetaTransistors.h @@ -0,0 +1,59 @@ + +// **************************************************************************************************** +// File: MetaTransistors.h +// Authors: YIFEI WU +// Date : 21/12/2006 +// **************************************************************************************************** + +#ifndef HURRICANE_METATRANSISTORS +#define HURRICANE_METATRANSISTORS + +#include "Collection.h" + +BEGIN_NAMESPACE_HURRICANE + +class MetaTransistor; + + +// **************************************************************************************************** +// MetaTransistors declaration +// **************************************************************************************************** + +typedef GenericCollection MetaTransistors; + + + +// **************************************************************************************************** +// MetaTransistorLocator declaration +// **************************************************************************************************** + +typedef GenericLocator MetaTransistorLocator; + + + +// **************************************************************************************************** +// MetaTransistorFilter declaration +// **************************************************************************************************** + +typedef GenericFilter MetaTransistorFilter; + + + +// **************************************************************************************************** +// for_each_metatransistor declaration +// **************************************************************************************************** + +#define for_each_metatransistor(metatransistor, metatransistors)\ +/******************************/\ +{\ + MetaTransistorLocator _locator = metatransistors.GetLocator();\ + while (_locator.IsValid()) {\ + MetaTransistor* metatransistor = _locator.GetElement();\ + _locator.Progress(); + + + +END_NAMESPACE_HURRICANE + +#endif // HURRICANE_METATRANSISTORS + diff --git a/hurricane/src/analogic/ParserDtrGram.hpp b/hurricane/src/analogic/ParserDtrGram.hpp new file mode 100644 index 00000000..2b14211d --- /dev/null +++ b/hurricane/src/analogic/ParserDtrGram.hpp @@ -0,0 +1,72 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_TABLE = 258, + T_TABLE_END = 259, + T_DOUBLE = 260, + T_ID = 261 + }; +#endif +/* Tokens. */ +#define T_TABLE 258 +#define T_TABLE_END 259 +#define T_DOUBLE 260 +#define T_ID 261 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 47 "/home/xtof/workspace/hurricane/src/analogic/ParserDtrGram.yy" +{ double _value; + char * _text; + } +/* Line 1489 of yacc.c. */ +#line 65 "/home/xtof/workspace/hurricane/src/analogic/ParserDtrGram.hpp" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +extern YYSTYPE dtrlval; + diff --git a/hurricane/src/analogic/ParserDtrGram.yy b/hurricane/src/analogic/ParserDtrGram.yy new file mode 100644 index 00000000..e10a1b8e --- /dev/null +++ b/hurricane/src/analogic/ParserDtrGram.yy @@ -0,0 +1,202 @@ +%{ +#include +#include +#include +#include + +#include "Error.h" +#include "DtrAccess.h" +using namespace Hurricane; + +#include "ParserDtrGram.hpp" + +extern FILE * dtrin; +extern int dtrlex(void); +extern char * dtrtext; +extern int DTRlineno; + + +// ************************************************************************* +// Static Function&Data +// ************************************************************************* + +static int dtrerror( char * message) +// ********************************* +{ + char * str = (char*)malloc(200*sizeof(char)); + sprintf(str, "ParserDtr():\n %s before %s at line %d.\n", message, dtrtext, DTRlineno); + + string errmsg = str; + + throw Error (errmsg); + + return 0; +} + +static DtrAccess * dtraccess = NULL; + + +static char* table_name = NULL; + +static list doubleList; +static list stringList; + + +%} + +%union { double _value; + char * _text; + }; + +%token T_TABLE T_TABLE_END T_DOUBLE T_ID +%type < _value > T_DOUBLE +%type < _text > T_ID + +%start file + +%% + +file: lines tables + ; + +lines : '\n' + | lines '\n' + ; + +tables: table + |tables table + ; + +table: T_TABLE T_ID '\n' + { table_name = $2; } + items T_TABLE_END lines + ; + +items: item + |items item + ; + +item: T_ID elems '\n' + { + + string label = $1; + delete $1; + + if( strcmp(table_name, "RULES")==0 ) { + if ( doubleList.empty() ) { + + dtrerror("ParserDtr detect no data in a line of table RULES : Please check it"); + } + + list::iterator i = doubleList.begin() + , j = doubleList.end(); + + while(i!=j) { + (dtraccess->_GetLabel2RuleMap())[label].push_back(*i); + i++; + } + } + else if( strcmp(table_name, "LAYERS")==0 ) { + if ( stringList.empty() ) { + dtrerror("ParserDtr detect no data in a line of table LAYERS : Please check it"); + } + + list::iterator i = stringList.begin() + , j = stringList.end(); + + while(i!=j) { + (dtraccess->_GetLabel2LayerNameMap())[label].push_back(*i);; + i++; + } + } + else if( strcmp(table_name, "ELECTRICAL") == 0 ) { + if ( doubleList.empty() ) { + dtrerror("ParserDtr detect no data in a line of table ELECTRICAL : Please check it"); + } + + list::iterator i = doubleList.begin() + , j = doubleList.end(); + + while(i!=j) { + (dtraccess->_GetLabel2ElectricalMap())[label].push_back(*i); + i++; + } + } + else if( strcmp(table_name, "MODELLING") == 0 ) { + if ( (doubleList.empty()) || (doubleList.size()!=1) ) { + dtrerror("ParserDtr detect no data or mutli datas in a line of table MODELLING: Please check it"); + } + + list::iterator i = doubleList.begin(); + + (dtraccess->_GetLabel2ModellingMap())[label] = (int)(*i); + } + + else if( strcmp(table_name, "SIMPLE_CAPA_MIM")==0 ) { + if( (doubleList.empty()) || (doubleList.size()!=1) ) { + dtrerror("ParserDtr detect no data or mutli datas in a line of table SIMPLE_CAPA_MIM : Please check it"); + } + + list::iterator i = doubleList.begin(); + (dtraccess->_GetLabel2SimpleCapaMimMap())[label] = (*i); + + } + + else { + throw Error("ParserDtr detect unknown table name " + string(table_name)); + } + + // Vide temporary list + // ******************** + doubleList.clear(); + stringList.clear(); + + } + | lines + ; + +elems: elem + |elems elem + ; + +elem: T_ID + { + if(!(doubleList.empty())) { + + dtrerror("ParserDtr detect incompatibles datas : Please check it"); + } + + stringList.push_back(string($1)); + delete $1; + } + | T_DOUBLE + { + if(!(stringList.empty())) { + + dtrerror("ParserDtr detect incompatibles datas : Please check it"); + } + + doubleList.push_back($1); + } + ; + +%% + +// ************************************************************************* +// Generic Function +// ************************************************************************* + +void ParseDtr(const char* dtrfilename, DtrAccess* dtr) +// *************************************************** +{ + dtraccess = dtr; + + if((dtrin=fopen(dtrfilename, "r"))==NULL) + { + throw Error("Can't open dtr file : " + string(dtrfilename)); + } + + dtrparse(); + +} + diff --git a/hurricane/src/analogic/ParserDtrScan.ll b/hurricane/src/analogic/ParserDtrScan.ll new file mode 100644 index 00000000..8e68e0fa --- /dev/null +++ b/hurricane/src/analogic/ParserDtrScan.ll @@ -0,0 +1,27 @@ +%{ + +#include +#include +#include +using namespace std; + +#include "ParserDtrGram.hpp" + +#define YY_NO_UNPUT + +int DTRlineno = 1; + +%} +%% +([ \t]+|#.*) {/* nothing to do */} +\n { DTRlineno++; return '\n'; } +TABLE_1DM { return T_TABLE;} +END_TABLE_1DM { return T_TABLE_END;} +[1-9]?[0-9]*(\.)?[0-9]+ { dtrlval._value=atof(dtrtext); return T_DOUBLE;} +[a-zA-Z0-9]+(_?[a-zA-Z0-9]+)* {dtrlval._text=strdup(dtrtext); return T_ID;} +. { return *dtrtext; } + +%% + +int dtrwrap() {return 1;} + diff --git a/hurricane/src/analogic/RdsUnit.cpp b/hurricane/src/analogic/RdsUnit.cpp new file mode 100644 index 00000000..c2098d06 --- /dev/null +++ b/hurricane/src/analogic/RdsUnit.cpp @@ -0,0 +1,260 @@ +// **************************************************************************************************** +// File: RdsUnit.cpp +// Authors: Wu YiFei +// Date : 21/12/2006 +// **************************************************************************************************** + + +#include "Error.h" +#include "stdio.h" +#include "regex.h" +#include "math.h" +#include "Commons.h" +#include "RdsUnit.h" + + + + +// **************************************************************************************************** +// Static data&function +// **************************************************************************************************** + +static long RDS_UNIT = -1; + +static long RDS_PHYSICAL_GRID = 2; + +static long RDS_LAMBDA = -1; + + + +// ----------------------------------------------------------------------- +// Function : "GetPattern()". + + /* \static char * GetPattern (const string& str, const char* pattern) + * \param str the string to check for regex. + * \param pattern the pattern to find. + * + * Get and return the march substring from str according to the pattern. + * + * \return NULL if Failure. + * \return the according substring if Success. + */ + +static char* GetPattern(const string& str, const char* pattern) +// ************************************************************ +{ + int err; + regex_t preg; + const char *str_request = str.c_str(); + const char *str_regex = pattern; + +/* (1) */ + err = regcomp (&preg, str_regex, REG_EXTENDED); + + if (err == 0) + { + int match; + size_t nmatch = 0; + regmatch_t *pmatch = NULL; + + nmatch= 1; + pmatch = (regmatch_t*)malloc (sizeof (*pmatch) * nmatch); + + if (pmatch) + { +/* (2) */ + match = regexec (&preg, str_request, nmatch, pmatch, 0); + +/* (3) */ + regfree (&preg); + +/* (4) */ + if (match == 0) + { + char *site = NULL; + int start = pmatch[0].rm_so; + int end = pmatch[0].rm_eo; + size_t size = end - start; + + site = (char*)malloc (sizeof (*site) * (size + 1)); + if (site) + { + strncpy (site, &str_request[start], size); + site[size] = '\0'; + + return site; + } + else { + fprintf (stderr, "Memoire insuffisante\n"); + exit (EXIT_FAILURE); + } + } + /* (5) */ + else if (match == REG_NOMATCH) + { + printf ("%s doesn't accord to %s\n", str_request, str_regex); + return NULL; + } + /* (6) */ + else + { + char *text; + size_t size; + + /* (7) */ + size = regerror (err, &preg, NULL, 0); + text = (char*)malloc (sizeof (*text) * size); + if (text) + { + /* (8) */ + regerror (err, &preg, text, size); + fprintf (stderr, "%s\n", text); + free (text); + } + else + { + fprintf (stderr, "Memoire insuffisante\n"); + } + exit (EXIT_FAILURE); + } + } + else + { + fprintf (stderr, "Memoire insuffisante\n"); + exit (EXIT_FAILURE); + } + } + else { + fprintf (stderr, "Regcomp fail\n"); + exit (EXIT_FAILURE); + } + +} + + + +// ------------------------------------------------------------------- +// Function : "CalculateRdsUnit()". + + /* static void CalculateRdsUnit() + * + * Open rds techno file who's name is MACRO RDS_TECHNO_FILE, + * and get values technology : rds_physical_grid, rds_lambda. + * Calculate the RDS_UNIT according to these values. + * + * If RDS_TECHNO_FILE is invalid or operaton of reading values technologys + * fail, a Hurricane Error will be throwed to explain the reason of failure. + */ + + +static void CalculateRdsUnit() +// *************************** +{ + using Hurricane::Error; + + const char * rdsfilename = getenv("RDS_TECHNO_NAME"); + FILE * rdstechnofile; + + if(!rdsfilename) { + throw Error("Can't not find macro RDS_TECHNO_FILE"); + } + + if( !(rdstechnofile = fopen(rdsfilename, "r")) ) { + throw Error("Can't not open rds techno file : " + GetString(rdsfilename)); + } + + char buffer[80]; // For stock a line of the rds techno file + double rds_physical_grid = -0.1; // For stock value of physical_grid + double rds_lambda = -0.1; // For stock value of lamba + + while(fgets(buffer, 80, rdstechnofile )!=NULL){ + string tmp = buffer; + + if( tmp.find("define physical_grid")!=string::npos) { // Find the ligne begin with "define physical_grid" + + string pattern; + + if( (pattern = GetPattern(tmp, "[[:digit:]\\.]+")).size()==0 ) { // Get the value behind + throw Error("Can't get rds_physical_grid : GetPattern(string&, char*) return NULL"); + } + + if(!Scan(pattern, rds_physical_grid)){ // Convert from string to double + throw Error("Can't get rds_physical_grid " + pattern + " : Hurricane::Scan(string&, double&) return false"); + } + + } + + if( tmp.find("define lambda")!=string::npos ) { + + string pattern; + + if( (pattern = GetPattern(tmp, "[[:digit:]\\.]+")).size()==0 ) { + throw Error("Can't get rds_lambda : GetPattern(string&, char*) return NULL"); + } + + if(!Scan(pattern, rds_lambda)){ + throw Error("Can't get rds_lambda " + pattern + " : Hurricane::Scan(string&, double&) return false"); + } + + } + + // if rds_physical_grid and rds_lambda are finded, break the loop + // ************************************************************** + if( (rds_physical_grid!=-0.1) && (rds_lambda!=-0.1) ) + break; + + } // end of while + + if( (rds_physical_grid==-0.1) && (rds_lambda==-0.1) ) { + throw Error("Can't get rds_physical_grid and rds_lambda from rds techno file : \n" + string(rdsfilename)); + } + + long rds_physical_grid_nano = (long)rint(rds_physical_grid*(double)1000); + + rds_physical_grid_nano = (long)rint( (double)1000/(double)rds_physical_grid_nano ); + + RDS_UNIT = rds_physical_grid_nano << 1; + + long rds_lambda_nano = (long)rint( rds_lambda*(double)1000 ); + + RDS_LAMBDA = rds_lambda_nano * RDS_UNIT / 1000 ; + + fclose(rdstechnofile); + +} + +BEGIN_NAMESPACE_HURRICANE + + + + +// **************************************************************************************************** +// Utilitarians +// **************************************************************************************************** + +const long& GetRdsUnit() +// ********************* +{ + if ( RDS_UNIT == -1) + CalculateRdsUnit(); + + return RDS_UNIT; +} + +const long& GetRdsPhysicalGrid() +// ***************************** +{ + return RDS_PHYSICAL_GRID; +} + +const long& GetRdsLambda() +// *********************** +{ + if ( RDS_LAMBDA == -1) + CalculateRdsUnit(); + + return RDS_LAMBDA; +} + + +END_NAMESPACE_HURRICANE diff --git a/hurricane/src/analogic/RdsUnit.h b/hurricane/src/analogic/RdsUnit.h new file mode 100644 index 00000000..f5d83ff1 --- /dev/null +++ b/hurricane/src/analogic/RdsUnit.h @@ -0,0 +1,54 @@ +// **************************************************************************************************** +// File: RdsUnit.h +// Authors: Wu YiFei +// Date : 21/12/2006 +// **************************************************************************************************** + +#ifndef HURRICANE_RDSUNIT +#define HURRICANE_RDSUNIT + +#include + +//BEGIN_NAMESPACE_HURRICANE + + +namespace Hurricane { + + + +// **************************************************************************************************** +// Utilitarians +// **************************************************************************************************** + +const long& GetRdsUnit(); + +const long& GetRdsPhysicalGrid(); + +const long& GetRdsLambda(); + +// ------------------------------------------------------------------------ +// Function : "ConvertRealToRdsUnit(const double&)". +// + + /* \inline long ConvertRealToRdsUnit(const double& value) + * \param value the value en Micro to convert to RdsUnit. + * + * Get and return the value en RdsUnit. + * + */ + +inline long ConvertRealToRdsUnit(const double& value) +// ******************************************************* +{ + long tmp_value = (long)rint(value*GetRdsUnit()); + return (tmp_value%2)==0?tmp_value:(tmp_value+1); +} + + +//END_NAMESPACE_HURRICANE + +} + +#endif // HURRICANE_RDSUNIT + + diff --git a/hurricane/src/analogic/Transistor.cpp b/hurricane/src/analogic/Transistor.cpp new file mode 100644 index 00000000..b0cd0743 --- /dev/null +++ b/hurricane/src/analogic/Transistor.cpp @@ -0,0 +1,505 @@ +// **************************************************************************************************** +// File: Transistor.h +// Authors: Wu YiFei +// Date : 21/12/2006 +// **************************************************************************************************** + +#include "AnalogicalCommons.h" +#include "Transistor.h" +#include "GenTrans.h" + +#include "Vertical.h" +#include "Horizontal.h" + +#include "UpdateSession.h" + +BEGIN_NAMESPACE_HURRICANE + + +// **************************************************************************************************** +// Transistor::MaskVersion implementation +// **************************************************************************************************** +Transistor::MaskVersion::MaskVersion(const Code& code) +// ******************************************************* +:_code(code) +{ +} + +Transistor::MaskVersion::MaskVersion(const MaskVersion& version) +// ******************************************************************* +:_code(version._code) +{ +} + + +Transistor::MaskVersion& Transistor::MaskVersion::operator=(const MaskVersion& version) +// ****************************************************************************************** +{ + _code = version._code; + return *this; +} + + +bool Transistor::MaskVersion::operator==(const MaskVersion& version) const +// *************************************************************************** +{ + return _code==version._code; +} + + +string Transistor::MaskVersion::_GetString() const +// ************************************************* +{ + switch(_code) { + case VERSION1 : return "VERSION1"; + } + return "ABNORMAL"; +} + + +Record* Transistor::MaskVersion::_GetRecord() const +// ************************************************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Code", _code)); + return record; +} + + +// **************************************************************************************************** +// Transistor::Type implementation +// **************************************************************************************************** +Transistor::Type::Type(const Code& code) +// ************************************* +:_code(code) +{ +} + + +Transistor::Type::Type(const Type& type) +// ************************************* +:_code(type._code) +{ +} + + +Transistor::Type& Transistor::Type::operator=(const Type& type) +// ************************************************************ +{ + _code = type._code; + return *this; +} + + +string Transistor::Type::_GetString() const +// ***************************************** +{ + switch(_code) { + case INTERNAL : return "INTERNAL"; + case LEFT : return "LEFT"; + case RIGHT : return "RIGHT"; + case SINGLE : return "SINGLE"; + } + + return "ABNORMAL"; +} + + +Record* Transistor::Type::_GetRecord() const +// ***************************************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Code", _code)); + return record; +} + + +// **************************************************************************************************** +// Transistor::MaskInfo implementation +// **************************************************************************************************** +Transistor::MaskInfo::MaskInfo(const double& l, const double& w, const Type::Code& type + , const unsigned& nbDrainColumn + , const unsigned& nbSourceColumn) +// **************************************************************************************************** +: _l(l) + , _w(w) + , _type(type) + , _nbDrainColumn(nbDrainColumn) + , _nbSourceColumn(nbSourceColumn) +{}; + + +Transistor::MaskInfo& Transistor::MaskInfo::operator=(const MaskInfo& masqueinfo) +// ************************************************************************************ +{ + _l = masqueinfo.GetL(); + _w = masqueinfo.GetW(); + _type= masqueinfo.GetType(); + _nbDrainColumn = masqueinfo.GetNbDrainColumn(); + _nbSourceColumn = masqueinfo.GetNbSourceColumn(); + + return *this; +} + + +void Transistor::MaskInfo::_PostCreate() +// *************************************** +{ +} + + +void Transistor::MaskInfo::_PreDelete() +// ************************************** +{ +} + + +void Transistor::MaskInfo::Delete() +// ********************************** +{ + _PreDelete(); + delete this; +} + + +bool Transistor::MaskInfo::operator==(const MaskInfo& masqueinfo) +// ****************************************************************** +{ + if(_l == masqueinfo.GetL() && + _w == masqueinfo.GetW() && + _type== masqueinfo.GetType() && + _nbDrainColumn == masqueinfo.GetNbDrainColumn() && + _nbSourceColumn == masqueinfo.GetNbSourceColumn() + ) + return true; + + return false; +} + + +string Transistor::MaskInfo::_GetString() const +// ********************************************** +{ + string s = "<" + _GetTypeName() + " " + + GetString(_l) + " " + + GetString(_w) + " " + + _type._GetString() + " " + + GetString(_nbSourceColumn) + " " + + GetString(_nbDrainColumn) + + ">"; + return s; +} + + +Record* Transistor::MaskInfo::_GetRecord() const +// *********************************************** +{ + Record * record = new Record(_GetString()); + return record; +} + + +// **************************************************************************************************** +// Transistor::MaskV1Info implementation +// **************************************************************************************************** +Transistor::MaskV1Info::MaskV1Info(const double& l, const double& w, const Type::Code& type + , const unsigned& nbDrainColumn + , const unsigned& nbSourceColumn) +// **************************************************************************************************** +: Inherit(l + , w + , type + , nbDrainColumn + , nbSourceColumn + ) +{} + + +Transistor::MaskV1Info* Transistor::MaskV1Info::Create(const double& l, const double& w + , const Type::Code& type + , const unsigned& nbDrainColumn + , const unsigned& nbSourceColumn) +// ********************************************************************************************** +{ + MaskV1Info* masquev1info = new MaskV1Info(l, w, type, nbDrainColumn, nbSourceColumn); + + masquev1info->_PostCreate(); + + return masquev1info; +} + + +Transistor::MaskInfo& Transistor::MaskV1Info::operator=(const MaskInfo& masqueinfo) +// ************************************************************************************** +{ +// (*(static_cast(this)))=masqueinfo; + Inherit::operator=(masqueinfo); + + return *this; +} + + +void Transistor::MaskV1Info::_PostCreate() +// ***************************************** +{ + Inherit::_PostCreate(); +} + + +void Transistor::MaskV1Info::_PreDelete() +// **************************************** +{ + Inherit::_PreDelete(); +} + + +bool Transistor::MaskV1Info::operator == (const MaskInfo& masqueinfo) +// ********************************************************************** +{ + //return (*(static_cast(this)))==masqueinfo; + return Inherit::operator==(masqueinfo); +} + + +string Transistor::MaskV1Info::_GetString() const +// ************************************************ +{ + string s = Inherit::_GetString(); + return s; +} + +Record* Transistor::MaskV1Info::_GetRecord() const +// ************************************************* +{ + Record* record = Inherit::_GetRecord(); + return record; +} + +// **************************************************************************************************** +// Transistor implementation +// **************************************************************************************************** + +Transistor::Transistor(Library* library, const Name& name, char type) +// ******************************************************************* +: Inherit(library, name), + _type(type), + _masqueInfo(NULL), + _genTrans(NULL) +{ +} + + +Transistor* Transistor::Create(Library* library, const Name& name, char type) +// ************************************************************************** +{ + Transistor* transistor = new Transistor(library, name, type); + + transistor->_PostCreate(); + + return transistor; +} + + + +void Transistor::_PreDelete() +// ****************************** +{ + // Delete aggregated objets. + // ************************* + if(_masqueInfo) + _masqueInfo->Delete(); + + if(_genTrans) + delete _genTrans; + + Inherit::_PreDelete(); +} + + +void Transistor::_PostCreate() +// ******************************* +{ + Inherit::_PostCreate(); + + (Net::Create(this, Name("DRAIN")))->SetExternal(true); + (Net::Create(this, Name("SOURCE")))->SetExternal(true); + (Net::Create(this, Name("GRID")))->SetExternal(true); + (Net::Create(this, Name("BULK")))->SetExternal(true); + + // By default, transistor's length and heigth is NULL, and is internal. + // ******************************************************************** + _masqueInfo = new MaskV1Info(0.0, 0.0); +} + + +string Transistor::_GetString() const +// *********************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length()-1, " " + GetString(_type)); + s.insert(s.length()-1, " " + GetAbutmentType()._GetString()); + return s; +} + + +Record* Transistor::_GetRecord() const +// ************************************ +{ + Record* record = Inherit::_GetRecord(); + return record; +} + + +Transistor::MaskVersion Transistor::_GetMaskInfoVersion(MaskInfo* masqueinfo) +// *************************************************************************************** +{ + if(!masqueinfo) + throw Error("Error : In Transistor::_GetMaskInfoVersion, param masqueinfo is NULL"); + + if(dynamic_cast(masqueinfo)) + return MaskVersion(MaskVersion::VERSION1); + + throw Error("Error : In Transistor::_GetMaskInfoVersion, can't dynamic cast param masqueinfo"); + return MaskVersion(MaskVersion::VERSION1); +} + + +Transistor::MaskInfo* Transistor::_CreateMaskInfo(const MaskVersion& version) +// ******************************************************************************* +{ + switch((const MaskVersion::Code&)version) { + case MaskVersion::VERSION1 : + return MaskV1Info::Create(0.0, 0.0); + + default : + throw Error ("Error : In Transistor::_CreateMaskInfoBy, unknown param version"); + return NULL; + } +} + + +void Transistor::SetMaskInfo(MaskInfo* masqueinfo) +// *************************************************** +{ + if(!masqueinfo) + throw Error("Error : In Transistor::CreateLayout : masqueinfo is NULL"); + + // Set new Param. + // *************** + MaskVersion newversion = _GetMaskInfoVersion(masqueinfo); + MaskVersion oldversion = _GetMaskInfoVersion(_masqueInfo); + + if(newversion == oldversion) { // If they are the same version. + if((*_masqueInfo)==(*masqueinfo)) // If they are identical. + return; + else + (*_masqueInfo)=(*masqueinfo); + } + else { // If change the version. + _masqueInfo->Delete(); + _masqueInfo = _CreateMaskInfo(newversion); + (*_masqueInfo) == (*masqueinfo); + } +} + + +void Transistor::CreateLayout() +// **************************** +{ + MaskVersion version = _GetMaskInfoVersion(_masqueInfo); + MaskV1Info* masquev1info = NULL; + + // Select algorithme with technology and masque version. + // ***************************************************** + switch((const MaskVersion::Code&)version) { + + case MaskVersion::VERSION1 : + masquev1info = dynamic_cast(_masqueInfo); + _genTrans = new GenV1Trans(masquev1info); + break; + + default : + break; + } + + SetTerminal(false); + + // Launch the selected algorithme. + // ****************************** + _genTrans->Calculate(this); + _genTrans->Generate(this); + + Materialize(); + + delete _genTrans; + _genTrans = NULL; + +} + + +void Transistor::DuplicateLayout(Transistor* transistor) +// ***************************************************** +{ + OpenUpdateSession(); + + SetTerminal(false); + + Net * tmp = NULL; + Contact * con = NULL; + Segment * seg = NULL; + + for_each_net(net, transistor->GetNets()) + if( !( tmp=GetNet(net->GetName()) ) ) { // + tmp = Net::Create(this, net->GetName()); + tmp->SetExternal(net->IsExternal()); + } + + for_each_component(component, net->GetComponents()) + if( (con=dynamic_cast(component)) ){ + Contact::Create(tmp, component->GetLayer(), con->GetX(), con->GetY(), con->GetWidth(), con->GetHeight()); + } + else if( (seg=dynamic_cast(component)) ) { + Vertical::Create(tmp, component->GetLayer(), seg->GetSourceX(), seg->GetWidth(), seg->GetSourceY(), + seg->GetTargetY()); + } + else if( (seg=dynamic_cast(component)) ){ + Horizontal::Create(tmp, component->GetLayer(), seg->GetSourceY(), seg->GetWidth(), seg->GetSourceX(), + seg->GetTargetX()); + } + else + throw Error ("Error : In Transistor::DuplicateLayout, find illegal elem : " + GetString(component) + + "In Transistor, all component must be contact or segment" ) ; + end_for + end_for + + SetAbutmentBox(transistor->GetAbutmentBox()); + + _mapNet2Box.clear(); + + map::iterator i = transistor->_GetMapNet2Box()->begin(), + j = transistor->_GetMapNet2Box()->end(); + + while(i!=j) { + _mapNet2Box[GetNet((*i).first->GetName())]=(*i).second; + i++; + } + + Materialize(); + + CloseUpdateSession(); + +} + +END_NAMESPACE_HURRICANE + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +string GetString(const H::Transistor::MaskInfo& masqueinfo) +// ********************************************************** +{ + return masqueinfo._GetString(); +} + diff --git a/hurricane/src/analogic/Transistor.h b/hurricane/src/analogic/Transistor.h new file mode 100644 index 00000000..9d9a5da1 --- /dev/null +++ b/hurricane/src/analogic/Transistor.h @@ -0,0 +1,344 @@ +// **************************************************************************************************** +// File: Transistor.h +// Authors: Wu YiFei +// Date : 21/12/2006 +// **************************************************************************************************** + +#ifndef HURRICANE_TRANSISTOR +#define HURRICANE_TRANSISTOR + +#include "Cell.h" +#include "AnalogicalCommons.h" + + +//BEGIN_NAMESPACE_HURRICANE + +namespace Hurricane { + +class Library; +class Name; +class Symbol; +class Record; +class GenTrans; + +class Transistor : public Cell { +// ******************************** + +//# if !defined(__DOXYGEN_PROCESSOR__) + +// Types +// ***** + + public : typedef Cell Inherit; + + + public : class MaskVersion { + // ****************** + public : enum Code { VERSION1=0 }; + + private: Code _code; + + public : explicit MaskVersion(const Code& code=VERSION1); + public : MaskVersion(const MaskVersion&); + public : MaskVersion& operator=(const MaskVersion&); + + public : bool operator==(const MaskVersion&) const; + + public : operator const Code& () const { return _code; }; + public : const Code& GetCode() const { return _code; }; + + public : string _GetTypeName() const { return _TName("Transistor::MaskVersion"); }; + public : string _GetString() const; + public : Record* _GetRecord() const; + + }; + + + public : class Type { + // ********* + + public : enum Code { INTERNAL=0, LEFT=1, RIGHT=2, SINGLE=3}; + + private: Code _code; + + public : explicit Type(const Code& code=INTERNAL); + public : Type(const Type& type); + public : Type& operator=(const Type& type); + public : operator const Code&() const { return _code; }; + + public : void SetCode(const Code& code) { _code = code; }; + + public : const Code& GetCode() const { return _code; }; + + public : string _GetTypeName() const { return _TName("Transistor::Type"); }; + public : string _GetString() const; + public : Record* _GetRecord() const; + + }; + + + public : class MaskInfo { + // *************** + + // Attributs + // ********* + private : double _l; + private : double _w ; + private : Type _type; + private : unsigned _nbDrainColumn; + private : unsigned _nbSourceColumn; + + // Constructors + // ************ + public : MaskInfo(const double& l, const double& w, const Type::Code& type=Type::INTERNAL + , const unsigned& nbDrainColumn=1 + , const unsigned& nbSourceColumn=1); + + public : virtual MaskInfo& operator=(const MaskInfo&); + + private : MaskInfo(const MaskInfo& ); + + protected : virtual void _PostCreate(); + + // Destructors + // *********** + protected: virtual ~MaskInfo() {}; + protected: virtual void _PreDelete(); + public : virtual void Delete(); + + // Accessors + // ********* + public : const double& GetL() const { return _l; }; + public : const double& GetW() const { return _w; }; + public : const unsigned & GetNbDrainColumn() const { return _nbDrainColumn; }; + public : const unsigned & GetNbSourceColumn() const { return _nbSourceColumn; }; + public : const Type& GetType() const { return _type; }; + + // Update + // ****** + public : void SetL(const double& l) { _l=l;}; + public : void SetW(const double& w) { _w=w;}; + public : void SetNbDrainColumn(const unsigned& column) { _nbDrainColumn=column; }; + public : void SetNbSourceColumn(const unsigned& column) { _nbSourceColumn=column; }; + public : void SetType(const Type::Code& code) { _type.SetCode(code); }; + public : void SetType(const Type& type) { _type = type; }; + + // Predicats + // ********* + + // Operators + // ********* + public : virtual bool operator==(const MaskInfo&); + + // Others + // ****** + public : virtual string _GetTypeName() const =0; + public : virtual string _GetString() const; + public : virtual Record* _GetRecord() const; + + }; + + + public : class MaskV1Info : public MaskInfo { + // ************************************* + + // type + // ***** + public : typedef MaskInfo Inherit ; + + // Attributs + // ********* + + // Constructors + // ************ + public: MaskV1Info(const double& l, const double& w, const Type::Code& type=Type::INTERNAL + , const unsigned& nbDrainColumn = 1 + , const unsigned& nbSourceColumn = 1); + + public: static MaskV1Info* Create(const double& l, const double& w, const Type::Code& type=Type::INTERNAL + , const unsigned& nbDrainColumn = 1 + , const unsigned& nbSourceColumn = 1); + + public : MaskInfo& operator=(const MaskInfo&); + + protected : void _PostCreate(); + + // Destructor + // *********** + public : virtual ~MaskV1Info() {}; + protected: void _PreDelete(); + + // Operators + // ********* + public : bool operator==(const MaskInfo&); + + // Others + // ********* + public : virtual string _GetTypeName() const { return _TName("Transistor::MaskV1Info"); }; + public : virtual string _GetString() const; + public : virtual Record* _GetRecord() const; + }; + + +# if !defined(__DOXYGEN_PROCESSOR__) + +// Attributes +// ******************* + private : char _type; + private : MaskInfo* _masqueInfo; + private : GenTrans * _genTrans; + //public : RealInfo * _realInfo; + + private : map _mapNet2Box; // This Map Is For localize The Position Of Routing. + +# endif + +// Constructors +// ************ +# if !defined(__DOXYGEN_PROCESSOR__) + protected : Transistor(Library* library, const Name& name, char type); +# endif + + public : static Transistor* Create(Library* library, const Name& name, char type); + +# if !defined(__DOXYGEN_PROCESSOR__) + protected : virtual void _PostCreate(); + + +// Destructors +// *********** + protected : ~Transistor() {}; + protected : virtual void _PreDelete(); +# endif + +// Accessors +// ********* + public : char GetType() const { return _type; }; + public : MaskVersion GetMaskVersion() const { return _GetMaskInfoVersion(_masqueInfo); }; + public : const MaskInfo* GetMaskInfo() const { return _masqueInfo; }; + public : const double& GetL() const { return _masqueInfo->GetL(); }; + public : const double& GetW() const { return _masqueInfo->GetW(); }; + public : const unsigned& GetNbDrainColumn() const { return _masqueInfo->GetNbDrainColumn(); }; + public : const unsigned& GetNbSourceColumn() const { return _masqueInfo->GetNbSourceColumn(); }; + public : const char* GetDrainName() const { return "DRAIN"; }; + public : const char* GetSourceName() const { return "SOURCE"; }; + public : const char* GetGridName() const { return "GRID"; }; + public : Net* GetDrain() const { return GetNet(GetDrainName()); }; + public : Net* GetSource() const { return GetNet(GetSourceName()); }; + public : Net* GetGrid() const { return GetNet(GetGridName()); }; + public : const Type& GetAbutmentType() const { return _masqueInfo->GetType(); }; + +// Predicats +// ********* + public : bool IsNmos() const { return _type==TRANSN; }; + public : bool IsPmos() const { return _type==TRANSP; }; + public : bool IsInternal() const { return GetAbutmentType().GetCode()==Type::INTERNAL; }; + public : bool IsLeft() const { return GetAbutmentType().GetCode()==Type::LEFT; }; + public : bool IsRight() const { return GetAbutmentType().GetCode()==Type::RIGHT; }; + public : bool IsSingle() const { return GetAbutmentType().GetCode()==Type::SINGLE; }; + +// Updators +// ******** + public : void SetL(const double& l) { _masqueInfo->SetL(l); }; + public : void SetW(const double& w) { _masqueInfo->SetW(w); }; + +//# endif + +# if !defined(__DOXYGEN_PROCESSOR__) +// Others +// ****** + public : virtual string _GetTypeName() const {return _TName("Transistor");}; + public : virtual string _GetString() const; + public : virtual Record* _GetRecord() const; + public : const GenTrans* _GetGenTrans() const {return _genTrans; }; + public : static MaskVersion _GetMaskInfoVersion(MaskInfo*) ; + public : static MaskInfo* _CreateMaskInfo(const MaskVersion&) ; + public : map* _GetMapNet2Box() { return &_mapNet2Box; }; + +# endif + +// Operators +// ********* + public : void SetMaskInfo(MaskInfo*); + public : void CreateLayout(); + public : void DuplicateLayout(Transistor* transistor) ; + + +}; + + +# if !defined(__DOXYGEN_PROCESSOR__) +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName + ( const Transistor::MaskVersion::Code* object ) + { return ">"; } + +template<> + inline string ProxyString + ( const Transistor::MaskVersion::Code* object ) + { + switch ( *object ) { + case Transistor::MaskVersion::VERSION1: return "VERSION1"; + } + return "ABNORMAL"; + } + +template<> + inline Record* ProxyRecord + ( const Transistor::MaskVersion::Code* object ) + { + Record* record = new Record(GetString(object)); + record->Add(GetSlot("Code", (unsigned int*)object)); + return record; + } + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName + ( const Transistor::Type::Code* object ) + { return ">"; } + +template<> + inline string ProxyString + ( const Transistor::Type::Code* object ) + { + switch ( *object ) { + case Transistor::Type::LEFT : return "LEFT"; + case Transistor::Type::SINGLE: return "SINGLE"; + case Transistor::Type::RIGHT: return "RIGHT"; + case Transistor::Type::INTERNAL: return "INTERNAL"; + } + return "ABNORMAL"; + } + +template<> + inline Record* ProxyRecord + ( const Transistor::Type::Code* object ) + { + Record* record = new Record(GetString(object)); + record->Add(GetSlot("Code", (unsigned int*)object)); + return record; + } + + +# endif + +} + +//END_NAMESPACE_HURRICANE + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +string GetString(const H::Transistor::MaskInfo&); + + +#endif // HURRICANE_TRANSISTOR diff --git a/hurricane/src/analogic/Transistors.h b/hurricane/src/analogic/Transistors.h new file mode 100644 index 00000000..72a4d882 --- /dev/null +++ b/hurricane/src/analogic/Transistors.h @@ -0,0 +1,59 @@ + +// **************************************************************************************************** +// File: Transistors.h +// Authors: YIFEI WU +// Date : 21/12/2006 +// **************************************************************************************************** + +#ifndef HURRICANE_TRANSISTORS +#define HURRICANE_TRANSISTORS + +#include "Collection.h" + +BEGIN_NAMESPACE_HURRICANE + +class Transistor; + + +// **************************************************************************************************** +// Transistors declaration +// **************************************************************************************************** + +typedef GenericCollection Transistors; + + + +// **************************************************************************************************** +// TransistorLocator declaration +// **************************************************************************************************** + +typedef GenericLocator TransistorLocator; + + + +// **************************************************************************************************** +// TransistorFilter declaration +// **************************************************************************************************** + +typedef GenericFilter TransistorFilter; + + + +// **************************************************************************************************** +// for_each_transistor declaration +// **************************************************************************************************** + +#define for_each_transistor(transistor, transistors)\ +/******************************/\ +{\ + TransistorLocator _locator = transistors.GetLocator();\ + while (_locator.IsValid()) {\ + Transistor* transistor = _locator.GetElement();\ + _locator.Progress(); + + + +END_NAMESPACE_HURRICANE + +#endif // HURRICANE_TRANSISTORS + diff --git a/hurricane/src/analogic/TwoSpaces.cpp b/hurricane/src/analogic/TwoSpaces.cpp new file mode 100644 index 00000000..74a81254 --- /dev/null +++ b/hurricane/src/analogic/TwoSpaces.cpp @@ -0,0 +1,123 @@ +// ************************************************************** +// TwoSpaces.cpp +// Author : Wu YiFei +// Date : 12/04/2007 +// *************************************************************** + +#include "TwoSpaces.h" + + +BEGIN_NAMESPACE_HURRICANE + +// **************************************************************************************************** +// Two Spaces definition. +// **************************************************************************************************** +TwoSpaces::TwoSpaces(const string& s) +// ********************************* +: _s(s) + ,_n(1) +{ +} + + +TwoSpaces::TwoSpaces(const TwoSpaces& ts) +// ************************************** +: _s(ts._s) + ,_n(ts._n) +{ +} + + +TwoSpaces& TwoSpaces::operator=(const TwoSpaces& ts) +// ************************************************ +{ + _s = ts._s; + _n = ts._n; + return *this; +} + + +TwoSpaces& TwoSpaces::operator++() +// ******************************* +{ + if(_n<100) _n++; + return *this; +} + +TwoSpaces TwoSpaces::operator++(int) +// ********************************* +{ + TwoSpaces ts = *this; + if(_n<100) _n++; + return ts; +} + + +TwoSpaces& TwoSpaces::operator--() +// ******************************* +{ + if(_n>1) _n--; + return *this; +} + + +TwoSpaces TwoSpaces::operator--(int) +// ********************************* +{ + TwoSpaces ts = *this; + if(_n>1) _n--; + return ts; +} + + +TwoSpaces TwoSpaces::operator+(int count) +// ************************************** +{ + TwoSpaces ts = *this; + if( (_n+count) <= 100 ) ts._n = _n + count; + return ts; +} + + +TwoSpaces TwoSpaces::operator-(int count) +// ************************************** +{ + TwoSpaces ts = *this; + if ( (_n - count) >= 1 ) ts._n = _n - count; + return ts; +} + + +string TwoSpaces::_GetString() const +// ********************************* +{ + string s; + unsigned n = _n; + + while(n--) { + s += _s; + } + + return s; +} + + + +// **************************************************************************************************** +// Variables definition. +// **************************************************************************************************** +TwoSpaces ts(" "); + + +END_NAMESPACE_HURRICANE + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** +string GetString(const H::TwoSpaces& ts) +// *********************************** +{ + return ts._GetString(); +} + diff --git a/hurricane/src/analogic/TwoSpaces.h b/hurricane/src/analogic/TwoSpaces.h new file mode 100644 index 00000000..bf62dfba --- /dev/null +++ b/hurricane/src/analogic/TwoSpaces.h @@ -0,0 +1,72 @@ +// ************************************************************** +// TwoSpaces.h +// Author : Wu YiFei +// Date : 12/04/2007 +// *************************************************************** + + +# ifndef HURRICANE_TWOSPACES +# define HURRICANE_TWOSPACES + +# include "Commons.h" + + +BEGIN_NAMESPACE_HURRICANE + +// **************************************************************************************************** +// TwoSpaces declaration. +// **************************************************************************************************** +class TwoSpaces { +// *************** + +// Attributes +// ********** + private : string _s; + private : unsigned _n; + +// Constructors +// ************* + public : TwoSpaces(const string& s = " "); + public : TwoSpaces(const TwoSpaces&); + +// Destructors +// *********** + public : ~TwoSpaces(){}; + +// Operators +// ********* + public : TwoSpaces& operator=(const TwoSpaces&); + public : TwoSpaces& operator++(); + public : TwoSpaces operator++(int); + public : TwoSpaces& operator--(); + public : TwoSpaces operator--(int); + public : TwoSpaces operator+(int); + public : TwoSpaces operator-(int); + +// Others +// ****** + public : string _GetString() const ; + +}; + + +// **************************************************************************************************** +// Variables declaration. +// **************************************************************************************************** +extern TwoSpaces ts; + +END_NAMESPACE_HURRICANE + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** +string GetString(const H::TwoSpaces&); + +inline ostream& operator<<(ostream& stream, const H::TwoSpaces& ts) +// **************************************************************** +{ + return stream<< GetString(ts); +} + +# endif // END HURRICANE_TWOSPACES diff --git a/hurricane/src/cmake_modules/FindBISON.cmake b/hurricane/src/cmake_modules/FindBISON.cmake new file mode 100644 index 00000000..8a3b66c7 --- /dev/null +++ b/hurricane/src/cmake_modules/FindBISON.cmake @@ -0,0 +1,162 @@ +# - Find bison executable and provides macros to generate custom build rules +# The module defined the following variables: +# BISON_EXECUTABLE - path to the bison program +# BISON_VERSION - version of bison +# BISON_FOUND - true if the program was found +# If bison is found, the module defines the macros: +# BISON_TARGET( [VERBOSE ] +# [COMPILE_FLAGS ]) +# which will create a custom rule to generate a parser. is +# the path to a yacc file. is the name of the source file +# generated by bison. A header file is also be generated, and contains +# the token list. If COMPILE_FLAGS option is specified, the next +# parameter is added in the bison command line. if VERBOSE option is +# specified, is created and contains verbose descriptions of the +# grammar and parser. The macro defines a set of variables: +# BISON_${Name}_DEFINED - true is the macro ran successfully +# BISON_${Name}_INPUT - The input source file, an alias for +# BISON_${Name}_OUTPUT_SOURCE - The source file generated by bison +# BISON_${Name}_OUTPUT_HEADER - The header file generated by bison +# BISON_${Name}_OUTPUTS - The sources files generated by bison +# BISON_${Name}_COMPILE_FLAGS - Options used in the bison command line +# +# Example: +# FIND_PACKAGE(BISON) +# BISON_TARGET(MyParser parser.y ${PROJECT_BINARY_DIR}/parser.cpp) +# ADD_EXECUTABLE(Foo main.cpp ${BISON_MyParser_OUTPUTS}) +# + +# Copyright (c) 2006, Tristan Carel +# All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the University of California, Berkeley nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# $Id: FindBISON.cmake 1218 2007-03-22 22:10:45Z jmh $ + +SET(BISON_FOUND FALSE) + +FIND_PROGRAM(BISON_EXECUTABLE bison DOC "path to the bison executable") +MARK_AS_ADVANCED(BISON_EXECUTABLE) + +IF(BISON_EXECUTABLE) + SET(BISON_FOUND TRUE) + + EXECUTE_PROCESS(COMMAND ${BISON_EXECUTABLE} --version + OUTPUT_VARIABLE BISON_version_output + ERROR_VARIABLE BISON_version_error + RESULT_VARIABLE BISON_version_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + IF(NOT ${BISON_version_result} EQUAL 0) + MESSAGE(SEND_ERROR "Command \"${BISON_EXECUTABLE} --version\" failed with output:\n${BISON_version_error}") + ELSE(NOT ${BISON_version_result} EQUAL 0) + STRING(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1" + BISON_VERSION "${BISON_version_output}") + ENDIF(NOT ${BISON_version_result} EQUAL 0) + + # internal macro + MACRO(BISON_TARGET_option_verbose Name BisonOutput filename) + LIST(APPEND BISON_TARGET_cmdopt "--verbose") + GET_FILENAME_COMPONENT(BISON_TARGET_output_path "${BisonOutput}" PATH) + GET_FILENAME_COMPONENT(BISON_TARGET_output_name "${BisonOutput}" NAME_WE) + ADD_CUSTOM_COMMAND(OUTPUT ${filename} + COMMAND ${CMAKE_COMMAND} -E copy + "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output" + "${filename}" + DEPENDS + "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output" + COMMENT "[BISON][${Name}] Copying bison verbose table to ${filename}" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + SET(BISON_${Name}_VERBOSE_FILE ${filename}) + LIST(APPEND BISON_TARGET_extraoutputs + "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output") + ENDMACRO(BISON_TARGET_option_verbose) + + # internal macro + MACRO(BISON_TARGET_option_extraopts Options) + SET(BISON_TARGET_extraopts "${Options}") + SEPARATE_ARGUMENTS(BISON_TARGET_extraopts) + LIST(APPEND BISON_TARGET_cmdopt ${BISON_TARGET_extraopts}) + ENDMACRO(BISON_TARGET_option_extraopts) + + MACRO(BISON_TARGET Name BisonInput BisonOutput) + SET(BISON_TARGET_output_header "") + SET(BISON_TARGET_command_opt "") + SET(BISON_TARGET_outputs "${BisonOutput}") + IF(NOT ${ARGC} EQUAL 3 AND NOT ${ARGC} EQUAL 5 AND NOT ${ARGC} EQUAL 7) + MESSAGE(SEND_ERROR "Usage") + ELSE(NOT ${ARGC} EQUAL 3 AND NOT ${ARGC} EQUAL 5 AND NOT ${ARGC} EQUAL 7) + # Parsing parameters + IF(${ARGC} GREATER 5 OR ${ARGC} EQUAL 5) + IF("${ARGV3}" STREQUAL "VERBOSE") + BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${ARGV4}") + ENDIF("${ARGV3}" STREQUAL "VERBOSE") + IF("${ARGV3}" STREQUAL "COMPILE_FLAGS") + BISON_TARGET_option_extraopts("${ARGV4}") + ENDIF("${ARGV3}" STREQUAL "COMPILE_FLAGS") + ENDIF(${ARGC} GREATER 5 OR ${ARGC} EQUAL 5) + IF(${ARGC} EQUAL 7) + IF("${ARGV5}" STREQUAL "VERBOSE") + BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${ARGV6}") + ENDIF("${ARGV5}" STREQUAL "VERBOSE") + IF("${ARGV5}" STREQUAL "COMPILE_FLAGS") + BISON_TARGET_option_extraopts("${ARGV6}") + ENDIF("${ARGV5}" STREQUAL "COMPILE_FLAGS") + ENDIF(${ARGC} EQUAL 7) + + # Header's name generated by bison (see option -d) + LIST(APPEND BISON_TARGET_cmdopt "-d") + STRING(REGEX REPLACE "^(.*)\\.c([^.]*)$" "\\1.h\\2" + BISON_${Name}_OUTPUT_HEADER "${ARGV2}") + LIST(APPEND BISON_TARGET_outputs "${BISON_${Name}_OUTPUT_HEADER}") + + ADD_CUSTOM_COMMAND(OUTPUT ${BISON_TARGET_outputs} + ${BISON_TARGET_extraoutputs} + COMMAND ${BISON_EXECUTABLE} ${BISON_TARGET_cmdopt} -o ${ARGV2} ${ARGV1} + DEPENDS ${ARGV1} + COMMENT "[BISON][${Name}] Building parser with bison ${BISON_VERSION}" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + + # define target variables + SET(BISON_${Name}_DEFINED TRUE) + SET(BISON_${Name}_INPUT ${ARGV1}) + SET(BISON_${Name}_OUTPUTS ${BISON_TARGET_outputs}) + SET(BISON_${Name}_COMPILE_FLAGS ${BISON_TARGET_cmdopt}) + SET(BISON_${Name}_OUTPUT_SOURCE "${BisonOutput}") + + ENDIF(NOT ${ARGC} EQUAL 3 AND NOT ${ARGC} EQUAL 5 AND NOT ${ARGC} EQUAL 7) + ENDMACRO(BISON_TARGET) + +ENDIF(BISON_EXECUTABLE) + + +IF(NOT BISON_FOUND) + IF(NOT BISON_FIND_QUIETLY) + MESSAGE(STATUS "BISON was not found.") + ELSE(NOT BISON_FIND_QUIETLY) + IF(BISON_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "BISON was not found.") + ENDIF(BISON_FIND_REQUIRED) + ENDIF(NOT BISON_FIND_QUIETLY) +ENDIF(NOT BISON_FOUND) + +# FindBISON.cmake ends here diff --git a/hurricane/src/cmake_modules/FindFLEX.cmake b/hurricane/src/cmake_modules/FindFLEX.cmake new file mode 100644 index 00000000..8eac2f96 --- /dev/null +++ b/hurricane/src/cmake_modules/FindFLEX.cmake @@ -0,0 +1,134 @@ +# - Find flex executable and provides a macro to generate custom build rules +# The module defines the following variables: +# FLEX_FOUND - true is flex executable is found +# FLEX_VERSION - the version of flex +# If flex is found on the system, the module provides the macro: +# FLEX_TARGET(Name FlexInput FlexOutput [COMPILE_FLAGS ]) +# which creates a custom command to generate the file from +# the file. If COMPILE_FLAGS option is specified, the next +# parameter is added to the flex command line. Name is an alias used to +# get details of this custom command. Indeed the macro defines the +# following variables: +# FLEX_${Name}_DEFINED - true is the macro ran successfully +# FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an +# alias for FlexOutput +# FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput} +# +# Flex scanners oftenly use tokens defined by Bison: the code generated +# by Flex depends of the header generated by Bison. This module also +# defines a macro: +# ADD_FLEX_BISON_DEPENDENCY(FlexTarget BisonTarget) +# which adds the required dependency between a scanner and a parser +# where and are the first parameters of +# respectively FLEX_TARGET and BISON_TARGET macros. +# +# Example: +# FIND_PACKAGE(BISON) +# FIND_PACKAGE(FLEX) +# BISON_TARGET(MyParser parser.y ${PROJECT_BINARY_DIR}/parser.cpp +# FLEX_TARGET(MyScanner lexer.l ${PROJECT_BINARY_DIR}/lexer.cpp) +# ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser) +# + +# Copyright (c) 2006, Tristan Carel +# All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the University of California, Berkeley nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# $Id: FindFLEX.cmake 1218 2007-03-22 22:10:45Z jmh $ + +SET(FLEX_FOUND FALSE) + +FIND_PROGRAM(FLEX_EXECUTABLE flex DOC "path to the flex executable") +MARK_AS_ADVANCED(FLEX_EXECUTABLE) + +FIND_LIBRARY(FL_LIBRARY NAMES fl + PATHS /usr/lib DOC "path to the fl library") +SET(FLEX_LIBRARIES ${FL_LIBRARY}) + +IF(FLEX_EXECUTABLE) + SET(FLEX_FOUND TRUE) + + EXECUTE_PROCESS(COMMAND ${FLEX_EXECUTABLE} --version + OUTPUT_VARIABLE FLEX_version_output + ERROR_VARIABLE FLEX_version_error + RESULT_VARIABLE FLEX_version_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + IF(NOT ${FLEX_version_result} EQUAL 0) + MESSAGE(SEND_ERROR "Command \"${FLEX_EXECUTABLE} --version\" failed with output:\n${FLEX_version_error}") + ELSE(NOT ${FLEX_version_result} EQUAL 0) + STRING(REGEX REPLACE "^flex (.*)$" "\\1" + FLEX_VERSION "${FLEX_version_output}") + ENDIF(NOT ${FLEX_version_result} EQUAL 0) + + MACRO(FLEX_TARGET Name Input Output) + SET(FLEX_TARGET_usage "FLEX_TARGET( [COMPILE_FLAGS ]") + IF(${ARGC} GREATER 3) + IF(${ARGC} EQUAL 5) + IF("${ARGV3}" STREQUAL "COMPILE_FLAGS") + SET(FLEX_EXECUTABLE_opts "${ARGV4}") + SEPARATE_ARGUMENTS(FLEX_EXECUTABLE_opts) + ELSE("${ARGV3}" STREQUAL "COMPILE_FLAGS") + MESSAGE(SEND_ERROR ${FLEX_TARGET_usage}) + ENDIF("${ARGV3}" STREQUAL "COMPILE_FLAGS") + ELSE(${ARGC} EQUAL 5) + MESSAGE(SEND_ERROR ${FLEX_TARGET_usage}) + ENDIF(${ARGC} EQUAL 5) + ENDIF(${ARGC} GREATER 3) + ADD_CUSTOM_COMMAND(OUTPUT ${Output} + COMMAND ${FLEX_EXECUTABLE} ${FLEX_EXECUTABLE_opts} -o${Output} ${Input} + DEPENDS ${Input} + COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + + SET(FLEX_${Name}_DEFINED TRUE) + SET(FLEX_${Name}_OUTPUTS ${Output}) + SET(FLEX_${Name}_INPUT ${Input}) + SET(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts}) + ENDMACRO(FLEX_TARGET) + + MACRO(ADD_FLEX_BISON_DEPENDENCY FlexTarget BisonTarget) + IF(NOT FLEX_${FlexTarget}_TARGET) + MESSAGE(SEND_ERROR "Flex target `${FlexTarget}' does not exists.") + ENDIF(NOT FLEX_${FlexTarget}_TARGET) + IF(NOT BISON_${BisonTarget}_TARGET) + MESSAGE(SEND_ERROR "Bison target `${BisonTarget}' does not exists.") + ENDIF(NOT BISON_${BisonTarget}_TARGET) + + SET_SOURCE_FILES_PROPERTIES(${FLEX_${FlexTarget}_OUTPUT} + PROPERTIES OBJECT_DEPENDS ${BISON_${BisonTarget}_OUTPUT_HEADER}) + ENDMACRO(ADD_FLEX_BISON_DEPENDENCY) + +ENDIF(FLEX_EXECUTABLE) + +IF(NOT FLEX_FOUND) + IF(NOT FLEX_FIND_QUIETLY) + MESSAGE(STATUS "FLEX was not found.") + ELSE(NOT FLEX_FIND_QUIETLY) + IF(FLEX_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "FLEX was not found.") + ENDIF(FLEX_FIND_REQUIRED) + ENDIF(NOT FLEX_FIND_QUIETLY) +ENDIF(NOT FLEX_FOUND) + +# FindFLEX.cmake ends here diff --git a/hurricane/src/figures/CMakeLists.txt b/hurricane/src/figures/CMakeLists.txt new file mode 100644 index 00000000..b01d14e3 --- /dev/null +++ b/hurricane/src/figures/CMakeLists.txt @@ -0,0 +1,11 @@ +include(${QT_USE_FILE}) + +include_directories(${HURRICANE_SOURCE_DIR}/hurricane) + +set(includes CellFigure.h InstanceFigure.h SliceFigure.h GoFigure.h SegmentFigure.h) +set(cpps CellFigure.cpp InstanceFigure.cpp SliceFigure.cpp GoFigure.cpp SegmentFigure.cpp) + +add_library(hurricanefigs SHARED ${cpps}) + +install(FILES ${includes} DESTINATION /include/hurricane) +install(TARGETS hurricanefigs DESTINATION /lib) diff --git a/hurricane/src/figures/CellFigure.cpp b/hurricane/src/figures/CellFigure.cpp new file mode 100644 index 00000000..932a89aa --- /dev/null +++ b/hurricane/src/figures/CellFigure.cpp @@ -0,0 +1,81 @@ +#include + +#include +#include + +#include "InstanceFigure.h" +#include "SliceFigure.h" + +#include "Utils.h" +#include "CellFigure.h" + +CellFigure::CellFigure(Cell* c): + QGraphicsItem(), + cell(c) { + QTransform transform; + transform.setMatrix(1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0); + setTransform(transform); + for_each_instance(instance, cell->GetInstances()) { + new InstanceFigure(this, instance); + end_for; + } + for_each_slice(slice, cell->GetSlices()) { + new SliceFigure(this, slice); + end_for; + } +} + +CellFigure::CellFigure(InstanceFigure* master, Cell* c) : QGraphicsItem(master), cell(c) { + for_each_instance(instance, cell->GetInstances()) { + new InstanceFigure(this, instance); + end_for; + } + for_each_slice(slice, cell->GetSlices()) { + new SliceFigure(this, slice); + end_for; + } +} + +QRectF CellFigure::boundingRect() const { + Box box = cell->GetBoundingBox(); + QRectF rect; + BoxToRectangle(box, rect); + rect = transform().mapRect(rect); + return rect; +} + +void CellFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem* option, QWidget *) { + // QPen pen(Qt::blue); + // pen.setWidth(10); + // painter->setPen(pen); + // painter->drawLine(0, 0, 50, 0); + // + // painter->drawLine(0, 0, 0, 50); + // pen.setColor(Qt::red); + // painter->setPen(pen); + + painter->setClipRect(option->exposedRect); + if (option->levelOfDetail > 1.0) { + drawBoundary(painter); + } else { + drawPhantom(painter); + } +} + +void CellFigure::drawBoundary(QPainter* painter) { + QPen pen(Qt::black); + painter->setPen(pen); + Box box = cell->GetAbutmentBox(); + QRectF rect; + BoxToRectangle(box, rect); + painter->drawRect(rect); +} + +void CellFigure::drawPhantom(QPainter* painter) { + painter->setBrush(Qt::red); + Box box = cell->GetAbutmentBox(); + QRectF rect; + BoxToRectangle(box, rect); + painter->drawRect(rect); +} + diff --git a/hurricane/src/figures/CellFigure.h b/hurricane/src/figures/CellFigure.h new file mode 100644 index 00000000..1afc0eef --- /dev/null +++ b/hurricane/src/figures/CellFigure.h @@ -0,0 +1,27 @@ +#ifndef __CELL_FIGURE_H +#define __CELL_FIGURE_H + +#include +#include + +#include "Cell.h" +using namespace Hurricane; + +class InstanceFigure; + + +class CellFigure : public QGraphicsItem { + public: + CellFigure(Cell* cell); + CellFigure(InstanceFigure* master, Cell* cell); + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget); + + private: + Cell* cell; + void drawBoundary(QPainter* painter); + void drawPhantom(QPainter* painter); +}; + +#endif /* __CELL_FIGURE_H */ diff --git a/hurricane/src/figures/GoFigure.cpp b/hurricane/src/figures/GoFigure.cpp new file mode 100644 index 00000000..c01cb326 --- /dev/null +++ b/hurricane/src/figures/GoFigure.cpp @@ -0,0 +1,19 @@ +#include + +#include + +#include "SliceFigure.h" + +#include "Utils.h" +#include "GoFigure.h" + +GoFigure::GoFigure(SliceFigure* master): + QGraphicsItem(master) +{} + +QRectF GoFigure::boundingRect() const { + Box box = getGo()->GetBoundingBox(); + QRectF rect; + BoxToRectangle(box, rect); + return rect; +} diff --git a/hurricane/src/figures/GoFigure.h b/hurricane/src/figures/GoFigure.h new file mode 100644 index 00000000..2b7e9b75 --- /dev/null +++ b/hurricane/src/figures/GoFigure.h @@ -0,0 +1,20 @@ +#ifndef __GO_FIGURE_H +#define __GO_FIGURE_H + +#include +#include + +#include "Go.h" +using namespace H; + +class SliceFigure; + +class GoFigure : public QGraphicsItem { + public: + GoFigure(SliceFigure* parent); + QRectF boundingRect() const; + protected: + virtual Go* getGo() const = 0; +}; + +#endif /* __GO_FIGURE_H */ diff --git a/hurricane/src/figures/InstanceFigure.cpp b/hurricane/src/figures/InstanceFigure.cpp new file mode 100644 index 00000000..2481d4b4 --- /dev/null +++ b/hurricane/src/figures/InstanceFigure.cpp @@ -0,0 +1,30 @@ +#include +#include + +#include "Utils.h" +#include "InstanceFigure.h" + +InstanceFigure::InstanceFigure(CellFigure* parent, Instance* inst): + QGraphicsItem(parent), + instance(inst) { + Cell* masterCell = inst->GetMasterCell(); + + Transformation transformation = instance->GetTransformation(); + QTransform transform; + QPoint pos; + HurricanePositionToQtPosition(transformation, transform, pos); + setTransform(transform); + setPos(pos); + new CellFigure(this, masterCell); +} + +QRectF InstanceFigure::boundingRect() const { + Cell* masterCell = instance->GetMasterCell(); + Box box = masterCell->GetAbutmentBox(); + QRectF rect; + BoxToRectangle(box, rect); + return rect; +} + +void InstanceFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{} diff --git a/hurricane/src/figures/InstanceFigure.h b/hurricane/src/figures/InstanceFigure.h new file mode 100644 index 00000000..a922ca85 --- /dev/null +++ b/hurricane/src/figures/InstanceFigure.h @@ -0,0 +1,24 @@ +#ifndef __INSTANCE_FIGURE_H +#define __INSTANCE_FIGURE_H + +#include +#include + +#include "CellFigure.h" + +#include "Instance.h" +using namespace Hurricane; + +class InstanceFigure : public QGraphicsItem { + public: + InstanceFigure(CellFigure* parent, Instance* instance); + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget); + + private: + Instance* instance; + +}; + +#endif /* __INSTANCE_FIGURE_H */ diff --git a/hurricane/src/figures/SegmentFigure.cpp b/hurricane/src/figures/SegmentFigure.cpp new file mode 100644 index 00000000..f8e4b168 --- /dev/null +++ b/hurricane/src/figures/SegmentFigure.cpp @@ -0,0 +1,31 @@ +#include + +#include +#include + +#include "BasicLayer.h" +using namespace H; + +#include "Utils.h" +#include "SegmentFigure.h" + +SegmentFigure::SegmentFigure(SliceFigure* master, Segment* s): + GoFigure(master), + segment(s) + {} + +void SegmentFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + if (option->levelOfDetail < 1.0) { + painter->setClipRect(option->exposedRect); + BasicLayer* layer = dynamic_cast(segment->GetLayer()); + if (layer) { + painter->setBrush(QColor(layer->GetRedValue(), layer->GetGreenValue(), layer->GetBlueValue())); + } else { + painter->setBrush(Qt::blue); + } + Box box = segment->GetBoundingBox(); + QRectF rect; + BoxToRectangle(box, rect); + painter->drawRect(rect); + } +} diff --git a/hurricane/src/figures/SegmentFigure.h b/hurricane/src/figures/SegmentFigure.h new file mode 100644 index 00000000..d2ddab04 --- /dev/null +++ b/hurricane/src/figures/SegmentFigure.h @@ -0,0 +1,23 @@ +#ifndef __SEGMENT_FIGURE_H +#define __SEGMENT_FIGURE_H + +#include +#include + +#include "GoFigure.h" + +#include "Segment.h" +using namespace Hurricane; + +class SegmentFigure : public GoFigure { + public: + SegmentFigure(SliceFigure* parent, Segment* segment); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + + private: + Segment* segment; + protected: + Go* getGo() const { return segment; } +}; + +#endif /* __SEGMENT_FIGURE_H */ diff --git a/hurricane/src/figures/SliceFigure.cpp b/hurricane/src/figures/SliceFigure.cpp new file mode 100644 index 00000000..4450a01e --- /dev/null +++ b/hurricane/src/figures/SliceFigure.cpp @@ -0,0 +1,53 @@ +#include +#include + +#include "BasicLayer.h" +using namespace H; + +#include "SegmentFigure.h" +#include "Utils.h" +#include "SliceFigure.h" + +SliceFigure::SliceFigure(CellFigure* parent, Slice* sli): + QGraphicsItem(parent), + slice(sli) +{ +// constructGoFigures(); +} + +QRectF SliceFigure::boundingRect() const { + Box box = slice->GetBoundingBox(); + return QRectF(box.GetXMin(), box.GetXMax(), box.GetYMin(), box.GetYMax()); +} + +void SliceFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + if (option->levelOfDetail > 1.0) { +// painter->setClipRect(option->exposedRect); + BasicLayer* layer = dynamic_cast(slice->GetLayer()); + if (layer) { + painter->setBrush(QColor(layer->GetRedValue(), layer->GetGreenValue(), layer->GetBlueValue())); + } else { + painter->setBrush(Qt::blue); + } + for_each_go(go, slice->GetGos()) { + Segment* segment = dynamic_cast(go); + if (segment) { + Box box = segment->GetBoundingBox(); + QRectF rect; + BoxToRectangle(box, rect); + painter->drawRect(rect); + } + end_for; + } + } +} + +void SliceFigure::constructGoFigures() { + for_each_go(go, slice->GetGos()) { + Segment* segment = dynamic_cast(go); + if (segment) { + new SegmentFigure(this, segment); + } + end_for; + } +} diff --git a/hurricane/src/figures/SliceFigure.h b/hurricane/src/figures/SliceFigure.h new file mode 100644 index 00000000..b0789a71 --- /dev/null +++ b/hurricane/src/figures/SliceFigure.h @@ -0,0 +1,24 @@ +#ifndef __SLICE_FIGURE_H +#define __SLICE_FIGURE_H + +#include +#include + +#include "CellFigure.h" + +#include "Slice.h" +using namespace Hurricane; + +class SliceFigure : public QGraphicsItem { + public: + SliceFigure(CellFigure* parent, Slice* slice); + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget); + + private: + Slice* slice; + void constructGoFigures(); +}; + +#endif /* __SLICE_FIGURE_H */ diff --git a/hurricane/src/figures/Utils.h b/hurricane/src/figures/Utils.h new file mode 100644 index 00000000..9326b2b9 --- /dev/null +++ b/hurricane/src/figures/Utils.h @@ -0,0 +1,44 @@ +#ifndef __UTILS_H +#define __UTILS_H + +#include +#include +#include "Box.h" +#include "Transformation.h" +using namespace H; + +inline void BoxToRectangle(const Box& box, QRectF& rec) { + double xmin = GetValue(box.GetXMin()); + double xmax = GetValue(box.GetXMax()); + double ymin = GetValue(box.GetYMin()); + double ymax = GetValue(box.GetYMax()); + rec.setCoords(xmin, ymin, xmax, ymax); +} + +inline void HurricanePositionToQtPosition(const Transformation& transformation, QTransform& transform, QPoint& position) { + double tx = GetValue(transformation.GetTx()); + double ty = GetValue(transformation.GetTy()); + + position.setX((int)tx); + position.setY((int)ty); + + switch (transformation.GetOrientation()) { + case Transformation::Orientation::ID: + transform.setMatrix(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0); + break; + case Transformation::Orientation::MX: + transform.setMatrix(-1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0); + break; + case Transformation::Orientation::MY: + transform.setMatrix(1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0); + break; + case Transformation::Orientation::R2: + transform.setMatrix(-1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0); + break; + default: + break; + } +} + + +#endif /* __UTILS_H */ diff --git a/hurricane/src/hurricane.txt b/hurricane/src/hurricane.txt deleted file mode 100644 index 9daeafb9..00000000 --- a/hurricane/src/hurricane.txt +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/hurricane/src/hurricane/BasicLayer.cpp b/hurricane/src/hurricane/BasicLayer.cpp new file mode 100644 index 00000000..06e9f37d --- /dev/null +++ b/hurricane/src/hurricane/BasicLayer.cpp @@ -0,0 +1,462 @@ +// **************************************************************************************************** +// File: BasicLayer.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "BasicLayer.h" +#include "Technology.h" +#include "CompositeLayer.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// BasicLayer_BasicLayers declaration +// **************************************************************************************************** + +class BasicLayer_BasicLayers : public Collection { +// ********************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // *********************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const BasicLayer* _basicLayer; + + public: Locator(const BasicLayer* basicLayer = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual BasicLayer* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Atributes +// ********* + + private: const BasicLayer* _basicLayer; + +// Constructors +// ************ + + public: BasicLayer_BasicLayers(const BasicLayer* basicLayer = NULL); + public: BasicLayer_BasicLayers(const BasicLayer_BasicLayers& basicLayers); + +// Operators +// ********* + + public: BasicLayer_BasicLayers& operator=(const BasicLayer_BasicLayers& basicLayers); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// BasicLayer implementation +// **************************************************************************************************** + +BasicLayer::BasicLayer(Technology* technology, const Name& name, const Type& type, unsigned extractNumber, const Unit& minimalSize, const Unit& minimalSpacing) +// **************************************************************************************************** +: Inherit(technology, name, minimalSize, minimalSpacing), + _type(type), + _extractNumber(extractNumber), + _redValue(255), + _greenValue(255), + _blueValue(255), + _fillPattern("FFFFFFFFFFFFFFFF"), + _displayThreshold(0.0) +{ +} + +BasicLayer* BasicLayer::Create(Technology* technology, const Name& name, const Type& type, unsigned extractNumber, const Unit& minimalSize, const Unit& minimalSpacing) +// **************************************************************************************************** +{ + BasicLayer* basicLayer = + new BasicLayer(technology, name, type, extractNumber, minimalSize, minimalSpacing); + + basicLayer->_PostCreate(); + + return basicLayer; +} + +BasicLayers BasicLayer::GetBasicLayers() const +// ******************************************* +{ + return BasicLayer_BasicLayers(this); +} + +void BasicLayer::SetColor(unsigned short redValue, unsigned short greenValue, unsigned short blueValue) +// **************************************************************************************************** +{ + if ((redValue != _redValue) || (greenValue != _greenValue) || (blueValue != _blueValue)) { + _redValue = redValue; + _greenValue = greenValue; + _blueValue = blueValue; + //if (_drawGC) { + // gdk_gc_destroy(_drawGC); + // _drawGC = NULL; + //} + //if (_fillGC) { + // gdk_gc_destroy(_fillGC); + // _fillGC = NULL; + //} + } +} + +void BasicLayer::SetFillPattern(const string& fillPattern) +// ******************************************************* +{ + if (fillPattern != _fillPattern) { + if (fillPattern.size() != 16) + throw Error("Can't set fill pattern (bad value)"); + + string validChars = "0123456789ABCDEFabcdef"; + for (unsigned i = 0; i < 16; i++) { + if (validChars.find(fillPattern[i]) == string::npos) + throw Error("Can't set fill pattern (bad value)"); + } + _fillPattern = fillPattern; + //if (_drawGC) { + // gdk_gc_destroy(_drawGC); + // _drawGC = NULL; + //} + //if (_fillGC) { + // gdk_gc_destroy(_fillGC); + // _fillGC = NULL; + //} + } +} + +void BasicLayer::_PostCreate() +// *************************** +{ + Mask basicLayersMask = 0; + for_each_basic_layer(basicLayer, GetTechnology()->GetBasicLayers()) { + basicLayersMask |= basicLayer->GetMask(); + end_for; + } + + Mask mask = 1; + while (mask && (mask & basicLayersMask)) mask = mask<<1; + + if (!mask) + throw Error("Can't create " + _TName("BasicLayer") + " : mask capacity overflow"); + + _SetMask(mask); + + if (_extractNumber) { + Mask extractMask = (1 << _extractNumber); + + if (!extractMask) + throw Error("Can't create " + _TName("BasicLayer") + " : extract mask capacity overflow"); + + _SetExtractMask(extractMask); + } + + Inherit::_PostCreate(); +} + +void BasicLayer::_PreDelete() +// ************************** +{ + Inherit::_PreDelete(); + + //if (_drawGC) gdk_gc_destroy(_drawGC); + //if (_fillGC) gdk_gc_destroy(_fillGC); + + CompositeLayers compositeLayers = GetTechnology()->GetCompositeLayers(); + for_each_composite_layer(compositeLayer, compositeLayers) { + if (compositeLayer->Contains(this)) compositeLayer->Remove(this); + end_for; + } +} + +string BasicLayer::_GetString() const +// ********************************** +{ + string s = Inherit::_GetString(); + // s.insert(s.length() - 1, " " + GetString(_type)); + return s; +} + +Record* BasicLayer::_GetRecord() const +// ***************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Type", &_type)); + record->Add(GetSlot("RedValue", &_redValue)); + record->Add(GetSlot("GreenValue", &_greenValue)); + record->Add(GetSlot("BlueValue", &_blueValue)); + record->Add(GetSlot("FillPattern", &_fillPattern)); + record->Add(GetSlot("DisplayThreshold", &_displayThreshold)); + } + return record; +} + +//GdkGC* BasicLayer::_GetDrawGC() +//// **************************** +//{ +// if (!_drawGC) _drawGC = gtk_gc_new(_redValue, _greenValue, _blueValue); +// +// return _drawGC; +//} +// +//GdkGC* BasicLayer::_GetFillGC() +//// **************************** +//{ +// if (!_fillGC) _fillGC = gtk_gc_new(_redValue, _greenValue, _blueValue, _fillPattern); +// +// return _fillGC; +//} +// + +//void BasicLayer::_Fill(View* view, const Box& box) const +//// ***************************************************** +//{ +// switch (_type) { +// case Type::CONTACT : { +// +// Unit minimalSize = GetMinimalSize(); +// Unit minimalSpacing = GetMinimalSpacing(); +// +// if ((minimalSize <= 0) || (minimalSpacing <= 0)) +// view->FillRectangle(box); +// else { +// view->DrawRectangle(box); +// +// Unit width = box.GetWidth(); +// Unit height = box.GetHeight(); +// Unit offset = minimalSize + minimalSpacing; +// +// int nx = (int)(GetValue(width) / GetValue(offset)); +// int ny = (int)(GetValue(height) / GetValue(offset)); +// +// Unit dx = (width - (minimalSize + (offset * nx))) / 2; +// Unit dy = (height - (minimalSize + (offset * ny))) / 2; +// +// if (dx < 0) dx = (width - (minimalSize + (offset * (--nx)))) / 2; +// if (dy < 0) dy = (height - (minimalSize + (offset * (--ny)))) / 2; +// +// Unit xmin = box.GetXMin() + dx; +// Unit ymin = box.GetYMin() + dy; +// Unit xmax = box.GetXMax() - dx; +// Unit ymax = box.GetYMax() - dy; +// +// if ((xmin < xmax) && (ymin < ymax)) { +// Unit y = ymin; +// do { +// Unit x = xmin; +// do { +// view->FillRectangle(x, y, x + minimalSize, y + minimalSize, true); +// x += offset; +// } while (x < xmax); +// y += offset; +// } while (y < ymax); +// } +// } +// break; +// } +// default : { +// view->FillRectangle(box); +// break; +// } +// } +//} +// +// **************************************************************************************************** +// BasicLayer_BasicLayers implementation +// **************************************************************************************************** + +BasicLayer_BasicLayers::BasicLayer_BasicLayers(const BasicLayer* basicLayer) +// ************************************************************************* +: Inherit(), + _basicLayer(basicLayer) +{ +} + +BasicLayer_BasicLayers::BasicLayer_BasicLayers(const BasicLayer_BasicLayers& basicLayers) +// ************************************************************************************** +: Inherit(), + _basicLayer(basicLayers._basicLayer) +{ +} + +BasicLayer_BasicLayers& BasicLayer_BasicLayers::operator=(const BasicLayer_BasicLayers& basicLayers) +// ************************************************************************************************* +{ + _basicLayer = basicLayers._basicLayer; + return *this; +} + +Collection* BasicLayer_BasicLayers::GetClone() const +// ************************************************************** +{ + return new BasicLayer_BasicLayers(*this); +} + +Locator* BasicLayer_BasicLayers::GetLocator() const +// ************************************************************* +{ + return new Locator(_basicLayer); +} + +string BasicLayer_BasicLayers::_GetString() const +// ********************************************** +{ + string s = "<" + _TName("BasicLayer::BasicLayers"); + if (_basicLayer) s += " " + GetString(_basicLayer); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// BasicLayer_BasicLayers::Locator implementation +// **************************************************************************************************** + +BasicLayer_BasicLayers::Locator::Locator(const BasicLayer* basicLayer) +// ******************************************************************* +: Inherit(), + _basicLayer(basicLayer) +{ +} + +BasicLayer_BasicLayers::Locator::Locator(const Locator& locator) +// ************************************************************* +: Inherit(), + _basicLayer(locator._basicLayer) +{ +} + +BasicLayer_BasicLayers::Locator& BasicLayer_BasicLayers::Locator::operator=(const Locator& locator) +// ************************************************************************************************ +{ + _basicLayer = locator._basicLayer; + return *this; +} + +BasicLayer* BasicLayer_BasicLayers::Locator::GetElement() const +// ************************************************************ +{ + return (BasicLayer*)_basicLayer; +} + +Locator* BasicLayer_BasicLayers::Locator::GetClone() const +// ******************************************************************** +{ + return new Locator(*this); +} + +bool BasicLayer_BasicLayers::Locator::IsValid() const +// ************************************************** +{ + return (_basicLayer != NULL); +} + +void BasicLayer_BasicLayers::Locator::Progress() +// ********************************************* +{ + _basicLayer = NULL; +} + +string BasicLayer_BasicLayers::Locator::_GetString() const +// ******************************************************* +{ + string s = "<" + _TName("BasicLayer::BasicLayers::Locator"); + if (_basicLayer) s += " " + GetString(_basicLayer); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// BasicLayer::Type implementation +// **************************************************************************************************** + +BasicLayer::Type::Type(const Code& code) +// ************************************* +: _code(code) +{ +} + +BasicLayer::Type::Type(const Type& type) +// ************************************* +: _code(type._code) +{ +} + +BasicLayer::Type& BasicLayer::Type::operator=(const Type& type) +// ************************************************************ +{ + _code = type._code; + return *this; +} + +string BasicLayer::Type::_GetString() const +// **************************************** +{ + return GetString(_code); +} + +Record* BasicLayer::Type::_GetRecord() const +// *********************************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Code", &_code)); + return record; +} + +} // End of Hurricane namespace. + +bool Scan(const string& s, H::BasicLayer::Type& type) +// ************************************************** +{ + if (s == "UNDEFINED") { + type = H::BasicLayer::Type::UNDEFINED; + return true; + } + if (s == "CONDUCTING") { + type = H::BasicLayer::Type::CONDUCTING; + return true; + } + if (s == "CONTACT") { + type = H::BasicLayer::Type::CONTACT; + return true; + } + return false; +} + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/BasicLayer.h b/hurricane/src/hurricane/BasicLayer.h new file mode 100644 index 00000000..4d3c9009 --- /dev/null +++ b/hurricane/src/hurricane/BasicLayer.h @@ -0,0 +1,154 @@ +// **************************************************************************************************** +// File: BasicLayer.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_BASIC_LAYER +#define HURRICANE_BASIC_LAYER + +#include "Layer.h" +#include "BasicLayers.h" +#include "Box.h" + +namespace Hurricane { + +class View; + + + +// **************************************************************************************************** +// BasicLayer declaration +// **************************************************************************************************** + +class BasicLayer : public Layer { +// **************************** + +// Types +// ***** + + public: typedef Layer Inherit; + + public: class Type { + // *************** + + public: enum Code {UNDEFINED=0, CONDUCTING=1, CONTACT=2}; + + private: Code _code; + + public: Type(const Code& code = UNDEFINED); + public: Type(const Type& type); + + public: Type& operator=(const Type& type); + + public: operator const Code&() const {return _code;}; + + public: const Code& GetCode() const {return _code;}; + + public: string _GetTypeName() const { return _TName("BasicLayer::Type"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + }; + +// Attributes +// ********** + + private: Type _type; + private: unsigned _extractNumber; + private: unsigned short _redValue; + private: unsigned short _greenValue; + private: unsigned short _blueValue; + private: string _fillPattern; + private: double _displayThreshold; +// private: GdkGC* _drawGC; +// private: GdkGC* _fillGC; + +// Constructors +// ************ + + protected: BasicLayer(Technology* technology, const Name& name, const Type& type, unsigned extractNumber, const Unit& minimalSize = 0, const Unit& minimalSpacing = 0); + + public: static BasicLayer* Create(Technology* technology, const Name& name, const Type& type, unsigned extractNumber, const Unit& minimalSize = 0, const Unit& minimalSpacing = 0); + +// Accessors +// ********* + + public: const Type& GetType() const {return _type;}; + public: unsigned GetExtractNumber() const {return _extractNumber;}; + public: const unsigned short& GetRedValue() const {return _redValue;}; + public: const unsigned short& GetGreenValue() const {return _greenValue;}; + public: const unsigned short& GetBlueValue() const {return _blueValue;}; + public: const string& GetFillPattern() const {return _fillPattern;}; + public: double GetDisplayThreshold() const {return _displayThreshold;}; + public: virtual BasicLayers GetBasicLayers() const; + +// Updators +// ******** + + public: void SetColor(unsigned short redValue, unsigned short greenValue, unsigned short blueValue); + public: void SetFillPattern(const string& fillPattern); + public: void SetDisplayThreshold(double threshold) {_displayThreshold = threshold;}; + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("BasicLayer");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: virtual BasicLayer* _GetSymbolicBasicLayer() {return this;}; + //public: GdkGC* _GetDrawGC(); + //public: GdkGC* _GetFillGC(); + + public: void _Fill(View* view, const Box& box) const; + +}; + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName ( const BasicLayer::Type::Code* object ) + { return ">"; } + +template<> + inline string ProxyString ( const BasicLayer::Type::Code* object ) + { + switch ( *object ) { + case BasicLayer::Type::UNDEFINED: return "UNDEFINED"; + case BasicLayer::Type::CONDUCTING: return "CONDUCTING"; + case BasicLayer::Type::CONTACT: return "CONTACT"; + } + return "ABNORMAL"; + } + +template<> + inline Record* ProxyRecord ( const BasicLayer::Type::Code* object ) + { + Record* record = new Record(GetString(object)); + record->Add(GetSlot("Code", (unsigned int*)object)); + return record; + } + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::BasicLayer) + + +bool Scan(const string& s, H::BasicLayer::Type& type); + + +#endif // HURRICANE_BASIC_LAYER + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/BasicLayers.h b/hurricane/src/hurricane/BasicLayers.h new file mode 100644 index 00000000..2f71db84 --- /dev/null +++ b/hurricane/src/hurricane/BasicLayers.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: BasicLayers.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_BASIC_LAYERS +#define HURRICANE_BASIC_LAYERS + +#include "Collection.h" + +namespace Hurricane { + +class BasicLayer; + + + +// **************************************************************************************************** +// BasicLayers declaration +// **************************************************************************************************** + +typedef GenericCollection BasicLayers; + + + +// **************************************************************************************************** +// BasicLayerLocator declaration +// **************************************************************************************************** + +typedef GenericLocator BasicLayerLocator; + + + +// **************************************************************************************************** +// BasicLayerFilter declaration +// **************************************************************************************************** + +typedef GenericFilter BasicLayerFilter; + + + +// **************************************************************************************************** +// for_each_basic_layer declaration +// **************************************************************************************************** + +#define for_each_basic_layer(basicLayer, basicLayers)\ +/****************************************************/\ +{\ + BasicLayerLocator _locator = basicLayers.GetLocator();\ + while (_locator.IsValid()) {\ + BasicLayer* basicLayer = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_BASIC_LAYERS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Box.cpp b/hurricane/src/hurricane/Box.cpp new file mode 100644 index 00000000..61809066 --- /dev/null +++ b/hurricane/src/hurricane/Box.cpp @@ -0,0 +1,349 @@ +// **************************************************************************************************** +// File: Box.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 added ManhattanDistance & ShrinkByFactor + +#include "Error.h" +#include "Box.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Box implementation +// **************************************************************************************************** + +Box::Box() +// ******* +: _xMin(1), + _yMin(1), + _xMax(-1), + _yMax(-1) +{ +} + +Box::Box(const Unit& x, const Unit& y) +// *********************************** +: _xMin(x), + _yMin(y), + _xMax(x), + _yMax(y) +{ +} + +Box::Box(const Point& point) +// ************************* +: _xMin(point.GetX()), + _yMin(point.GetY()), + _xMax(point.GetX()), + _yMax(point.GetY()) +{ +} + +Box::Box(const Unit& x1, const Unit& y1, const Unit& x2, const Unit& y2) +// ********************************************************************* +: _xMin(min(x1, x2)), + _yMin(min(y1, y2)), + _xMax(max(x1, x2)), + _yMax(max(y1, y2)) +{ +} + +Box::Box(const Point& point1, const Point& point2) +// *********************************************** +: _xMin(min(point1.GetX(), point2.GetX())), + _yMin(min(point1.GetY(), point2.GetY())), + _xMax(max(point1.GetX(), point2.GetX())), + _yMax(max(point1.GetY(), point2.GetY())) +{ +} + +Box::Box(const Box& box) +// ********************* +: _xMin(box._xMin), + _yMin(box._yMin), + _xMax(box._xMax), + _yMax(box._yMax) +{ +} + +Box& Box::operator=(const Box& box) +// ******************************** +{ + _xMin = box._xMin; + _yMin = box._yMin; + _xMax = box._xMax; + _yMax = box._yMax; + return *this; +} + +bool Box::operator==(const Box& box) const +// *************************************** +{ + return (!IsEmpty() && + !box.IsEmpty() && + (_xMin == box._xMin) && + (_yMin == box._yMin) && + (_xMax == box._xMax) && + (_yMax == box._yMax)); +} + +bool Box::operator!=(const Box& box) const +// *************************************** +{ + return (IsEmpty() || + box.IsEmpty() || + (_xMin != box._xMin) || + (_yMin != box._yMin) || + (_xMax != box._xMax) || + (_yMax != box._yMax)); +} + +Box Box::GetUnion(const Box& box) const +// ************************************ +{ + if (IsEmpty() && box.IsEmpty()) return Box(); + return Box(min(_xMin, box._xMin), + min(_yMin, box._yMin), + max(_xMax, box._xMax), + max(_yMax, box._yMax)); +} + +Box Box::GetIntersection(const Box& box) const +// ******************************************* +{ + if (!Intersect(box)) return Box(); + return Box(max(_xMin, box._xMin), + max(_yMin, box._yMin), + min(_xMax, box._xMax), + min(_yMax, box._yMax)); +} + +Unit Box::ManhattanDistance(const Point& pt) const +// *********************************************** +{ + Unit dist = 0; + if (IsEmpty()) + throw Error("Can't compute distance to an empty Box"); + if (pt.GetX() < _xMin) dist = _xMin - pt.GetX(); + else if (pt.GetX() > _xMax) dist = pt.GetX() - _xMax; + // else dist = 0; + if (pt.GetY() < _yMin) dist += _yMin - pt.GetY(); + else if (pt.GetY() > _yMax) dist += pt.GetY() - _yMax; + // else dist += 0; + return dist; +} + +Unit Box::ManhattanDistance(const Box& box) const +// ********************************************** +{ + if (IsEmpty() || box.IsEmpty()) + throw Error("Can't compute distance to an empty Box"); + Unit dx, dy; + if ((dx=box.GetXMin() - _xMax) < 0) + if ((dx=_xMin-box.GetXMax()) < 0) dx=0; + if ((dy=box.GetYMin() - _yMax) < 0) + if ((dy=_yMin-box.GetYMax()) < 0) dy=0; + return dx+dy; +} + +bool Box::IsEmpty() const +// ********************** +{ + return ((_xMax < _xMin) || (_yMax < _yMin)); +} + +bool Box::IsFlat() const +// ********************* +{ + return (!IsEmpty() && + (((_xMin == _xMax) && (_yMin < _yMax)) || + ((_xMin < _xMax) && (_yMin == _yMax)))); +} + +bool Box::IsPonctual() const +// ************************* +{ + return (!IsEmpty() && (_xMax == _xMin) && (_yMax == _yMin)); +} + +bool Box::Contains(const Unit& x, const Unit& y) const +// *************************************************** +{ + return (!IsEmpty() && + (_xMin <= x) && + (_yMin <= y) && + (x <= _xMax) && + (y <= _yMax)); +} + +bool Box::Contains(const Point& point) const +// ***************************************** +{ + return Contains(point.GetX(), point.GetY()); +} + +bool Box::Contains(const Box& box) const +// ************************************* +{ + return (!IsEmpty() && + !box.IsEmpty() && + (_xMin <= box._xMin) && + (box._xMax <= _xMax) && + (_yMin <= box._yMin) && + (box._yMax <= _yMax)); +} + +bool Box::Intersect(const Box& box) const +// ************************************** +{ + return (!IsEmpty() && + !box.IsEmpty() && + !((_xMax < box._xMin) || + (box._xMax < _xMin) || + (_yMax < box._yMin) || + (box._yMax < _yMin))); +} + +bool Box::IsConstrainedBy(const Box& box) const +// ******************************************** +{ + return (!IsEmpty() && + !box.IsEmpty() && + ((_xMin == box.GetXMin()) || + (_yMin == box.GetYMin()) || + (_xMax == box.GetXMax()) || + (_yMax == box.GetYMax()))); +} + +Box& Box::MakeEmpty() +// ****************** +{ + _xMin = 1; + _yMin = 1; + _xMax = -1; + _yMax = -1; + return *this; +} + +Box& Box::Inflate(const Unit& d) +// ***************************** +{ + return Inflate(d, d, d, d); +} + +Box& Box::Inflate(const Unit& dx, const Unit& dy) +// ********************************************** +{ + return Inflate(dx, dy, dx, dy); +} + +Box& Box::Inflate(const Unit& dxMin, const Unit& dyMin, const Unit& dxMax, const Unit& dyMax) +// ****************************************************************************************** +{ + if (!IsEmpty()) { + _xMin -= dxMin; + _yMin -= dyMin; + _xMax += dxMax; + _yMax += dyMax; + } + return *this; +} + +Box& Box::ShrinkByFactor(double factor) +// ************************************** +{ + assert((0 <= factor) && (factor <= 1)); + Unit dx=GetUnit(0.5*(1- factor) * (GetValue(_xMax) - GetValue(_xMin))); + Unit dy=GetUnit(0.5*(1- factor) * (GetValue(_yMax) - GetValue(_yMin))); + return Inflate(-dx, -dy); +} + +Box& Box::Merge(const Unit& x, const Unit& y) +// ****************************************** +{ + if (IsEmpty()) { + _xMin = x; + _yMin = y; + _xMax = x; + _yMax = y; + } + else { + _xMin = min(_xMin, x); + _yMin = min(_yMin, y); + _xMax = max(_xMax, x); + _yMax = max(_yMax, y); + } + return *this; +} + +Box& Box::Merge(const Point& point) +// ******************************** +{ + return Merge(point.GetX(), point.GetY()); +} + +Box& Box::Merge(const Unit& x1, const Unit& y1, const Unit& x2, const Unit& y2) +// **************************************************************************** +{ + Merge(x1, y1); + Merge(x2, y2); + return *this; +} + +Box& Box::Merge(const Box& box) +// **************************** +{ + if (!box.IsEmpty()) { + Merge(box.GetXMin(), box.GetYMin()); + Merge(box.GetXMax(), box.GetYMax()); + } + return *this; +} + +Box& Box::Translate(const Unit& dx, const Unit& dy) +// ************************************************ +{ + if (!IsEmpty()) { + _xMin += dx; + _yMin += dy; + _xMax += dx; + _yMax += dy; + } + return *this; +} + +string Box::_GetString() const +// *************************** +{ + if (IsEmpty()) + return "<" + _TName("Box") + " empty>"; + else + return "<" + _TName("Box") + " " + + GetValueString(_xMin) + " " + GetValueString(_yMin) + " " + + GetValueString(_xMax) + " " + GetValueString(_yMax) + + ">"; +} + +Record* Box::_GetRecord() const +// ********************** +{ + if (IsEmpty()) return NULL; + + Record* record = new Record(GetString(this)); + record->Add(GetSlot("XMin", &_xMin)); + record->Add(GetSlot("YMin", &_yMin)); + record->Add(GetSlot("XMax", &_xMax)); + record->Add(GetSlot("YMax", &_yMax)); + return record; +} + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Box.h b/hurricane/src/hurricane/Box.h new file mode 100644 index 00000000..0d281c2b --- /dev/null +++ b/hurricane/src/hurricane/Box.h @@ -0,0 +1,128 @@ +// **************************************************************************************************** +// File: Box.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 added ManhattanDistance & ShrinkByFactor + +#ifndef HURRICANE_BOX +#define HURRICANE_BOX + +#include "Point.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Box declaration +// **************************************************************************************************** + +class Box { +// ****** + +// Attributes +// ********** + + private: Unit _xMin; + private: Unit _yMin; + private: Unit _xMax; + private: Unit _yMax; + +// constructors +// ************ + + public: Box(); + + public: Box(const Unit& x, const Unit& y); + public: Box(const Point& point); + public: Box(const Unit& x1, const Unit& y1, const Unit& x2, const Unit& y2); + public: Box(const Point& point1, const Point& point2); + + public: Box(const Box& box); + +// Operators +// ********* + + public: Box& operator=(const Box& box); + + public: bool operator==(const Box& box) const; + public: bool operator!=(const Box& box) const; + +// Accessors +// ********* + + public: const Unit& GetXMin() const {return _xMin;}; + public: const Unit& GetYMin() const {return _yMin;}; + public: const Unit& GetXMax() const {return _xMax;}; + public: const Unit& GetYMax() const {return _yMax;}; + + public: Unit GetXCenter() const {return ((_xMin + _xMax) / 2);}; + public: Unit GetYCenter() const {return ((_yMin + _yMax) / 2);}; + public: Point GetCenter() const {return Point(GetXCenter(), GetYCenter());}; + + public: Unit GetWidth() const {return (_xMax - _xMin);}; + public: Unit GetHalfWidth() const {return (GetWidth() / 2);}; + public: Unit GetHeight() const {return (_yMax - _yMin);}; + public: Unit GetHalfHeight() const {return (GetHeight() / 2);}; + + public: Box GetUnion(const Box& box) const; + + public: Box GetIntersection(const Box& box) const; + public: Unit ManhattanDistance(const Point& pt) const; + public: Unit ManhattanDistance(const Box& box) const; + +// Predicates +// ********** + + public: bool IsEmpty() const; + public: bool IsFlat() const; + public: bool IsPonctual() const; + + public: bool Contains(const Unit& x, const Unit& y) const; + public: bool Contains(const Point& point) const; + public: bool Contains(const Box& box) const; + + public: bool Intersect(const Box& box) const; + + public: bool IsConstrainedBy(const Box& box) const; + +// Updators +// ******** + + public: Box& MakeEmpty(); + + public: Box& Inflate(const Unit& d); + public: Box& Inflate(const Unit& dx, const Unit& dy); + public: Box& Inflate(const Unit& dxMin, const Unit& dyMin, const Unit& dxMax, const Unit& dyMax); + public: Box& ShrinkByFactor(double factor); // 0 <= factor <= 1 + + public: Box& Merge(const Unit& x, const Unit& y); + public: Box& Merge(const Point& point); + public: Box& Merge(const Unit& x1, const Unit& y1, const Unit& x2, const Unit& y2); + public: Box& Merge(const Box& box); + + public: Box& Translate(const Unit& dx, const Unit& dy); + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("Box"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + +}; + + + +} // End of Hurricane namespace. + + +ValueIOStreamSupport(Hurricane::Box) + + +#endif // HURRICANE_BOX + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Boxes.h b/hurricane/src/hurricane/Boxes.h new file mode 100644 index 00000000..774b0b2d --- /dev/null +++ b/hurricane/src/hurricane/Boxes.h @@ -0,0 +1,61 @@ +// **************************************************************************************************** +// File: Boxes.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_BOXES +#define HURRICANE_BOXES + +#include "Collection.h" +#include "Box.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Boxes declaration +// **************************************************************************************************** + +typedef GenericCollection Boxes; + + + +// **************************************************************************************************** +// BoxLocator declaration +// **************************************************************************************************** + +typedef GenericLocator BoxLocator; + + + +// **************************************************************************************************** +// BoxFilter declaration +// **************************************************************************************************** + +typedef GenericFilter BoxFilter; + + + +// **************************************************************************************************** +// for_each_box declaration +// **************************************************************************************************** + +#define for_each_box(box, boxes)\ +/*******************************/\ +{\ + BoxLocator _locator = boxes.GetLocator();\ + while (_locator.IsValid()) {\ + Box box = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_BOXES + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/CMakeLists.txt b/hurricane/src/hurricane/CMakeLists.txt new file mode 100644 index 00000000..d181e0ff --- /dev/null +++ b/hurricane/src/hurricane/CMakeLists.txt @@ -0,0 +1,36 @@ +set(includes BasicLayer.h BasicLayers.h Boxes.h Box.h Cell.h +Cells.h Collection.h Commons.h Component.h Components.h CompositeLayer.h +CompositeLayers.h Contact.h Contacts.h DataBase.h DBo.h DBos.h +DeepNet.h DisplaySlot.h DisplaySlots.h DRCError.h Entities.h +Entity.h Error.h Exception.h Filter.h Go.h Gos.h +Hook.h Hooks.h Horizontal.h Horizontals.h +HyperNet.h Instance.h Instances.h Interruption.h Interval.h +Intervals.h IntrusiveMap.h IntrusiveSet.h Layer.h Layers.h Libraries.h +Library.h ListCollection.h Locator.h MapCollection.h Marker.h Markers.h +MultisetCollection.h Name.h Names.h NetExternalComponents.h Net.h +Nets.h Occurrence.h Occurrences.h Pad.h Pads.h Pathes.h Path.h +Pin.h Pins.h Plug.h Plugs.h Point.h Points.h Primitives.h Properties.h +Property.h QuadTree.h Quark.h Quarks.h Record.h Reference.h References.h Region.h +Relation.h RoutingPad.h RoutingPads.h Rubber.h Rubbers.h Segment.h Segments.h Selectors.h +SetCollection.h SharedName.h SharedPathes.h SharedPath.h Slice.h Slices.h +SlotAdapter.h Slot.h Symbols.h Tabulation.h Tag.h Tags.h Technology.h Timer.h +Transformation.h Unit.h UpdateSession.h UserGo.h UserGos.h VectorCollection.h Vertical.h +Verticals.h Views.h Warning.h) + +set(cpps BasicLayer.cpp Box.cpp CellCollections.cpp Cell.cpp +Commons.cpp Component.cpp CompositeLayer.cpp Contact.cpp DataBase.cpp +DBo.cpp DeepNet.cpp DisplaySlot.cpp DRCError.cpp Entity.cpp +Error.cpp Exception.cpp Go.cpp Hook.cpp Horizontal.cpp HyperNet.cpp +Instance.cpp Interruption.cpp Interval.cpp Layer.cpp Library.cpp +Marker.cpp Name.cpp Net.cpp NetExternalComponents.cpp Occurrence.cpp +Pad.cpp Path.cpp Pin.cpp Plug.cpp Point.cpp Property.cpp +QuadTree.cpp Quark.cpp Record.cpp Reference.cpp Region.cpp +Relation.cpp RoutingPad.cpp Rubber.cpp Segment.cpp SharedName.cpp +SharedPath.cpp Slice.cpp SlotAdapter.cpp Slot.cpp Tabulation.cpp +Tag.cpp Technology.cpp Timer.cpp Transformation.cpp Unit.cpp UpdateSession.cpp +UserGo.cpp Vertical.cpp Warning.cpp) + +add_library(hurricane SHARED ${cpps}) + +install(FILES ${includes} DESTINATION /include/hurricane) +install(TARGETS hurricane DESTINATION /lib) diff --git a/hurricane/src/hurricane/Cell.cpp b/hurricane/src/hurricane/Cell.cpp new file mode 100644 index 00000000..a73e1b80 --- /dev/null +++ b/hurricane/src/hurricane/Cell.cpp @@ -0,0 +1,701 @@ +// **************************************************************************************************** +// File: Cell.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Cell.h" +#include "DataBase.h" +#include "Library.h" +#include "Instance.h" +#include "Net.h" +#include "Pin.h" +#include "RoutingPad.h" +#include "Layer.h" +#include "Slice.h" +#include "Rubber.h" +#include "Marker.h" +#include "Component.h" +#include "UpdateSession.h" +#include "Error.h" + +namespace Hurricane { + +// **************************************************************************************************** +// Cell implementation +// **************************************************************************************************** + +Cell::Cell(Library* library, const Name& name) +// ******************************************* +: Inherit(), + _library(library), + _name(name), + _instanceMap(), + _quadTree(), + _slaveInstanceSet(), + _netMap(), + _sliceMap(), + _markerSet(), + //_viewSet(), + _abutmentBox(), + _boundingBox(), + _isTerminal(true), + _isPad(false), + _nextOfLibraryCellMap(NULL), + _nextOfSymbolCellSet(NULL), + _slaveEntityMap() +{ + if (!_library) + throw Error("Can't create " + _TName("Cell") + " : null library"); + + if (name.IsEmpty()) + throw Error("Can't create " + _TName("Cell") + " : empty name"); + + if (_library->GetCell(_name)) + throw Error("Can't create " + _TName("Cell") + " : already exists"); +} + +Cell* Cell::Create(Library* library, const Name& name) +// *************************************************** +{ + Cell* cell = new Cell(library, name); + + cell->_PostCreate(); + + return cell; +} + +Box Cell::GetBoundingBox() const +// ***************************** +{ + if (_boundingBox.IsEmpty()) { + Box& boundingBox = (Box&)_boundingBox; + boundingBox = _abutmentBox; + boundingBox.Merge(_quadTree.GetBoundingBox()); + for_each_slice(slice, GetSlices()) { + boundingBox.Merge(slice->GetBoundingBox()); + end_for; + } + } + + return _boundingBox; +} + +bool Cell::IsLeaf() const +// ********************** +{ + return _instanceMap.IsEmpty(); +} + +bool Cell::IsCalledBy(Cell* cell) const +// ************************************ +{ + for_each_instance(instance, cell->GetInstances()) { + Cell* masterCell = instance->GetMasterCell(); + if (masterCell == this) return true; + if (IsCalledBy(masterCell)) return true; + end_for; + } + return false; +} + +void Cell::SetName(const Name& name) +// ********************************* +{ + if (name != _name) { + if (name.IsEmpty()) + throw Error("Can't change " + _TName("Cell") + " name : empty name"); + + if (_library->GetCell(name)) + throw Error("Can't change " + _TName("Cell") + " name : already exists"); + + _library->_GetCellMap()._Remove(this); + _name = name; + _library->_GetCellMap()._Insert(this); + } +} + +void Cell::SetAbutmentBox(const Box& abutmentBox) +// ********************************************** +{ + if (abutmentBox != _abutmentBox) { + if (!_abutmentBox.IsEmpty() && + (abutmentBox.IsEmpty() || !abutmentBox.Contains(_abutmentBox))) + _Unfit(_abutmentBox); + _abutmentBox = abutmentBox; + _Fit(_abutmentBox); + } +} + +void Cell::FlattenNets(bool buildRings) +// ************************************ +{ + OpenUpdateSession (); + + for_each_occurrence ( occurrence, GetHyperNetRootNetOccurrences() ) { + HyperNet hyperNet ( occurrence ); + if ( !occurrence.GetPath().IsEmpty() ) { + DeepNet* deepNet = DeepNet::Create ( hyperNet ); + if (deepNet) deepNet->_CreateRoutingPads ( buildRings ); + } else { + RoutingPad* previousRP = NULL; + RoutingPad* currentRP = NULL; + Net* net = static_cast(occurrence.GetEntity()); + + for_each_component ( component, net->GetComponents() ) { + Plug* primaryPlug = dynamic_cast( component ); + if ( primaryPlug ) { + if ( !primaryPlug->GetBodyHook()->GetSlaveHooks().IsEmpty() ) { + cerr << "[ERROR] " << primaryPlug << "\n" + << " has attached components, not managed yet." << endl; + } else { + primaryPlug->GetBodyHook()->Detach (); + } + } + end_for + } + + for_each_occurrence ( plugOccurrence, hyperNet.GetLeafPlugOccurrences() ) { + currentRP = CreateRoutingPad ( net, plugOccurrence ); + currentRP->Materialize (); + if ( buildRings ) { + if ( previousRP ) { + currentRP->GetBodyHook()->Attach ( previousRP->GetBodyHook() ); + } + Plug* plug = static_cast( plugOccurrence.GetEntity() ); + if ( plugOccurrence.GetPath().IsEmpty() ) { + plug->GetBodyHook()->Attach ( currentRP->GetBodyHook() ); + plug->GetBodyHook()->Detach (); + } + previousRP = currentRP; + } + + end_for + } + + for_each_component ( component, net->GetComponents() ) { + Pin* pin = dynamic_cast( component ); + if ( pin ) { + currentRP = CreateRoutingPad ( pin ); + if ( buildRings ) { + if ( previousRP ) { + currentRP->GetBodyHook()->Attach ( previousRP->GetBodyHook() ); + } + pin->GetBodyHook()->Attach ( currentRP->GetBodyHook() ); + pin->GetBodyHook()->Detach (); + } + previousRP = currentRP; + } + + end_for + } + } + end_for + } + + CloseUpdateSession (); +} + +void Cell::Materialize() +// ********************* +{ + for_each_instance(instance, GetInstances()) instance->Materialize(); end_for; + for_each_net(net, GetNets()) net->Materialize(); end_for; + for_each_marker(marker, GetMarkers()) marker->Materialize(); end_for; +} + +void Cell::Unmaterialize() +// *********************** +{ + for_each_instance(instance, GetInstances()) instance->Unmaterialize(); end_for; + for_each_net(net, GetNets()) net->Unmaterialize(); end_for; + for_each_marker(marker, GetMarkers()) marker->Unmaterialize(); end_for; +} + +void Cell::_PostCreate() +// ********************* +{ + _library->_GetCellMap()._Insert(this); + + Inherit::_PostCreate(); +} + +void Cell::_PreDelete() +// ******************** +{ + Inherit::_PreDelete(); + + while(_slaveEntityMap.size()) { + _slaveEntityMap.begin()->second->Delete(); + } + + //for_each_view(view, GetViews()) view->SetCell(NULL); end_for; + for_each_marker(marker, GetMarkers()) marker->Delete(); end_for; + for_each_instance(slaveInstance, GetSlaveInstances()) slaveInstance->Delete(); end_for; + for_each_instance(instance, GetInstances()) instance->Delete(); end_for; + for_each_net(net, GetNets()) net->Delete(); end_for; + for_each_slice(slice, GetSlices()) slice->_Delete(); end_for; + + _library->_GetCellMap()._Remove(this); +} + +string Cell::_GetString() const +// **************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_name)); + return s; +} + +Record* Cell::_GetRecord() const +// *********************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Library", _library)); + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("Instances", &_instanceMap)); + record->Add(GetSlot("QuadTree", &_quadTree)); + record->Add(GetSlot("SlaveInstances", &_slaveInstanceSet)); + record->Add(GetSlot("Nets", &_netMap)); + record->Add(GetSlot("Pins", &_pinMap)); + record->Add(GetSlot("Slices", &_sliceMap)); + record->Add(GetSlot("Markers", &_markerSet)); + //record->Add(GetSlot("Views", &_viewSet)); + record->Add(GetSlot("AbutmentBox", &_abutmentBox)); + record->Add(GetSlot("BoundingBox", &_boundingBox)); + record->Add(GetSlot("IsTerminal", &_isTerminal)); + record->Add(GetSlot("IsFlattenLeaf", &_isFlattenLeaf)); + //record->Add(GetSlot("Symbol", _symbol)); + } + return record; +} + +void Cell::_Fit(const Box& box) +// **************************** +{ + if (box.IsEmpty()) return; + if (_boundingBox.IsEmpty()) return; + if (_boundingBox.Contains(box)) return; + _boundingBox.Merge(box); + for_each_instance(instance, GetSlaveInstances()) { + instance->GetCell()->_Fit(instance->GetTransformation().GetBox(box)); + end_for; + } +} + +void Cell::_Unfit(const Box& box) +// ****************************** +{ + if (box.IsEmpty()) return; + if (_boundingBox.IsEmpty()) return; + if (!_boundingBox.IsConstrainedBy(box)) return; + _boundingBox.MakeEmpty(); + for_each_instance(instance, GetSlaveInstances()) { + instance->GetCell()->_Unfit(instance->GetTransformation().GetBox(box)); + end_for; + } +} + +void Cell::_AddSlaveEntity(Entity* entity, Entity* slaveEntity) +// ************************************************************************ +{ + assert(entity->GetCell() == this); + + _slaveEntityMap.insert(pair(entity,slaveEntity)); +} + +void Cell::_RemoveSlaveEntity(Entity* entity, Entity* slaveEntity) +// *************************************************************************** +{ + assert(entity->GetCell() == this); + + pair + bounds = _slaveEntityMap.equal_range(entity); + multimap::iterator it = bounds.first; + for(; it != bounds.second ; it++ ) { + if (it->second == slaveEntity) { + _slaveEntityMap.erase(it); + break; + } + } +} + +void Cell::_GetSlaveEntities(SlaveEntityMap::iterator& begin, SlaveEntityMap::iterator& end) +// ********************************************************************************************************* +{ + begin = _slaveEntityMap.begin(); + end = _slaveEntityMap.end(); +} + +void Cell::_GetSlaveEntities(Entity* entity, SlaveEntityMap::iterator& begin, SlaveEntityMap::iterator& end) +// ********************************************************************************************************* +{ + begin = _slaveEntityMap.lower_bound(entity); + end = _slaveEntityMap.upper_bound(entity); +} + +//bool Cell::_IsDrawable(View* view) const +//// ************************************* +//{ +// return true; +// //if (view->GetCell() == this) return true; +// +// //if (is_a(view)) return true; +// +// //return (1 < (double)view->GetScreenSize(_boundingBox.GetHeight())); +//// return (100 < ((double)view->GetScreenSize(_boundingBox.GetWidth()) * +//// (double)view->GetScreenSize(_boundingBox.GetHeight()))); +//} +// +//bool Cell::_ContentIsDrawable(View* view) const +//// ******************************************** +//{ +// if (IsTerminal()) return false; +// +// return true; +// +// //if (view->GetCell() == this) return true; +// +// //if (is_a(view)) return false; +// +// //return (40 < (double)view->GetScreenSize(_boundingBox.GetHeight())); +//// return (400 < ((double)view->GetScreenSize(_boundingBox.GetWidth()) * +//// (double)view->GetScreenSize(_boundingBox.GetHeight()))); +//} +// +//void Cell::_DrawPhantoms(View* view, const Box& updateArea, const Transformation& transformation) +//// ********************************************************************************************** +//{ +//// if (_IsDrawable(view)) { // To avoid irregular display of instances phantoms +//// if (!_ContentIsDrawable(view)) +//// view->FillRectangle(transformation.GetBox(GetAbutmentBox())); +//// else { +//// for_each_instance(instance, GetInstancesUnder(updateArea)) { +//// instance->_DrawPhantoms(view, updateArea, transformation); +//// end_for; +//// } +//// } +//// } +//} +// +//void Cell::_DrawBoundaries(View* view, const Box& updateArea, const Transformation& transformation) +//// ************************************************************************************************ +//{ +// // if (_IsDrawable(view)) { // To avoid irregular display of instances phantoms +// // view->DrawRectangle(transformation.GetBox(GetAbutmentBox())); +// // if (_ContentIsDrawable(view)) { +// // for_each_instance(instance, GetInstancesUnder(updateArea)) { +// // instance->_DrawBoundaries(view, updateArea, transformation); +// // end_for; +// // } +// // } +// // } +//} +// +//void Cell::_DrawContent(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) +//// **************************************************************************************************** +//{ +//// if (_IsDrawable(view)) { +//// if (_ContentIsDrawable(view)) { +//// view->CheckForDisplayInterruption(); +//// for_each_instance(instance, GetInstancesUnder(updateArea)) { +//// instance->_Draw(view, basicLayer, updateArea, transformation); +//// end_for; +//// } +//// for_each_slice(slice, GetSlices()) { +//// slice->_Draw(view, basicLayer, updateArea, transformation); +//// end_for; +//// } +//// } +//// } +//} +// +//void Cell::_DrawRubbers(View* view, const Box& updateArea, const Transformation& transformation) +//// ********************************************************************************************* +//{ +//// if (_IsDrawable(view)) { +//// if (_ContentIsDrawable(view)) { +//// for_each_instance(instance, GetInstancesUnder(updateArea)) { +//// instance->_DrawRubbers(view, updateArea, transformation); +//// end_for; +//// } +//// for_each_rubber(rubber, GetRubbersUnder(updateArea)) { +//// rubber->_Draw(view, NULL, updateArea, transformation); +//// end_for; +//// } +//// } +//// } +//} +// +//void Cell::_DrawMarkers(View* view, const Box& updateArea, const Transformation& transformation) +//// ********************************************************************************************* +//{ +//// if (_IsDrawable(view)) { +//// if (_ContentIsDrawable(view)) { +//// for_each_instance(instance, GetInstancesUnder(updateArea)) { +//// instance->_DrawMarkers(view, updateArea, transformation); +//// end_for; +//// } +//// for_each_marker(marker, GetMarkersUnder(updateArea)) { +//// marker->_Draw(view, NULL, updateArea, transformation); +//// end_for; +//// } +//// } +//// } +//} +// +//void Cell::_DrawDisplaySlots(View* view, const Box& area, const Box& updateArea, const Transformation& transformation) +//// ******************************************************************************************************************** +//{ +//// if (_IsDrawable(view)) { +//// if (_ContentIsDrawable(view)) { +//// for_each_instance(instance, GetInstancesUnder(updateArea)) { +//// instance->_DrawDisplaySlots(view, area, updateArea, transformation); +//// end_for; +//// } +//// for_each_display_slot(displaySlot, GetDisplaySlots(this)) { +//// view->_DrawDisplaySlot(displaySlot, area, updateArea, transformation); +//// end_for; +//// } +//// } +//// } +//} +// +// **************************************************************************************************** +// Cell::InstanceMap implementation +// **************************************************************************************************** + +Cell::InstanceMap::InstanceMap() +// ***************************** +: Inherit() +{ +} + +Name Cell::InstanceMap::_GetKey(Instance* instance) const +// ****************************************************** +{ + return instance->GetName(); +} + +unsigned Cell::InstanceMap::_GetHashValue(Name name) const +// ******************************************************* +{ + return ( (unsigned int)( (unsigned long)name._GetSharedName() ) ) / 8; +} + +Instance* Cell::InstanceMap::_GetNextElement(Instance* instance) const +// ******************************************************************* +{ + return instance->_GetNextOfCellInstanceMap(); +} + +void Cell::InstanceMap::_SetNextElement(Instance* instance, Instance* nextInstance) const +// ************************************************************************************** +{ + instance->_SetNextOfCellInstanceMap(nextInstance); +} + + + +// **************************************************************************************************** +// Cell::SlaveInstanceSet implementation +// **************************************************************************************************** + +Cell::SlaveInstanceSet::SlaveInstanceSet() +// *************************************** +: Inherit() +{ +} + +unsigned Cell::SlaveInstanceSet::_GetHashValue(Instance* slaveInstance) const +// ************************************************************************** +{ + return ( (unsigned int)( (unsigned long)slaveInstance ) ) / 8; +} + +Instance* Cell::SlaveInstanceSet::_GetNextElement(Instance* slaveInstance) const +// ***************************************************************************** +{ + return slaveInstance->_GetNextOfCellSlaveInstanceSet(); +} + +void Cell::SlaveInstanceSet::_SetNextElement(Instance* slaveInstance, Instance* nextSlaveInstance) const +// **************************************************************************************************** +{ + slaveInstance->_SetNextOfCellSlaveInstanceSet(nextSlaveInstance); +} + + + +// **************************************************************************************************** +// Cell::NetMap implementation +// **************************************************************************************************** + +Cell::NetMap::NetMap() +// ******************* +: Inherit() +{ +} + +Name Cell::NetMap::_GetKey(Net* net) const +// *************************************** +{ + return net->GetName(); +} + +unsigned Cell::NetMap::_GetHashValue(Name name) const +// ************************************************** +{ + return ( (unsigned int)( (unsigned long)name._GetSharedName() ) ) / 8; +} + +Net* Cell::NetMap::_GetNextElement(Net* net) const +// *********************************************** +{ + return net->_GetNextOfCellNetMap(); +} + +void Cell::NetMap::_SetNextElement(Net* net, Net* nextNet) const +// ************************************************************* +{ + net->_SetNextOfCellNetMap(nextNet); +} + + +// **************************************************************************************************** +// Cell::PinMap implementation +// **************************************************************************************************** + +Cell::PinMap::PinMap() +// ******************* +: Inherit() +{ +} + +Name Cell::PinMap::_GetKey(Pin* pin) const +// *************************************** +{ + return pin->GetName(); +} + +unsigned Cell::PinMap::_GetHashValue(Name name) const +// ************************************************** +{ + return ( (unsigned int)( (unsigned long)name._GetSharedName() ) ) / 8; +} + +Pin* Cell::PinMap::_GetNextElement(Pin* pin) const +// *********************************************** +{ + return pin->_GetNextOfCellPinMap(); +} + +void Cell::PinMap::_SetNextElement(Pin* pin, Pin* nextPin) const +// ************************************************************* +{ + pin->_SetNextOfCellPinMap(nextPin); +} + + +// **************************************************************************************************** +// Cell::SliceMap implementation +// **************************************************************************************************** + +Cell::SliceMap::SliceMap() +// *********************** +: Inherit() +{ +} + +const Layer* Cell::SliceMap::_GetKey(Slice* slice) const +// ***************************************************** +{ + return slice->GetLayer(); +} + +unsigned Cell::SliceMap::_GetHashValue(const Layer* layer) const +// ************************************************************* +{ + return ( (unsigned int)( (unsigned long)layer ) ) / 8; +} + +Slice* Cell::SliceMap::_GetNextElement(Slice* slice) const +// ******************************************************* +{ + return slice->_GetNextOfCellSliceMap(); +} + +void Cell::SliceMap::_SetNextElement(Slice* slice, Slice* nextSlice) const +// *********************************************************************** +{ + slice->_SetNextOfCellSliceMap(nextSlice); +}; + + + +// **************************************************************************************************** +// Cell::MarkerSet implementation +// **************************************************************************************************** + +Cell::MarkerSet::MarkerSet() +// ************************* +: Inherit() +{ +} + +unsigned Cell::MarkerSet::_GetHashValue(Marker* marker) const +// ********************************************************** +{ + return ( (unsigned int)( (unsigned long)marker ) ) / 8; +} + +Marker* Cell::MarkerSet::_GetNextElement(Marker* marker) const +// *********************************************************** +{ + return marker->_GetNextOfCellMarkerSet(); +} + +void Cell::MarkerSet::_SetNextElement(Marker* marker, Marker* nextMarker) const +// **************************************************************************** +{ + marker->_SetNextOfCellMarkerSet(nextMarker); +} + + + +//// **************************************************************************************************** +//// Cell::ViewSet implementation +//// **************************************************************************************************** +// +//Cell::ViewSet::ViewSet() +//// ********************* +//: Inherit() +//{ +//} +// +//unsigned Cell::ViewSet::_GetHashValue(View* view) const +//// **************************************************** +//{ +// return ( (unsigned int)( (unsigned long)view ) ) / 8; +//} +// +//View* Cell::ViewSet::_GetNextElement(View* view) const +//// *************************************************** +//{ +// return view->_GetNextOfCellViewSet(); +//} +// +//void Cell::ViewSet::_SetNextElement(View* view, View* nextView) const +//// ****************************************************************** +//{ +// view->_SetNextOfCellViewSet(nextView); +//} +// +// + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Cell.h b/hurricane/src/hurricane/Cell.h new file mode 100644 index 00000000..cfd44d25 --- /dev/null +++ b/hurricane/src/hurricane/Cell.h @@ -0,0 +1,322 @@ +// **************************************************************************************************** +// File: Cell.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_CELL +#define HURRICANE_CELL + +#include "Pathes.h" +#include "Entity.h" +#include "Cells.h" +#include "Instance.h" +#include "DeepNet.h" +#include "Pin.h" +#include "Pins.h" +#include "Slices.h" +#include "Rubbers.h" +#include "Markers.h" +#include "Marker.h" +#include "Reference.h" +#include "Components.h" +#include "Occurrences.h" +#include "Transformation.h" +#include "Layer.h" +#include "QuadTree.h" +#include "IntrusiveMap.h" +#include "IntrusiveSet.h" + + +namespace Hurricane { + +class Library; +class BasicLayer; + + +typedef multimap SlaveEntityMap; + + + +// **************************************************************************************************** +// Cell declaration +// **************************************************************************************************** + +class Cell : public Entity { +// *********************** + +# if !defined(__DOXYGEN_PROCESSOR__) + +// Types +// ***** + + public: typedef Entity Inherit; + + class InstanceMap : public IntrusiveMap { + // **************************************************** + + public: typedef IntrusiveMap Inherit; + + public: InstanceMap(); + + public: virtual Name _GetKey(Instance* instance) const; + public: virtual unsigned _GetHashValue(Name name) const; + public: virtual Instance* _GetNextElement(Instance* instance) const; + public: virtual void _SetNextElement(Instance* instance, Instance* nextInstance) const; + + }; + + public: class SlaveInstanceSet : public IntrusiveSet { + // *********************************************************** + + public: typedef IntrusiveSet Inherit; + + public: SlaveInstanceSet(); + + public: virtual unsigned _GetHashValue(Instance* slaveInstance) const; + public: virtual Instance* _GetNextElement(Instance* slaveInstance) const; + public: virtual void _SetNextElement(Instance* slaveInstance, Instance* nextSlaveInstance) const; + + }; + + public: class NetMap : public IntrusiveMap { + // ************************************************** + + public: typedef IntrusiveMap Inherit; + + public: NetMap(); + + public: virtual Name _GetKey(Net* net) const; + public: virtual unsigned _GetHashValue(Name name) const; + public: virtual Net* _GetNextElement(Net* net) const; + public: virtual void _SetNextElement(Net* net, Net* nextNet) const; + + }; + + class PinMap : public IntrusiveMap { + // ******************************************* + + public: typedef IntrusiveMap Inherit; + + public: PinMap(); + + public: virtual Name _GetKey(Pin* pin) const; + public: virtual unsigned _GetHashValue(Name name) const; + public: virtual Pin* _GetNextElement(Pin* pin) const; + public: virtual void _SetNextElement(Pin* pin, Pin* nextPin) const; + + }; + + public: class SliceMap : public IntrusiveMap { + // ************************************************************** + + public: typedef IntrusiveMap Inherit; + + public: SliceMap(); + + public: virtual const Layer* _GetKey(Slice* slice) const; + public: virtual unsigned _GetHashValue(const Layer* layer) const; + public: virtual Slice* _GetNextElement(Slice* slice) const; + public: virtual void _SetNextElement(Slice* slice, Slice* nextSlice) const; + + }; + + public: class MarkerSet : public IntrusiveSet { + // ************************************************** + + public: typedef IntrusiveSet Inherit; + + public: MarkerSet(); + + public: virtual unsigned _GetHashValue(Marker* marker) const; + public: virtual Marker* _GetNextElement(Marker* marker) const; + public: virtual void _SetNextElement(Marker* marker, Marker* nextMarker) const; + + }; + + //public: class ViewSet : public IntrusiveSet { + //// ********************************************** + + // public: typedef IntrusiveSet Inherit; + // + // public: ViewSet(); + + // public: virtual unsigned _GetHashValue(View* view) const; + // public: virtual View* _GetNextElement(View* view) const; + // public: virtual void _SetNextElement(View* view, View* nextView) const; + + //}; + +// Attributes +// ********** + + private: Library* _library; + private: Name _name; + private: InstanceMap _instanceMap; + private: QuadTree _quadTree; + private: SlaveInstanceSet _slaveInstanceSet; + private: NetMap _netMap; + private: PinMap _pinMap; + private: SliceMap _sliceMap; + private: MarkerSet _markerSet; + //private: ViewSet _viewSet; + private: Box _abutmentBox; + private: Box _boundingBox; + private: bool _isTerminal; + private: bool _isFlattenLeaf; + private: bool _isPad; + private: Cell* _nextOfLibraryCellMap; + private: Cell* _nextOfSymbolCellSet; + private: multimap _slaveEntityMap; + +// Constructors +// ************ + + protected: Cell(Library* library, const Name& name); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("Cell");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: InstanceMap& _GetInstanceMap() {return _instanceMap;}; + public: QuadTree* _GetQuadTree() {return &_quadTree;}; + public: SlaveInstanceSet& _GetSlaveInstanceSet() {return _slaveInstanceSet;}; + public: NetMap& _GetNetMap() {return _netMap;}; + public: PinMap& _GetPinMap() {return _pinMap;}; + public: SliceMap& _GetSliceMap() {return _sliceMap;}; + public: MarkerSet& _GetMarkerSet() {return _markerSet;}; + //public: ViewSet& _GetViewSet() {return _viewSet;}; + public: Cell* _GetNextOfLibraryCellMap() const {return _nextOfLibraryCellMap;}; + public: Cell* _GetNextOfSymbolCellSet() const {return _nextOfSymbolCellSet;}; + + public: void _SetNextOfLibraryCellMap(Cell* cell) {_nextOfLibraryCellMap = cell;}; + public: void _SetNextOfSymbolCellSet(Cell* cell) {_nextOfSymbolCellSet = cell;}; + + public: void _Fit(const Box& box); + public: void _Unfit(const Box& box); + + public: void _AddSlaveEntity(Entity* entity, Entity* slaveEntity); + public: void _RemoveSlaveEntity(Entity* entity, Entity* slaveEntity); + public: void _GetSlaveEntities(SlaveEntityMap::iterator& begin, SlaveEntityMap::iterator& end); + public: void _GetSlaveEntities(Entity* entity, SlaveEntityMap::iterator& begin, SlaveEntityMap::iterator& end); + + //public: bool _IsDrawable(View* view) const; + //public: bool _ContentIsDrawable(View* view) const; + //public: void _DrawPhantoms(View* view, const Box& updateArea, const Transformation& transformation); + //public: void _DrawBoundaries(View* view, const Box& updateArea, const Transformation& transformation); + //public: void _DrawContent(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation); + //public: void _DrawRubbers(View* view, const Box& updateArea, const Transformation& transformation); + //public: void _DrawMarkers(View* view, const Box& updateArea, const Transformation& transformation); + //public: void _DrawDisplaySlots(View* view, const Box& area, const Box& updateArea, const Transformation& transformation); + +# endif + +// Constructors +// ************ + + public: static Cell* Create(Library* library, const Name& name); + +// Accessors +// ********* + + public: virtual Cell* GetCell() const {return (Cell*)this;}; + public: virtual Box GetBoundingBox() const; + public: Library* GetLibrary() const {return _library;}; + public: const Name& GetName() const {return _name;}; + public: Instance* GetInstance(const Name& name) const {return _instanceMap.GetElement(name);}; + public: Instances GetInstances() const {return _instanceMap.GetElements();}; + public: Instances GetPlacedInstances() const; + public: Instances GetFixedInstances() const; + public: Instances GetUnplacedInstances() const; + public: Instances GetNotUnplacedInstances() const; + public: Instances GetInstancesUnder(const Box& area) const; + public: Instances GetPlacedInstancesUnder(const Box& area) const; + public: Instances GetFixedInstancesUnder(const Box& area) const; + public: Instances GetUnplacedInstancesUnder(const Box& area) const; + public: Instances GetNotUnplacedInstancesUnder(const Box& area) const; + public: Instances GetSlaveInstances() const; // {return _slaveInstanceSet.GetElements();}; NOON!! + public: Instances GetTerminalInstances() const; + public: Instances GetTerminalInstancesUnder(const Box& area) const; + public: Instances GetNonTerminalInstances() const; + public: Instances GetNonTerminalInstancesUnder(const Box& area) const; + public: Instances GetLeafInstances() const; + public: Instances GetLeafInstancesUnder(const Box& area) const; + public: Instances GetNonLeafInstances() const; + public: Instances GetNonLeafInstancesUnder(const Box& area) const; + public: Net* GetNet(const Name& name) const {return _netMap.GetElement(name);}; + public: Nets GetNets() const {return _netMap.GetElements();}; + public: Nets GetGlobalNets() const; + public: Nets GetExternalNets() const; + public: Nets GetInternalNets() const; + public: Nets GetClockNets() const; + public: Nets GetSupplyNets() const; + public: Nets GetPowerNets() const; + public: Nets GetGroundNets() const; + public: Pin* GetPin(const Name& name) const {return _pinMap.GetElement(name);}; + public: Pins GetPins() const {return _pinMap.GetElements();}; + public: Slice* GetSlice(const Layer* layer) const {return _sliceMap.GetElement(layer);}; + public: Slices GetSlices(const Layer::Mask& mask = ~0) const; +// public: Views GetViews() const {return _viewSet.GetElements();}; +// public: MainViews GetMainViews() const; +// public: MainViews GetImpactedMainViews() const; + public: Rubbers GetRubbers() const; + public: Rubbers GetRubbersUnder(const Box& area) const; + public: Markers GetMarkers() const {return _markerSet.GetElements();}; + public: Markers GetMarkersUnder(const Box& area) const; + public: References GetReferences() const; + public: Components GetComponents(const Layer::Mask& mask = ~0) const; + public: Components GetComponentsUnder(const Box& area, const Layer::Mask& mask = ~0) const; + public: Occurrences GetOccurrences(unsigned searchDepth = (unsigned)-1) const; + public: Occurrences GetOccurrencesUnder(const Box& area, unsigned searchDepth = (unsigned)-1) const; + public: Occurrences GetTerminalInstanceOccurrences() const; + public: Occurrences GetTerminalInstanceOccurrencesUnder(const Box& area) const; + public: Occurrences GetLeafInstanceOccurrences() const; + public: Occurrences GetLeafInstanceOccurrencesUnder(const Box& area) const; + public: Occurrences GetComponentOccurrences(const Layer::Mask& mask = ~0) const; + public: Occurrences GetComponentOccurrencesUnder(const Box& area, const Layer::Mask& mask = ~0) const; + public: Occurrences GetHyperNetRootNetOccurrences() const; + public: Cells GetSubCells() const; + public: Pathes GetRecursiveSlavePathes() const; + public: const Box& GetAbutmentBox() const {return _abutmentBox;}; + +// Predicates +// ********** + + public: bool IsCalledBy(Cell* cell) const; + public: bool IsTerminal() const {return _isTerminal;}; + public: bool IsFlattenLeaf() const {return _isFlattenLeaf;}; + public: bool IsLeaf() const; + public: bool IsPad() const {return _isPad;}; + +// Updators +// ******** + + public: void SetName(const Name& name); + public: void SetAbutmentBox(const Box& abutmentBox); + public: void SetTerminal(bool isTerminal) {_isTerminal = isTerminal;}; + public: void SetFlattenLeaf(bool isFlattenLeaf) {_isFlattenLeaf = isFlattenLeaf;}; + public: void SetPad(bool isPad) {_isPad = isPad;}; + public: void FlattenNets(bool buildRings=true); + public: void Materialize(); + public: void Unmaterialize(); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Cell) + +#endif // HURRICANE_CELL + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/CellCollections.cpp b/hurricane/src/hurricane/CellCollections.cpp new file mode 100644 index 00000000..8cd812a4 --- /dev/null +++ b/hurricane/src/hurricane/CellCollections.cpp @@ -0,0 +1,4309 @@ +// **************************************************************************************************** +// File: Cell.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Slice.h" +#include "Cell.h" +//#include "MainView.h" +#include "HyperNet.h" + +namespace Hurricane { + +// **************************************************************************************************** +// Cell_Slices implementation +// **************************************************************************************************** + +class Cell_Slices : public Collection { +// ****************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ****************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Cell* _cell; + private: Layer::Mask _mask; + private: SliceLocator _sliceLocator; + + public: Locator(); + public: Locator(const Cell* cell, const Layer::Mask& mask = ~0); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Slice* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + private: Layer::Mask _mask; + +// Constructors +// ************ + + public: Cell_Slices(); + public: Cell_Slices(const Cell* cell, const Layer::Mask& mask = ~0); + public: Cell_Slices(const Cell_Slices& slices); + +// Operators +// ********* + + public: Cell_Slices& operator=(const Cell_Slices& slices); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Cell_Components implementation +// **************************************************************************************************** + +class Cell_Components : public Collection { +// ************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Cell* _cell; + private: Layer::Mask _mask; + private: SliceLocator _sliceLocator; + private: ComponentLocator _componentLocator; + private: Component* _component; + + public: Locator(); + public: Locator(const Cell* cell, const Layer::Mask& mask = ~0); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Component* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + private: Layer::Mask _mask; + +// Constructors +// ************ + + public: Cell_Components(); + public: Cell_Components(const Cell* cell, const Layer::Mask& mask = ~0); + public: Cell_Components(const Cell_Components& components); + +// Operators +// ********* + + public: Cell_Components& operator=(const Cell_Components& components); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Cell_ComponentsUnder implementation +// **************************************************************************************************** + +class Cell_ComponentsUnder : public Collection { +// ******************************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Cell* _cell; + private: Box _area; + private: Layer::Mask _mask; + private: SliceLocator _sliceLocator; + private: ComponentLocator _componentLocator; + private: Component* _component; + + public: Locator(); + public: Locator(const Cell* cell, const Box& area, const Layer::Mask& mask = ~0); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Component* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + private: Box _area; + private: Layer::Mask _mask; + +// Constructors +// ************ + + public: Cell_ComponentsUnder(); + public: Cell_ComponentsUnder(const Cell* cell, const Box& area, const Layer::Mask& mask = ~0); + public: Cell_ComponentsUnder(const Cell_ComponentsUnder& components); + +// Operators +// ********* + + public: Cell_ComponentsUnder& operator=(const Cell_ComponentsUnder& components); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Cell_Occurrences implementation +// **************************************************************************************************** + +class Cell_Occurrences : public Collection { +// ************************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const Cell* _cell; + private: unsigned _searchDepth; + private: unsigned _state; + private: ComponentLocator _componentLocator; + private: RubberLocator _rubberLocator; + private: MarkerLocator _markerLocator; + private: InstanceLocator _instanceLocator; + private: OccurrenceLocator _occurrenceLocator; + + public: Locator(); + public: Locator(const Cell* cell, unsigned searchDepth); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Occurrence GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + private: unsigned _searchDepth; + +// Constructors +// ************ + + public: Cell_Occurrences(); + public: Cell_Occurrences(const Cell* cell, unsigned searchDepth); + public: Cell_Occurrences(const Cell_Occurrences& occurrences); + +// Operators +// ********* + + public: Cell_Occurrences& operator=(const Cell_Occurrences& occurrences); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Cell_OccurrencesUnder implementation +// **************************************************************************************************** + +class Cell_OccurrencesUnder : public Collection { +// ****************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const Cell* _cell; + private: Box _area; + private: unsigned _searchDepth; + private: unsigned _state; + private: ComponentLocator _componentLocator; + private: RubberLocator _rubberLocator; + private: MarkerLocator _markerLocator; + private: InstanceLocator _instanceLocator; + private: OccurrenceLocator _occurrenceLocator; + + public: Locator(); + public: Locator(const Cell* cell, const Box& area, unsigned searchDepth = (unsigned)-1); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Occurrence GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + private: Box _area; + private: unsigned _searchDepth; + +// Constructors +// ************ + + public: Cell_OccurrencesUnder(); + public: Cell_OccurrencesUnder(const Cell* cell, const Box& area, unsigned searchDepth = (unsigned)-1); + public: Cell_OccurrencesUnder(const Cell_OccurrencesUnder& occurrences); + +// Operators +// ********* + + public: Cell_OccurrencesUnder& operator=(const Cell_OccurrencesUnder& occurrences); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + +// **************************************************************************************************** +// Cell_LeafInstanceOccurrences declaration +// **************************************************************************************************** + +class Cell_LeafInstanceOccurrences : public Collection { +// ***************************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const Cell* _cell; + private: int _state; + private: InstanceLocator _leafInstanceLocator; + private: InstanceLocator _nonLeafInstanceLocator; + private: OccurrenceLocator _occurrenceLocator; + + public: Locator(const Cell* cell = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Occurrence GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + +// Constructors +// ************ + + public: Cell_LeafInstanceOccurrences(const Cell* cell = NULL); + public: Cell_LeafInstanceOccurrences(const Cell_LeafInstanceOccurrences& occurrences); + +// Operators +// ********* + + public: Cell_LeafInstanceOccurrences& operator=(const Cell_LeafInstanceOccurrences& occurrences); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Cell_LeafInstanceOccurrencesUnder declaration +// **************************************************************************************************** + +class Cell_LeafInstanceOccurrencesUnder : public Collection { +// ********************************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const Cell* _cell; + private: Box _area; + private: int _state; + private: InstanceLocator _leafInstanceLocator; + private: InstanceLocator _nonLeafInstanceLocator; + private: OccurrenceLocator _occurrenceLocator; + + public: Locator(); + public: Locator(const Cell* cell, const Box& area); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Occurrence GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + private: Box _area; + +// Constructors +// ************ + + public: Cell_LeafInstanceOccurrencesUnder(); + public: Cell_LeafInstanceOccurrencesUnder(const Cell* cell, const Box& area); + public: Cell_LeafInstanceOccurrencesUnder(const Cell_LeafInstanceOccurrencesUnder& occurrences); + +// Operators +// ********* + + public: Cell_LeafInstanceOccurrencesUnder& operator=(const Cell_LeafInstanceOccurrencesUnder& occurrences); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Cell_TerminalInstanceOccurrences declaration +// **************************************************************************************************** + +class Cell_TerminalInstanceOccurrences : public Collection { +// ***************************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const Cell* _cell; + private: int _state; + private: InstanceLocator _terminalInstanceLocator; + private: InstanceLocator _nonTerminalInstanceLocator; + private: OccurrenceLocator _occurrenceLocator; + + public: Locator(const Cell* cell = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Occurrence GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + +// Constructors +// ************ + + public: Cell_TerminalInstanceOccurrences(const Cell* cell = NULL); + public: Cell_TerminalInstanceOccurrences(const Cell_TerminalInstanceOccurrences& occurrences); + +// Operators +// ********* + + public: Cell_TerminalInstanceOccurrences& operator=(const Cell_TerminalInstanceOccurrences& occurrences); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Cell_TerminalInstanceOccurrencesUnder declaration +// **************************************************************************************************** + +class Cell_TerminalInstanceOccurrencesUnder : public Collection { +// ********************************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const Cell* _cell; + private: Box _area; + private: int _state; + private: InstanceLocator _terminalInstanceLocator; + private: InstanceLocator _nonTerminalInstanceLocator; + private: OccurrenceLocator _occurrenceLocator; + + public: Locator(); + public: Locator(const Cell* cell, const Box& area); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Occurrence GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + private: Box _area; + +// Constructors +// ************ + + public: Cell_TerminalInstanceOccurrencesUnder(); + public: Cell_TerminalInstanceOccurrencesUnder(const Cell* cell, const Box& area); + public: Cell_TerminalInstanceOccurrencesUnder(const Cell_TerminalInstanceOccurrencesUnder& occurrences); + +// Operators +// ********* + + public: Cell_TerminalInstanceOccurrencesUnder& operator=(const Cell_TerminalInstanceOccurrencesUnder& occurrences); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Cell_ComponentOccurrences implementation +// **************************************************************************************************** + +class Cell_ComponentOccurrences : public Collection { +// ********************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const Cell* _cell; + private: Layer::Mask _mask; + private: int _state; + private: ComponentLocator _componentLocator; + private: InstanceLocator _instanceLocator; + private: OccurrenceLocator _occurrenceLocator; + + public: Locator(); + public: Locator(const Cell* cell, const Layer::Mask& mask = ~0); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Occurrence GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + private: Layer::Mask _mask; + +// Constructors +// ************ + + public: Cell_ComponentOccurrences(); + public: Cell_ComponentOccurrences(const Cell* cell, const Layer::Mask& mask = ~0); + public: Cell_ComponentOccurrences(const Cell_ComponentOccurrences& occurrences); + +// Operators +// ********* + + public: Cell_ComponentOccurrences& operator=(const Cell_ComponentOccurrences& occurrences); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Cell_ComponentOccurrencesUnder implementation +// **************************************************************************************************** + +class Cell_ComponentOccurrencesUnder : public Collection { +// *************************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const Cell* _cell; + private: Box _area; + private: Layer::Mask _mask; + private: int _state; + private: ComponentLocator _componentLocator; + private: InstanceLocator _instanceLocator; + private: OccurrenceLocator _occurrenceLocator; + + public: Locator(); + public: Locator(const Cell* cell, const Box& area, const Layer::Mask& mask = ~0); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Occurrence GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + private: Box _area; + private: Layer::Mask _mask; + +// Constructors +// ************ + + public: Cell_ComponentOccurrencesUnder(); + public: Cell_ComponentOccurrencesUnder(const Cell* cell, const Box& area, const Layer::Mask& mask = ~0); + public: Cell_ComponentOccurrencesUnder(const Cell_ComponentOccurrencesUnder& occurrences); + +// Operators +// ********* + + public: Cell_ComponentOccurrencesUnder& operator=(const Cell_ComponentOccurrencesUnder& occurrences); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + +// **************************************************************************************************** +// Cell_HyperNetRootNetOccurrences implementation +// **************************************************************************************************** + +class Cell_HyperNetRootNetOccurrences : public Collection { +// **************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: Path _path; + private: NetLocator _netLocator; + private: InstanceLocator _instanceLocator; + private: OccurrenceLocator _hyperNetRootNetOccurrenceLocator; + + public: Locator(); + public: Locator(const Cell* cell, const Path path); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Occurrence GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + private: Path _path; + +// Constructors +// ************ + + public: Cell_HyperNetRootNetOccurrences(); + public: Cell_HyperNetRootNetOccurrences(const Cell* cell, const Path path); + public: Cell_HyperNetRootNetOccurrences(const Cell_HyperNetRootNetOccurrences& netOccurrences); + +// Operators +// ********* + + public: Cell_HyperNetRootNetOccurrences& operator=(const Cell_HyperNetRootNetOccurrences& HyperNetRootNetOccurrences); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + +//// **************************************************************************************************** +//// Cell_ImpactedMainViews implementation +//// **************************************************************************************************** +// +//class Cell_ImpactedMainViews : public Collection { +//// ******************************************************** +// +//// Types +//// ***** +// +// public: typedef Collection Inherit; +// +// public: class Locator : public Hurricane::Locator { +// // ********************************************************* +// +// public: typedef Hurricane::Locator Inherit; +// +// private: const Cell* _cell; +// private: set _cellSet; +// private: stack _cellStack; +// private: MainViewLocator _mainViewLocator; +// private: MainView* _mainView; +// +// public: Locator(const Cell* cell = NULL); +// public: Locator(const Locator& locator); +// +// public: Locator& operator=(const Locator& locator); +// +// public: virtual MainView* GetElement() const; +// public: virtual Hurricane::Locator* GetClone() const; +// +// public: virtual bool IsValid() const; +// +// public: virtual void Progress(); +// +// public: virtual string _GetString() const; +// +// }; +// +//// Attributes +//// ********** +// +// private: const Cell* _cell; +// +//// Constructors +//// ************ +// +// public: Cell_ImpactedMainViews(const Cell* cell = NULL); +// public: Cell_ImpactedMainViews(const Cell_ImpactedMainViews& impactedMainViews); +// +//// Operators +//// ********* +// +// public: Cell_ImpactedMainViews& operator=(const Cell_ImpactedMainViews& impactedMainViews); +// +//// Accessors +//// ********* +// +// public: virtual Collection* GetClone() const; +// public: virtual Hurricane::Locator* GetLocator() const; +// +//// Others +//// ****** +// +// public: virtual string _GetString() const; +// +//}; +// +// **************************************************************************************************** +// Cell_SubCells declaration +// **************************************************************************************************** + +class Cell_SubCells : public Collection { +// ********************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ******************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: set _cellSet; + private: InstanceLocator _instanceLocator; + + public: Locator(); + public: Locator(InstanceLocator instanceLocator); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Cell* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + +// Constructors +// ************ + + public: Cell_SubCells(); + public: Cell_SubCells(const Cell* cell); + public: Cell_SubCells(const Cell_SubCells& subCells); + +// Operators +// ********* + + public: Cell_SubCells& operator=(const Cell_SubCells& subCells); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + + +// ------------------------------------------------------------------- +// Class : "Cell_RecursiveSlavePathes". + + class Cell_RecursiveSlavePathes : public Collection { + + // Locator Sub-Class. + public: + class Locator : public Hurricane::Locator { + // Attributes. + protected: + vector _instancesStack; + Path _instancePath; + bool _isInPop; + // Constructors. + public: + Locator ( const Cell* cell ); + Locator ( const Locator &locator ) : Hurricane::Locator() + , _instancesStack(locator._instancesStack) + , _instancePath(locator._instancePath) + , _isInPop(locator._isInPop) + { }; + // Accessors. + public: + virtual Path GetElement () const { return _instancePath; }; + virtual Hurricane::Locator* GetClone () const { return new Locator(*this); }; + virtual bool IsValid () const { return _instancesStack.size(); }; + virtual void Progress (); + // Hurricane Managment. + public: + virtual string _GetString() const; + }; + + // Attributes. + public: + const Cell* _cell; + + // Constructors. + public: + Cell_RecursiveSlavePathes ( const Cell* cell ) + : Collection() + , _cell(cell) + { }; + Cell_RecursiveSlavePathes ( const Cell_RecursiveSlavePathes& pathes ) + : Collection() + , _cell(pathes._cell) + { }; + + // Accessors. + public: + virtual Collection* GetClone () const { return new Cell_RecursiveSlavePathes(*this); }; + virtual Hurricane::Locator* GetLocator () const { return new Locator(_cell); }; + + // Hurricane Managment. + public: + virtual string _GetString() const; + + }; + + + + +// **************************************************************************************************** +// Cell further definition +// **************************************************************************************************** + +Instances Cell::GetInstancesUnder(const Box& area) const +// ***************************************************** +{ + // return _quadTree.GetGosUnder(area).GetSubSet(); + return SubTypeCollection(_quadTree.GetGosUnder(area)); +} + +Instances Cell::GetSlaveInstances() const +// ************************************** +{ + return _slaveInstanceSet.GetElements(); +} + +Instances Cell::GetTerminalInstances() const +// ***************************************** +{ + return GetInstances().GetSubSet(Instance::GetIsTerminalFilter()); +} + +Instances Cell::GetLeafInstances() const +// ************************************* +{ + return GetInstances().GetSubSet(Instance::GetIsLeafFilter()); +} + +Instances Cell::GetPlacedInstances() const +// *************************************** +{ + return GetInstances().GetSubSet(Instance::GetIsPlacedFilter()); +} + +Instances Cell::GetFixedInstances() const +// ************************************** +{ + return GetInstances().GetSubSet(Instance::GetIsFixedFilter()); +} + +Instances Cell::GetUnplacedInstances() const +// ************************************** +{ + return GetInstances().GetSubSet(Instance::GetIsUnplacedFilter()); +} + +Instances Cell::GetNotUnplacedInstances() const +// ************************************** +{ + return GetInstances().GetSubSet(Instance::GetIsNotUnplacedFilter()); +} + +Instances Cell::GetPlacedInstancesUnder(const Box& area) const +// *********************************************************** +{ + return GetInstancesUnder(area).GetSubSet(Instance::GetIsPlacedFilter()); +} + +Instances Cell::GetFixedInstancesUnder(const Box& area) const +// ********************************************************** +{ + return GetInstancesUnder(area).GetSubSet(Instance::GetIsFixedFilter()); +} + +Instances Cell::GetUnplacedInstancesUnder(const Box& area) const +// ************************************************************* +{ + return GetInstancesUnder(area).GetSubSet(Instance::GetIsUnplacedFilter()); +} + +Instances Cell::GetNotUnplacedInstancesUnder(const Box& area) const +// **************************************************************** +{ + return GetInstancesUnder(area).GetSubSet(Instance::GetIsNotUnplacedFilter()); +} + +Instances Cell::GetTerminalInstancesUnder(const Box& area) const +// ************************************************************* +{ + return GetInstancesUnder(area).GetSubSet(Instance::GetIsTerminalFilter()); +} + +Instances Cell::GetNonTerminalInstances() const +// ******************************************** +{ + return GetInstances().GetSubSet(!Instance::GetIsTerminalFilter()); +} + +Instances Cell::GetNonTerminalInstancesUnder(const Box& area) const +// **************************************************************** +{ + return GetInstancesUnder(area).GetSubSet(!Instance::GetIsTerminalFilter()); +} + +Instances Cell::GetLeafInstancesUnder(const Box& area) const +// ********************************************************* +{ + return GetInstancesUnder(area).GetSubSet(Instance::GetIsLeafFilter()); +} + +Instances Cell::GetNonLeafInstances() const +// **************************************** +{ + return GetInstances().GetSubSet(!Instance::GetIsLeafFilter()); +} + +Instances Cell::GetNonLeafInstancesUnder(const Box& area) const +// ************************************************************ +{ + return GetInstancesUnder(area).GetSubSet(!Instance::GetIsLeafFilter()); +} + +Nets Cell::GetGlobalNets() const +// ***************************** +{ + return GetNets().GetSubSet(Net::GetIsGlobalFilter()); +} + +Nets Cell::GetExternalNets() const +// ******************************* +{ + return GetNets().GetSubSet(Net::GetIsExternalFilter()); +} + +Nets Cell::GetInternalNets() const +// ******************************* +{ + return GetNets().GetSubSet(Net::GetIsInternalFilter()); +} + +Nets Cell::GetClockNets() const +// **************************** +{ + return GetNets().GetSubSet(Net::GetIsClockFilter()); +} + +Nets Cell::GetSupplyNets() const +// ***************************** +{ + return GetNets().GetSubSet(Net::GetIsSupplyFilter()); +} + +Nets Cell::GetPowerNets() const +// ***************************** +{ + return GetNets().GetSubSet(Net::GetIsPowerFilter()); +} + +Nets Cell::GetGroundNets() const +// ***************************** +{ + return GetNets().GetSubSet(Net::GetIsGroundFilter()); +} + +Slices Cell::GetSlices(const Layer::Mask& mask) const +// ************************************************** +{ + return Cell_Slices(this, mask); +} + +//MainViews Cell::GetMainViews() const +//// ********************************* +//{ +// // return GetViews().GetSubSet(); +// return SubTypeCollection(GetViews()); +//} +// +//MainViews Cell::GetImpactedMainViews() const +//// ***************************************** +//{ +// return Cell_ImpactedMainViews(this); +//} +// +Rubbers Cell::GetRubbers() const +// ***************************** +{ + // return _quadTree.GetGos().GetSubSet(); + return SubTypeCollection(_quadTree.GetGos()); +} + +Rubbers Cell::GetRubbersUnder(const Box& area) const +// ************************************************* +{ + // return (area.IsEmpty()) ? Rubbers() : _quadTree.GetGosUnder(area).GetSubSet(); + return SubTypeCollection(_quadTree.GetGosUnder(area)); +} + +Markers Cell::GetMarkersUnder(const Box& area) const +// ************************************************* +{ + // return (area.IsEmpty()) ? Markers() : _quadTree.GetGosUnder(area).GetSubSet(); + return SubTypeCollection(_quadTree.GetGosUnder(area)); +} + +References Cell::GetReferences() const +// ********************************** +{ + return SubTypeCollection(GetMarkers()); +} + +Cells Cell::GetSubCells() const +// **************************** +{ + return Cell_SubCells(this); +} + +Components Cell::GetComponents(const Layer::Mask& mask) const +// ********************************************************** +{ + return Cell_Components(this, mask); +} + +Components Cell::GetComponentsUnder(const Box& area, const Layer::Mask& mask) const +// ******************************************************************************** +{ + return Cell_ComponentsUnder(this, area, mask); +} + +Occurrences Cell::GetOccurrences(unsigned searchDepth) const +// ******************************************************* +{ + return Cell_Occurrences(this, searchDepth); +} + +Occurrences Cell::GetOccurrencesUnder(const Box& area, unsigned searchDepth) const +// ***************************************************************************** +{ + return Cell_OccurrencesUnder(this, area, searchDepth); +} + +Occurrences Cell::GetTerminalInstanceOccurrences() const +// *************************************************** +{ + return Cell_TerminalInstanceOccurrences(this); +} + +Occurrences Cell::GetTerminalInstanceOccurrencesUnder(const Box& area) const +// *********************************************************************** +{ + return Cell_TerminalInstanceOccurrencesUnder(this, area); +} + +Occurrences Cell::GetLeafInstanceOccurrences() const +// *********************************************** +{ + return Cell_LeafInstanceOccurrences(this); +} + +Occurrences Cell::GetLeafInstanceOccurrencesUnder(const Box& area) const +// ******************************************************************* +{ + return Cell_LeafInstanceOccurrencesUnder(this, area); +} + +Occurrences Cell::GetComponentOccurrences(const Layer::Mask& mask) const +// ******************************************************************* +{ + return Cell_ComponentOccurrences(this, mask); +} + +Occurrences Cell::GetComponentOccurrencesUnder(const Box& area, const Layer::Mask& mask) const +// ***************************************************************************************** +{ + return Cell_ComponentOccurrencesUnder(this, area, mask); +} + +Pathes Cell::GetRecursiveSlavePathes() const +// ***************************************** +{ + return Cell_RecursiveSlavePathes(this); +} + +Occurrences Cell::GetHyperNetRootNetOccurrences() const +// ********************************* +{ + return Cell_HyperNetRootNetOccurrences(this,Path()); +} + +// **************************************************************************************************** +// Cell_Slices implementation +// **************************************************************************************************** + +Cell_Slices::Cell_Slices() +// *********************** +: Inherit(), + _cell(NULL), + _mask(0) +{ +} + +Cell_Slices::Cell_Slices(const Cell* cell, const Layer::Mask& mask) +// **************************************************************** +: Inherit(), + _cell(cell), + _mask(mask) +{ +} + +Cell_Slices::Cell_Slices(const Cell_Slices& slices) +// ************************************************ +: Inherit(), + _cell(slices._cell), + _mask(slices._mask) +{ +} + +Cell_Slices& Cell_Slices::operator=(const Cell_Slices& slices) +// *********************************************************** +{ + _cell = slices._cell; + _mask = slices._mask; + return *this; +} + +Collection* Cell_Slices::GetClone() const +// ********************************************** +{ + return new Cell_Slices(*this); +} + +Locator* Cell_Slices::GetLocator() const +// ********************************************* +{ + return new Locator(_cell, _mask); +} + +string Cell_Slices::_GetString() const +// *********************************** +{ + string s = "<" + _TName("Cell::Slices"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_mask); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_Slices::Locator implementation +// **************************************************************************************************** + +Cell_Slices::Locator::Locator() +// **************************** +: Inherit(), + _cell(NULL), + _mask(0), + _sliceLocator() +{ +} + +Cell_Slices::Locator::Locator(const Cell* cell, const Layer::Mask& mask) +// ********************************************************************* +: Inherit(), + _cell(cell), + _mask(mask), + _sliceLocator() +{ + if (_cell && (_mask != 0)) { + _sliceLocator = ((Cell*)_cell)->_GetSliceMap().GetElements().GetLocator(); + while (_sliceLocator.IsValid() && !(_sliceLocator.GetElement()->GetLayer()->GetMask() & _mask)) + _sliceLocator.Progress(); + } +} + +Cell_Slices::Locator::Locator(const Locator& locator) +// ************************************************** +: Inherit(), + _cell(locator._cell), + _mask(locator._mask), + _sliceLocator(locator._sliceLocator) +{ +} + +Cell_Slices::Locator& Cell_Slices::Locator::operator=(const Locator& locator) +// ************************************************************************** +{ + _cell = locator._cell; + _mask = locator._mask; + _sliceLocator = locator._sliceLocator; + return *this; +} + +Slice* Cell_Slices::Locator::GetElement() const +// ******************************************** +{ + return _sliceLocator.GetElement(); +} + +Locator* Cell_Slices::Locator::GetClone() const +// **************************************************** +{ + return new Locator(*this); +} + +bool Cell_Slices::Locator::IsValid() const +// *************************************** +{ + return _sliceLocator.IsValid(); +} + +void Cell_Slices::Locator::Progress() +// ********************************** +{ + if (_sliceLocator.IsValid()) { + do { + _sliceLocator.Progress(); + } + while (_sliceLocator.IsValid() && !(_sliceLocator.GetElement()->GetLayer()->GetMask() & _mask)); + } +} + +string Cell_Slices::Locator::_GetString() const +// ******************************************** +{ + string s = "<" + _TName("Cell::Slices::Locator"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_mask); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_Components implementation +// **************************************************************************************************** + +Cell_Components::Cell_Components() +// ******************************* +: Inherit(), + _cell(NULL), + _mask(0) +{ +} + +Cell_Components::Cell_Components(const Cell* cell, const Layer::Mask& mask) +// ************************************************************************ +: Inherit(), + _cell(cell), + _mask(mask) +{ +} + +Cell_Components::Cell_Components(const Cell_Components& components) +// **************************************************************** +: Inherit(), + _cell(components._cell), + _mask(components._mask) +{ +} + +Cell_Components& Cell_Components::operator=(const Cell_Components& components) +// *************************************************************************** +{ + _cell = components._cell; + _mask = components._mask; + return *this; +} + +Collection* Cell_Components::GetClone() const +// ****************************************************** +{ + return new Cell_Components(*this); +} + +Locator* Cell_Components::GetLocator() const +// ***************************************************** +{ + return new Locator(_cell, _mask); +} + +string Cell_Components::_GetString() const +// *************************************** +{ + string s = "<" + _TName("Cell::Components"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_mask); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_Components::Locator implementation +// **************************************************************************************************** + +Cell_Components::Locator::Locator() +// ******************************** +: Inherit(), + _cell(NULL), + _mask(0), + _sliceLocator(), + _componentLocator(), + _component(NULL) +{ +} + +Cell_Components::Locator::Locator(const Cell* cell, const Layer::Mask& mask) +// ************************************************************************* +: Inherit(), + _cell(cell), + _mask(mask), + _sliceLocator(), + _componentLocator(), + _component(NULL) +{ + if (_cell && (_mask != 0)) { + _sliceLocator = _cell->GetSlices(_mask).GetLocator(); + while (!_component && _sliceLocator.IsValid()) { + Slice* slice = _sliceLocator.GetElement(); + if (slice) { + _componentLocator = slice->GetComponents().GetLocator(); + while (!_component && _componentLocator.IsValid()) { + _component = _componentLocator.GetElement(); + if (!_component) _componentLocator.Progress(); + } + } + if (!_component) _sliceLocator.Progress(); + } + } +} + +Cell_Components::Locator::Locator(const Locator& locator) +// ****************************************************** +: Inherit(), + _cell(locator._cell), + _mask(locator._mask), + _sliceLocator(locator._sliceLocator), + _componentLocator(locator._componentLocator), + _component(locator._component) +{ +} + +Cell_Components::Locator& Cell_Components::Locator::operator=(const Locator& locator) +// ********************************************************************************** +{ + _cell = locator._cell; + _mask = locator._mask; + _sliceLocator = locator._sliceLocator; + _componentLocator = locator._componentLocator; + _component = locator._component; + return *this; +} + +Component* Cell_Components::Locator::GetElement() const +// **************************************************** +{ + return _component; +} + +Locator* Cell_Components::Locator::GetClone() const +// ************************************************************ +{ + return new Locator(*this); +} + +bool Cell_Components::Locator::IsValid() const +// ******************************************* +{ + return (_component != NULL); +} + +void Cell_Components::Locator::Progress() +// ************************************** +{ + if (_component) { + _component = NULL; + do { + _componentLocator.Progress(); + _component = _componentLocator.GetElement(); + } + while (!_component && _componentLocator.IsValid()); + if (!_component) { + do { + _sliceLocator.Progress(); + Slice* slice = _sliceLocator.GetElement(); + if (slice) { + _componentLocator = slice->GetComponents().GetLocator(); + while (!_component && _componentLocator.IsValid()) { + _component = _componentLocator.GetElement(); + if (!_component) _componentLocator.Progress(); + } + } + } + while (!_component && _sliceLocator.IsValid()); + } + } +} + +string Cell_Components::Locator::_GetString() const +// ************************************************ +{ + string s = "<" + _TName("Cell::Components::Locator"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_mask); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_ComponentsUnder implementation +// **************************************************************************************************** + +Cell_ComponentsUnder::Cell_ComponentsUnder() +// ***************************************** +: Inherit(), + _cell(NULL), + _area(), + _mask(0) +{ +} + +Cell_ComponentsUnder::Cell_ComponentsUnder(const Cell* cell, const Box& area, const Layer::Mask& mask) +// *************************************************************************************************** +: Inherit(), + _cell(cell), + _area(area), + _mask(mask) +{ +} + +Cell_ComponentsUnder::Cell_ComponentsUnder(const Cell_ComponentsUnder& components) +// ******************************************************************************* +: Inherit(), + _cell(components._cell), + _area(components._area), + _mask(components._mask) +{ +} + +Cell_ComponentsUnder& Cell_ComponentsUnder::operator=(const Cell_ComponentsUnder& components) +// ****************************************************************************************** +{ + _cell = components._cell; + _area = components._area; + _mask = components._mask; + return *this; +} + +Collection* Cell_ComponentsUnder::GetClone() const +// *********************************************************** +{ + return new Cell_ComponentsUnder(*this); +} + +Locator* Cell_ComponentsUnder::GetLocator() const +// ********************************************************** +{ + return new Locator(_cell, _area, _mask); +} + +string Cell_ComponentsUnder::_GetString() const +// ******************************************** +{ + string s = "<" + _TName("Cell::ComponentsUnder"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_area); + s += " " + GetString(_mask); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_ComponentsUnder::Locator implementation +// **************************************************************************************************** + +Cell_ComponentsUnder::Locator::Locator() +// ************************************* +: Inherit(), + _cell(NULL), + _area(), + _mask(0), + _sliceLocator(), + _componentLocator(), + _component(NULL) +{ +} + +Cell_ComponentsUnder::Locator::Locator(const Cell* cell, const Box& area, const Layer::Mask& mask) +// *********************************************************************************************** +: Inherit(), + _cell(cell), + _area(area), + _mask(mask), + _sliceLocator(), + _componentLocator(), + _component(NULL) +{ + if (_cell && !_area.IsEmpty()) { + _sliceLocator = _cell->GetSlices(_mask).GetLocator(); + while (!_component && _sliceLocator.IsValid()) { + Slice* slice = _sliceLocator.GetElement(); + if (slice) { + _componentLocator = slice->GetComponentsUnder(_area).GetLocator(); + if (_componentLocator.IsValid()) + _component = _componentLocator.GetElement(); + } + if (!_component) _sliceLocator.Progress(); + } + } +} + +Cell_ComponentsUnder::Locator::Locator(const Locator& locator) +// *********************************************************** +: Inherit(), + _cell(locator._cell), + _area(locator._area), + _mask(locator._mask), + _sliceLocator(locator._sliceLocator), + _componentLocator(locator._componentLocator), + _component(locator._component) +{ +} + +Cell_ComponentsUnder::Locator& Cell_ComponentsUnder::Locator::operator=(const Locator& locator) +// ******************************************************************************************** +{ + _cell = locator._cell; + _area = locator._area; + _mask = locator._mask; + _sliceLocator = locator._sliceLocator; + _componentLocator = locator._componentLocator; + _component = locator._component; + return *this; +} + +Component* Cell_ComponentsUnder::Locator::GetElement() const +// ********************************************************* +{ + return _component; +} + +Locator* Cell_ComponentsUnder::Locator::GetClone() const +// ***************************************************************** +{ + return new Locator(*this); +} + +bool Cell_ComponentsUnder::Locator::IsValid() const +// ************************************************ +{ + return (_component != NULL); +} + +void Cell_ComponentsUnder::Locator::Progress() +// ******************************************* +{ + if (_component) { + _component = NULL; + _componentLocator.Progress(); + if (_componentLocator.IsValid()) + _component = _componentLocator.GetElement(); + else { + do { + _sliceLocator.Progress(); + Slice* slice = _sliceLocator.GetElement(); + if (slice) { + _componentLocator = slice->GetComponentsUnder(_area).GetLocator(); + if (_componentLocator.IsValid()) + _component = _componentLocator.GetElement(); + } + } while (!_component && _sliceLocator.IsValid()); + } + } +} + +string Cell_ComponentsUnder::Locator::_GetString() const +// ***************************************************** +{ + string s = "<" + _TName("Cell::ComponentsUnder::Locator"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_area); + s += " " + GetString(_mask); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_Occurrences implementation +// **************************************************************************************************** + +Cell_Occurrences::Cell_Occurrences() +// ******************************* +: Inherit(), + _cell(NULL), + _searchDepth(0) +{ +} + +Cell_Occurrences::Cell_Occurrences(const Cell* cell, unsigned searchDepth) +// ********************************************************************* +: Inherit(), + _cell(cell), + _searchDepth(searchDepth) +{ +} + +Cell_Occurrences::Cell_Occurrences(const Cell_Occurrences& occurrences) +// **************************************************************** +: Inherit(), + _cell(occurrences._cell), + _searchDepth(occurrences._searchDepth) +{ +} + +Cell_Occurrences& Cell_Occurrences::operator=(const Cell_Occurrences& occurrences) +// *************************************************************************** +{ + _cell = occurrences._cell; + _searchDepth = occurrences._searchDepth; + return *this; +} + +Collection* Cell_Occurrences::GetClone() const +// ***************************************************** +{ + return new Cell_Occurrences(*this); +} + +Locator* Cell_Occurrences::GetLocator() const +// **************************************************** +{ + return new Locator(_cell, _searchDepth); +} + +string Cell_Occurrences::_GetString() const +// *************************************** +{ + string s = "<" + _TName("Cell::Occurrences"); + if (_cell) { + s += " " + GetString(_cell); + if (_searchDepth != ((unsigned)-1)) s += " " + GetString(_searchDepth); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_Occurrences::Locator implementation +// **************************************************************************************************** + +Cell_Occurrences::Locator::Locator() +// ******************************** +: Inherit(), + _cell(NULL), + _searchDepth(0), + _state(0), + _componentLocator(), + _rubberLocator(), + _markerLocator(), + _instanceLocator(), + _occurrenceLocator() +{ +} + +Cell_Occurrences::Locator::Locator(const Cell* cell, unsigned searchDepth) +// ********************************************************************** +: Inherit(), + _cell(cell), + _searchDepth(searchDepth), + _state(0), + _componentLocator(), + _rubberLocator(), + _markerLocator(), + _instanceLocator(), + _occurrenceLocator() +{ + if (_cell) { + _componentLocator = _cell->GetComponents().GetLocator(); + if (_componentLocator.IsValid()) + _state = 1; + else { + _rubberLocator = _cell->GetRubbers().GetLocator(); + if (_rubberLocator.IsValid()) + _state = 2; + else { + _markerLocator = _cell->GetMarkers().GetLocator(); + if (_markerLocator.IsValid()) + _state = 3; + else { + _instanceLocator = _cell->GetInstances().GetLocator(); + if (_instanceLocator.IsValid()) + _state = 4; + } + } + } + } +} + +Cell_Occurrences::Locator::Locator(const Locator& locator) +// ****************************************************** +: Inherit(), + _cell(locator._cell), + _searchDepth(locator._searchDepth), + _state(locator._state), + _componentLocator(locator._componentLocator), + _rubberLocator(locator._rubberLocator), + _markerLocator(locator._markerLocator), + _instanceLocator(locator._instanceLocator), + _occurrenceLocator(locator._occurrenceLocator) +{ +} + +Cell_Occurrences::Locator& Cell_Occurrences::Locator::operator=(const Locator& locator) +// ********************************************************************************** +{ + _cell = locator._cell; + _searchDepth = locator._searchDepth; + _state = locator._state; + _componentLocator = locator._componentLocator; + _rubberLocator = locator._rubberLocator; + _markerLocator = locator._markerLocator; + _instanceLocator = locator._instanceLocator; + _occurrenceLocator = locator._occurrenceLocator; + return *this; +} + +Occurrence Cell_Occurrences::Locator::GetElement() const +// *************************************************** +{ + if (_state) { + switch (_state) { + case 1 : return Occurrence(_componentLocator.GetElement()); + case 2 : return Occurrence(_rubberLocator.GetElement()); + case 3 : return Occurrence(_markerLocator.GetElement()); + case 4 : return Occurrence(_instanceLocator.GetElement()); + case 5 : { + Occurrence occurrence = _occurrenceLocator.GetElement(); + Entity* entity = occurrence.GetEntity(); + Path path = Path(_instanceLocator.GetElement(), occurrence.GetPath()); + return Occurrence(entity, path); + } + } + } + return Occurrence(); +} + +Locator* Cell_Occurrences::Locator::GetClone() const +// *********************************************************** +{ + return new Locator(*this); +} + +bool Cell_Occurrences::Locator::IsValid() const +// ******************************************* +{ + return (_state != 0); +} + +void Cell_Occurrences::Locator::Progress() +// ************************************** +{ + if (_state) { + switch (_state) { + case 1 : + _componentLocator.Progress(); + if (!_componentLocator.IsValid()) { + _rubberLocator = _cell->GetRubbers().GetLocator(); + if (_rubberLocator.IsValid()) + _state = 2; + else { + _markerLocator = _cell->GetMarkers().GetLocator(); + if (_markerLocator.IsValid()) + _state = 3; + else { + _instanceLocator = _cell->GetInstances().GetLocator(); + if (_instanceLocator.IsValid()) + _state = 4; + else + _state = 0; + } + } + } + break; + case 2 : + _rubberLocator.Progress(); + if (!_rubberLocator.IsValid()) { + _markerLocator = _cell->GetMarkers().GetLocator(); + if (_markerLocator.IsValid()) + _state = 3; + else { + _instanceLocator = _cell->GetInstances().GetLocator(); + if (_instanceLocator.IsValid()) + _state = 4; + else + _state = 0; + } + } + break; + case 3 : + _markerLocator.Progress(); + if (!_markerLocator.IsValid()) { + _instanceLocator = _cell->GetInstances().GetLocator(); + if (_instanceLocator.IsValid()) + _state = 4; + else + _state = 0; + } + break; + case 4 : + if (!_searchDepth) { + _instanceLocator.Progress(); + if (!_instanceLocator.IsValid()) _state = 0; + } + else { + Instance* instance = _instanceLocator.GetElement(); + if (instance->IsTerminal()) { + _instanceLocator.Progress(); + if (!_instanceLocator.IsValid()) _state = 0; + } + else { + _occurrenceLocator = + instance->GetMasterCell()->GetOccurrences(_searchDepth - 1).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 5; + else { + _instanceLocator.Progress(); + if (!_instanceLocator.IsValid()) _state = 0; + } + } + } + break; + case 5 : + _occurrenceLocator.Progress(); + if (!_occurrenceLocator.IsValid()) { + _instanceLocator.Progress(); + if (_instanceLocator.IsValid()) + _state = 4; + else + _state = 0; + } + break; + } + } +} + +string Cell_Occurrences::Locator::_GetString() const +// ************************************************ +{ + string s = "<" + _TName("Cell::Occurrences::Locator"); + if (_cell) { + s += " " + GetString(_cell); + if (_searchDepth != ((unsigned)-1)) s += " " + GetString(_searchDepth); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_OccurrencesUnder implementation +// **************************************************************************************************** + +Cell_OccurrencesUnder::Cell_OccurrencesUnder() +// ***************************************** +: Inherit(), + _cell(NULL), + _area(), + _searchDepth(0) +{ +} + +Cell_OccurrencesUnder::Cell_OccurrencesUnder(const Cell* cell, const Box& area, unsigned searchDepth) +// ************************************************************************************************ +: Inherit(), + _cell(cell), + _area(area), + _searchDepth(searchDepth) +{ +} + +Cell_OccurrencesUnder::Cell_OccurrencesUnder(const Cell_OccurrencesUnder& occurrences) +// ******************************************************************************* +: Inherit(), + _cell(occurrences._cell), + _area(occurrences._area), + _searchDepth(occurrences._searchDepth) +{ +} + +Cell_OccurrencesUnder& Cell_OccurrencesUnder::operator=(const Cell_OccurrencesUnder& occurrences) +// ****************************************************************************************** +{ + _cell = occurrences._cell; + _area = occurrences._area; + _searchDepth = occurrences._searchDepth; + return *this; +} + +Collection* Cell_OccurrencesUnder::GetClone() const +// ********************************************************** +{ + return new Cell_OccurrencesUnder(*this); +} + +Locator* Cell_OccurrencesUnder::GetLocator() const +// ********************************************************* +{ + return new Locator(_cell, _area, _searchDepth); +} + +string Cell_OccurrencesUnder::_GetString() const +// ******************************************** +{ + string s = "<" + _TName("Cell::OccurrencesUnder"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_area); + if (_searchDepth != ((unsigned)-1)) s += " " + GetString(_searchDepth); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_OccurrencesUnder::Locator implementation +// **************************************************************************************************** + +Cell_OccurrencesUnder::Locator::Locator() +// ************************************* +: Inherit(), + _cell(NULL), + _area(), + _searchDepth(0), + _state(0), + _componentLocator(), + _rubberLocator(), + _markerLocator(), + _instanceLocator(), + _occurrenceLocator() +{ +} + +Cell_OccurrencesUnder::Locator::Locator(const Cell* cell, const Box& area, unsigned searchDepth) +// ******************************************************************************************** +: Inherit(), + _cell(cell), + _area(area), + _searchDepth(searchDepth), + _state(0), + _componentLocator(), + _rubberLocator(), + _markerLocator(), + _instanceLocator(), + _occurrenceLocator() +{ + if (_cell && !_area.IsEmpty()) { + _componentLocator = _cell->GetComponentsUnder(_area).GetLocator(); + if (_componentLocator.IsValid()) + _state = 1; + else { + _rubberLocator = _cell->GetRubbersUnder(_area).GetLocator(); + if (_rubberLocator.IsValid()) + _state = 2; + else { + _markerLocator = _cell->GetMarkersUnder(_area).GetLocator(); + if (_markerLocator.IsValid()) + _state = 3; + else { + _instanceLocator = _cell->GetInstancesUnder(_area).GetLocator(); + if (_instanceLocator.IsValid()) + _state = 4; + } + } + } + } +} + +Cell_OccurrencesUnder::Locator::Locator(const Locator& locator) +// *********************************************************** +: Inherit(), + _cell(locator._cell), + _area(locator._area), + _searchDepth(locator._searchDepth), + _state(locator._state), + _componentLocator(locator._componentLocator), + _rubberLocator(locator._rubberLocator), + _markerLocator(locator._markerLocator), + _instanceLocator(locator._instanceLocator), + _occurrenceLocator(locator._occurrenceLocator) +{ +} + +Cell_OccurrencesUnder::Locator& Cell_OccurrencesUnder::Locator::operator=(const Locator& locator) +// ******************************************************************************************** +{ + _cell = locator._cell; + _area = locator._area; + _searchDepth = locator._searchDepth; + _state = locator._state; + _componentLocator = locator._componentLocator; + _rubberLocator = locator._rubberLocator; + _markerLocator = locator._markerLocator; + _instanceLocator = locator._instanceLocator; + _occurrenceLocator = locator._occurrenceLocator; + return *this; +} + +Occurrence Cell_OccurrencesUnder::Locator::GetElement() const +// ******************************************************** +{ + if (_state) { + switch (_state) { + case 1 : return Occurrence(_componentLocator.GetElement()); + case 2 : return Occurrence(_rubberLocator.GetElement()); + case 3 : return Occurrence(_markerLocator.GetElement()); + case 4 : return Occurrence(_instanceLocator.GetElement()); + case 5 : { + Occurrence occurrence = _occurrenceLocator.GetElement(); + Entity* entity = occurrence.GetEntity(); + Path path = Path(_instanceLocator.GetElement(), occurrence.GetPath()); + return Occurrence(entity, path); + } + } + } + return Occurrence(); +} + +Locator* Cell_OccurrencesUnder::Locator::GetClone() const +// **************************************************************** +{ + return new Locator(*this); +} + +bool Cell_OccurrencesUnder::Locator::IsValid() const +// ************************************************ +{ + return (_state != 0); +} + +void Cell_OccurrencesUnder::Locator::Progress() +// ******************************************* +{ + if (_state) { + switch (_state) { + case 1 : + _componentLocator.Progress(); + if (!_componentLocator.IsValid()) { + _rubberLocator = _cell->GetRubbersUnder(_area).GetLocator(); + if (_rubberLocator.IsValid()) + _state = 2; + else { + _markerLocator = _cell->GetMarkersUnder(_area).GetLocator(); + if (_markerLocator.IsValid()) + _state = 3; + else { + _instanceLocator = _cell->GetInstancesUnder(_area).GetLocator(); + if (_instanceLocator.IsValid()) + _state = 4; + else + _state = 0; + } + } + } + break; + case 2 : + _rubberLocator.Progress(); + if (!_rubberLocator.IsValid()) { + _markerLocator = _cell->GetMarkersUnder(_area).GetLocator(); + if (_markerLocator.IsValid()) + _state = 3; + else { + _instanceLocator = _cell->GetInstancesUnder(_area).GetLocator(); + if (_instanceLocator.IsValid()) + _state = 4; + else + _state = 0; + } + } + break; + case 3 : + _markerLocator.Progress(); + if (!_markerLocator.IsValid()) { + _instanceLocator = _cell->GetInstancesUnder(_area).GetLocator(); + if (_instanceLocator.IsValid()) + _state = 4; + else + _state = 0; + } + break; + case 4 : + if (!_searchDepth) { + _instanceLocator.Progress(); + if (!_instanceLocator.IsValid()) _state = 0; + } + else { + Instance* instance = _instanceLocator.GetElement(); + if (instance->IsTerminal()) { + _instanceLocator.Progress(); + if (!_instanceLocator.IsValid()) _state = 0; + } + else { + Box masterArea = _area; + instance->GetTransformation().GetInvert().ApplyOn(masterArea); + Cell* masterCell = instance->GetMasterCell(); + _occurrenceLocator = + masterCell->GetOccurrencesUnder(masterArea, _searchDepth - 1).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 5; + else { + _instanceLocator.Progress(); + if (!_instanceLocator.IsValid()) _state = 0; + } + } + } + break; + case 5 : + _occurrenceLocator.Progress(); + if (!_occurrenceLocator.IsValid()) { + _instanceLocator.Progress(); + if (_instanceLocator.IsValid()) + _state = 4; + else + _state = 0; + } + break; + } + } +} + +string Cell_OccurrencesUnder::Locator::_GetString() const +// ***************************************************** +{ + string s = "<" + _TName("Cell::OccurrencesUnder::Locator"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_area); + if (_searchDepth != ((unsigned)-1)) s += " " + GetString(_searchDepth); + } + s += ">"; + return s; +} + +// **************************************************************************************************** +// Cell_LeafInstanceOccurrences implementation +// **************************************************************************************************** + +Cell_LeafInstanceOccurrences::Cell_LeafInstanceOccurrences(const Cell* cell) +// ******************************************************************************* +: Inherit(), + _cell(cell) +{ +} + +Cell_LeafInstanceOccurrences::Cell_LeafInstanceOccurrences(const Cell_LeafInstanceOccurrences& occurrences) +// **************************************************************************************************** +: Inherit(), + _cell(occurrences._cell) +{ +} + +Cell_LeafInstanceOccurrences& Cell_LeafInstanceOccurrences::operator=(const Cell_LeafInstanceOccurrences& occurrences) +// **************************************************************************************************** +{ + _cell = occurrences._cell; + return *this; +} + +Collection* Cell_LeafInstanceOccurrences::GetClone() const +// ********************************************************************* +{ + return new Cell_LeafInstanceOccurrences(*this); +} + +Locator* Cell_LeafInstanceOccurrences::GetLocator() const +// ******************************************************************** +{ + return new Locator(_cell); +} + +string Cell_LeafInstanceOccurrences::_GetString() const +// ******************************************************* +{ + string s = "<" + _TName("Cell::LeafInstanceOccurrences"); + if (_cell) s += " " + GetString(_cell); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_LeafInstanceOccurrences::Locator implementation +// **************************************************************************************************** + +Cell_LeafInstanceOccurrences::Locator::Locator(const Cell* cell) +// **************************************************************** +: Inherit(), + _cell(cell), + _state(0), + _leafInstanceLocator(), + _nonLeafInstanceLocator(), + _occurrenceLocator() +{ + if (_cell) { + _leafInstanceLocator = _cell->GetLeafInstances().GetLocator(); + if (_leafInstanceLocator.IsValid()) + _state = 1; + else { + _nonLeafInstanceLocator = _cell->GetNonLeafInstances().GetLocator(); + while (!_state && _nonLeafInstanceLocator.IsValid()) { + Cell* masterCell = _nonLeafInstanceLocator.GetElement()->GetMasterCell(); + _occurrenceLocator = masterCell->GetLeafInstanceOccurrences().GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _nonLeafInstanceLocator.Progress(); + } + } + } +} + +Cell_LeafInstanceOccurrences::Locator::Locator(const Locator& locator) +// ********************************************************************** +: Inherit(), + _cell(locator._cell), + _state(locator._state), + _leafInstanceLocator(locator._leafInstanceLocator), + _nonLeafInstanceLocator(locator._nonLeafInstanceLocator), + _occurrenceLocator(locator._occurrenceLocator) +{ +} + +Cell_LeafInstanceOccurrences::Locator& Cell_LeafInstanceOccurrences::Locator::operator=(const Locator& locator) +// **************************************************************************************************** +{ + _cell = locator._cell; + _state = locator._state; + _leafInstanceLocator = locator._leafInstanceLocator; + _nonLeafInstanceLocator = locator._nonLeafInstanceLocator; + _occurrenceLocator = locator._occurrenceLocator; + return *this; +} + +Occurrence Cell_LeafInstanceOccurrences::Locator::GetElement() const +// ******************************************************************* +{ + if (_state) { + switch (_state) { + case 1 : return Occurrence(_leafInstanceLocator.GetElement()); + case 2 : { + Occurrence occurrence = _occurrenceLocator.GetElement(); + Entity* entity = occurrence.GetEntity(); + Path path = Path(_nonLeafInstanceLocator.GetElement(), occurrence.GetPath()); + return Occurrence(entity, path); + } + } + } + return Occurrence(); +} + +Locator* Cell_LeafInstanceOccurrences::Locator::GetClone() const +// *************************************************************************** +{ + return new Locator(*this); +} + +bool Cell_LeafInstanceOccurrences::Locator::IsValid() const +// *********************************************************** +{ + return (_state != 0); +} + +void Cell_LeafInstanceOccurrences::Locator::Progress() +// ****************************************************** +{ + if (_state) { + switch (_state) { + case 1 : + _leafInstanceLocator.Progress(); + if (!_leafInstanceLocator.IsValid()) { + _state = 0; + _nonLeafInstanceLocator = _cell->GetNonLeafInstances().GetLocator(); + while (!_state && _nonLeafInstanceLocator.IsValid()) { + Cell* masterCell = _nonLeafInstanceLocator.GetElement()->GetMasterCell(); + _occurrenceLocator = masterCell->GetLeafInstanceOccurrences().GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _nonLeafInstanceLocator.Progress(); + } + } + break; + case 2 : + _occurrenceLocator.Progress(); + if (!_occurrenceLocator.IsValid()) { + _state = 0; + if (_nonLeafInstanceLocator.IsValid()) { + _nonLeafInstanceLocator.Progress(); + while (!_state && _nonLeafInstanceLocator.IsValid()) { + Cell* masterCell = _nonLeafInstanceLocator.GetElement()->GetMasterCell(); + _occurrenceLocator = + masterCell->GetLeafInstanceOccurrences().GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _nonLeafInstanceLocator.Progress(); + } + } + } + break; + } + } +} + +string Cell_LeafInstanceOccurrences::Locator::_GetString() const +// **************************************************************** +{ + string s = "<" + _TName("Cell::LeafInstanceOccurrences::Locator"); + if (_cell) s += " " + GetString(_cell); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_LeafInstanceOccurrencesUnder implementation +// **************************************************************************************************** + +Cell_LeafInstanceOccurrencesUnder::Cell_LeafInstanceOccurrencesUnder() +// ************************************************************************* +: Inherit(), + _cell(NULL), + _area() +{ +} + +Cell_LeafInstanceOccurrencesUnder::Cell_LeafInstanceOccurrencesUnder(const Cell* cell, const Box& area) +// **************************************************************************************************** +: Inherit(), + _cell(cell), + _area(area) +{ +} + +Cell_LeafInstanceOccurrencesUnder::Cell_LeafInstanceOccurrencesUnder(const Cell_LeafInstanceOccurrencesUnder& occurrences) +// **************************************************************************************************** +: Inherit(), + _cell(occurrences._cell), + _area(occurrences._area) +{ +} + +Cell_LeafInstanceOccurrencesUnder& Cell_LeafInstanceOccurrencesUnder::operator=(const Cell_LeafInstanceOccurrencesUnder& occurrences) +// **************************************************************************************************** +{ + _cell = occurrences._cell; + _area = occurrences._area; + return *this; +} + +Collection* Cell_LeafInstanceOccurrencesUnder::GetClone() const +// ************************************************************************** +{ + return new Cell_LeafInstanceOccurrencesUnder(*this); +} + +Locator* Cell_LeafInstanceOccurrencesUnder::GetLocator() const +// ************************************************************************* +{ + return new Locator(_cell, _area); +} + +string Cell_LeafInstanceOccurrencesUnder::_GetString() const +// ************************************************************ +{ + string s = "<" + _TName("Cell::LeafInstanceOccurrencesUnder"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_area); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_LeafInstanceOccurrencesUnder::Locator implementation +// **************************************************************************************************** + +Cell_LeafInstanceOccurrencesUnder::Locator::Locator() +// ***************************************************** +: Inherit(), + _cell(NULL), + _area(), + _state(0), + _leafInstanceLocator(), + _nonLeafInstanceLocator(), + _occurrenceLocator() +{ +} + +Cell_LeafInstanceOccurrencesUnder::Locator::Locator(const Cell* cell, const Box& area) +// ************************************************************************************** +: Inherit(), + _cell(cell), + _area(area), + _state(0), + _leafInstanceLocator(), + _nonLeafInstanceLocator(), + _occurrenceLocator() +{ + if (_cell && !_area.IsEmpty()) { + _leafInstanceLocator = _cell->GetLeafInstancesUnder(_area).GetLocator(); + if (_leafInstanceLocator.IsValid()) + _state = 1; + else { + _nonLeafInstanceLocator = _cell->GetNonLeafInstancesUnder(_area).GetLocator(); + while (!_state && _nonLeafInstanceLocator.IsValid()) { + Instance* instance = _nonLeafInstanceLocator.GetElement(); + Cell* masterCell = instance->GetMasterCell(); + Box masterArea = _area; + instance->GetTransformation().GetInvert().ApplyOn(masterArea); + _occurrenceLocator = + masterCell->GetLeafInstanceOccurrencesUnder(masterArea).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _nonLeafInstanceLocator.Progress(); + } + } + } +} + +Cell_LeafInstanceOccurrencesUnder::Locator::Locator(const Locator& locator) +// *************************************************************************** +: Inherit(), + _cell(locator._cell), + _area(locator._area), + _state(locator._state), + _leafInstanceLocator(locator._leafInstanceLocator), + _nonLeafInstanceLocator(locator._nonLeafInstanceLocator), + _occurrenceLocator(locator._occurrenceLocator) +{ +} + +Cell_LeafInstanceOccurrencesUnder::Locator& Cell_LeafInstanceOccurrencesUnder::Locator::operator=(const Locator& locator) +// **************************************************************************************************** +{ + _cell = locator._cell; + _area = locator._area; + _state = locator._state; + _leafInstanceLocator = locator._leafInstanceLocator; + _nonLeafInstanceLocator = locator._nonLeafInstanceLocator; + _occurrenceLocator = locator._occurrenceLocator; + return *this; +} + +Occurrence Cell_LeafInstanceOccurrencesUnder::Locator::GetElement() const +// ************************************************************************ +{ + if (_state) { + switch (_state) { + case 1 : return Occurrence(_leafInstanceLocator.GetElement()); + case 2 : { + Occurrence occurrence = _occurrenceLocator.GetElement(); + Entity* entity = occurrence.GetEntity(); + Path path = Path(_nonLeafInstanceLocator.GetElement(), occurrence.GetPath()); + return Occurrence(entity, path); + } + } + } + return Occurrence(); +} + +Locator* Cell_LeafInstanceOccurrencesUnder::Locator::GetClone() const +// ******************************************************************************** +{ + return new Locator(*this); +} + +bool Cell_LeafInstanceOccurrencesUnder::Locator::IsValid() const +// **************************************************************** +{ + return (_state != 0); +} + +void Cell_LeafInstanceOccurrencesUnder::Locator::Progress() +// *********************************************************** +{ + if (_state) { + switch (_state) { + case 1 : + _leafInstanceLocator.Progress(); + if (!_leafInstanceLocator.IsValid()) { + _state = 0; + _nonLeafInstanceLocator = _cell->GetNonLeafInstancesUnder(_area).GetLocator(); + while (!_state && _nonLeafInstanceLocator.IsValid()) { + Instance* instance = _nonLeafInstanceLocator.GetElement(); + Cell* masterCell = instance->GetMasterCell(); + Box masterArea = _area; + instance->GetTransformation().GetInvert().ApplyOn(masterArea); + _occurrenceLocator = + masterCell->GetLeafInstanceOccurrencesUnder(masterArea).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _nonLeafInstanceLocator.Progress(); + } + } + break; + case 2 : + _occurrenceLocator.Progress(); + if (!_occurrenceLocator.IsValid()) { + _state = 0; + if (_nonLeafInstanceLocator.IsValid()) { + _nonLeafInstanceLocator.Progress(); + while (!_state && _nonLeafInstanceLocator.IsValid()) { + Instance* instance = _nonLeafInstanceLocator.GetElement(); + Cell* masterCell = instance->GetMasterCell(); + Box masterArea = _area; + instance->GetTransformation().GetInvert().ApplyOn(masterArea); + _occurrenceLocator = + masterCell->GetLeafInstanceOccurrencesUnder(masterArea).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _nonLeafInstanceLocator.Progress(); + } + } + } + break; + } + } +} + +string Cell_LeafInstanceOccurrencesUnder::Locator::_GetString() const +// ********************************************************************* +{ + string s = "<" + _TName("Cell::LeafInstanceOccurrencesUnder::Locator"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_area); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_TerminalInstanceOccurrences implementation +// **************************************************************************************************** + +Cell_TerminalInstanceOccurrences::Cell_TerminalInstanceOccurrences(const Cell* cell) +// ******************************************************************************* +: Inherit(), + _cell(cell) +{ +} + +Cell_TerminalInstanceOccurrences::Cell_TerminalInstanceOccurrences(const Cell_TerminalInstanceOccurrences& occurrences) +// **************************************************************************************************** +: Inherit(), + _cell(occurrences._cell) +{ +} + +Cell_TerminalInstanceOccurrences& Cell_TerminalInstanceOccurrences::operator=(const Cell_TerminalInstanceOccurrences& occurrences) +// **************************************************************************************************** +{ + _cell = occurrences._cell; + return *this; +} + +Collection* Cell_TerminalInstanceOccurrences::GetClone() const +// ********************************************************************* +{ + return new Cell_TerminalInstanceOccurrences(*this); +} + +Locator* Cell_TerminalInstanceOccurrences::GetLocator() const +// ******************************************************************** +{ + return new Locator(_cell); +} + +string Cell_TerminalInstanceOccurrences::_GetString() const +// ******************************************************* +{ + string s = "<" + _TName("Cell::TerminalInstanceOccurrences"); + if (_cell) s += " " + GetString(_cell); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_TerminalInstanceOccurrences::Locator implementation +// **************************************************************************************************** + +Cell_TerminalInstanceOccurrences::Locator::Locator(const Cell* cell) +// **************************************************************** +: Inherit(), + _cell(cell), + _state(0), + _terminalInstanceLocator(), + _nonTerminalInstanceLocator(), + _occurrenceLocator() +{ + if (_cell) { + _terminalInstanceLocator = _cell->GetTerminalInstances().GetLocator(); + if (_terminalInstanceLocator.IsValid()) + _state = 1; + else { + _nonTerminalInstanceLocator = _cell->GetNonTerminalInstances().GetLocator(); + while (!_state && _nonTerminalInstanceLocator.IsValid()) { + Cell* masterCell = _nonTerminalInstanceLocator.GetElement()->GetMasterCell(); + _occurrenceLocator = masterCell->GetTerminalInstanceOccurrences().GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _nonTerminalInstanceLocator.Progress(); + } + } + } +} + +Cell_TerminalInstanceOccurrences::Locator::Locator(const Locator& locator) +// ********************************************************************** +: Inherit(), + _cell(locator._cell), + _state(locator._state), + _terminalInstanceLocator(locator._terminalInstanceLocator), + _nonTerminalInstanceLocator(locator._nonTerminalInstanceLocator), + _occurrenceLocator(locator._occurrenceLocator) +{ +} + +Cell_TerminalInstanceOccurrences::Locator& Cell_TerminalInstanceOccurrences::Locator::operator=(const Locator& locator) +// **************************************************************************************************** +{ + _cell = locator._cell; + _state = locator._state; + _terminalInstanceLocator = locator._terminalInstanceLocator; + _nonTerminalInstanceLocator = locator._nonTerminalInstanceLocator; + _occurrenceLocator = locator._occurrenceLocator; + return *this; +} + +Occurrence Cell_TerminalInstanceOccurrences::Locator::GetElement() const +// ******************************************************************* +{ + if (_state) { + switch (_state) { + case 1 : return Occurrence(_terminalInstanceLocator.GetElement()); + case 2 : { + Occurrence occurrence = _occurrenceLocator.GetElement(); + Entity* entity = occurrence.GetEntity(); + Path path = Path(_nonTerminalInstanceLocator.GetElement(), occurrence.GetPath()); + return Occurrence(entity, path); + } + } + } + return Occurrence(); +} + +Locator* Cell_TerminalInstanceOccurrences::Locator::GetClone() const +// *************************************************************************** +{ + return new Locator(*this); +} + +bool Cell_TerminalInstanceOccurrences::Locator::IsValid() const +// *********************************************************** +{ + return (_state != 0); +} + +void Cell_TerminalInstanceOccurrences::Locator::Progress() +// ****************************************************** +{ + if (_state) { + switch (_state) { + case 1 : + _terminalInstanceLocator.Progress(); + if (!_terminalInstanceLocator.IsValid()) { + _state = 0; + _nonTerminalInstanceLocator = _cell->GetNonTerminalInstances().GetLocator(); + while (!_state && _nonTerminalInstanceLocator.IsValid()) { + Cell* masterCell = _nonTerminalInstanceLocator.GetElement()->GetMasterCell(); + _occurrenceLocator = masterCell->GetTerminalInstanceOccurrences().GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _nonTerminalInstanceLocator.Progress(); + } + } + break; + case 2 : + _occurrenceLocator.Progress(); + if (!_occurrenceLocator.IsValid()) { + _state = 0; + if (_nonTerminalInstanceLocator.IsValid()) { + _nonTerminalInstanceLocator.Progress(); + while (!_state && _nonTerminalInstanceLocator.IsValid()) { + Cell* masterCell = _nonTerminalInstanceLocator.GetElement()->GetMasterCell(); + _occurrenceLocator = + masterCell->GetTerminalInstanceOccurrences().GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _nonTerminalInstanceLocator.Progress(); + } + } + } + break; + } + } +} + +string Cell_TerminalInstanceOccurrences::Locator::_GetString() const +// **************************************************************** +{ + string s = "<" + _TName("Cell::TerminalInstanceOccurrences::Locator"); + if (_cell) s += " " + GetString(_cell); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_TerminalInstanceOccurrencesUnder implementation +// **************************************************************************************************** + +Cell_TerminalInstanceOccurrencesUnder::Cell_TerminalInstanceOccurrencesUnder() +// ************************************************************************* +: Inherit(), + _cell(NULL), + _area() +{ +} + +Cell_TerminalInstanceOccurrencesUnder::Cell_TerminalInstanceOccurrencesUnder(const Cell* cell, const Box& area) +// **************************************************************************************************** +: Inherit(), + _cell(cell), + _area(area) +{ +} + +Cell_TerminalInstanceOccurrencesUnder::Cell_TerminalInstanceOccurrencesUnder(const Cell_TerminalInstanceOccurrencesUnder& occurrences) +// **************************************************************************************************** +: Inherit(), + _cell(occurrences._cell), + _area(occurrences._area) +{ +} + +Cell_TerminalInstanceOccurrencesUnder& Cell_TerminalInstanceOccurrencesUnder::operator=(const Cell_TerminalInstanceOccurrencesUnder& occurrences) +// **************************************************************************************************** +{ + _cell = occurrences._cell; + _area = occurrences._area; + return *this; +} + +Collection* Cell_TerminalInstanceOccurrencesUnder::GetClone() const +// ************************************************************************** +{ + return new Cell_TerminalInstanceOccurrencesUnder(*this); +} + +Locator* Cell_TerminalInstanceOccurrencesUnder::GetLocator() const +// ************************************************************************* +{ + return new Locator(_cell, _area); +} + +string Cell_TerminalInstanceOccurrencesUnder::_GetString() const +// ************************************************************ +{ + string s = "<" + _TName("Cell::TerminalInstanceOccurrencesUnder"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_area); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_TerminalInstanceOccurrencesUnder::Locator implementation +// **************************************************************************************************** + +Cell_TerminalInstanceOccurrencesUnder::Locator::Locator() +// ***************************************************** +: Inherit(), + _cell(NULL), + _area(), + _state(0), + _terminalInstanceLocator(), + _nonTerminalInstanceLocator(), + _occurrenceLocator() +{ +} + +Cell_TerminalInstanceOccurrencesUnder::Locator::Locator(const Cell* cell, const Box& area) +// ************************************************************************************** +: Inherit(), + _cell(cell), + _area(area), + _state(0), + _terminalInstanceLocator(), + _nonTerminalInstanceLocator(), + _occurrenceLocator() +{ + if (_cell && !_area.IsEmpty()) { + _terminalInstanceLocator = _cell->GetTerminalInstancesUnder(_area).GetLocator(); + if (_terminalInstanceLocator.IsValid()) + _state = 1; + else { + _nonTerminalInstanceLocator = _cell->GetNonTerminalInstancesUnder(_area).GetLocator(); + while (!_state && _nonTerminalInstanceLocator.IsValid()) { + Instance* instance = _nonTerminalInstanceLocator.GetElement(); + Cell* masterCell = instance->GetMasterCell(); + Box masterArea = _area; + instance->GetTransformation().GetInvert().ApplyOn(masterArea); + _occurrenceLocator = + masterCell->GetTerminalInstanceOccurrencesUnder(masterArea).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _nonTerminalInstanceLocator.Progress(); + } + } + } +} + +Cell_TerminalInstanceOccurrencesUnder::Locator::Locator(const Locator& locator) +// *************************************************************************** +: Inherit(), + _cell(locator._cell), + _area(locator._area), + _state(locator._state), + _terminalInstanceLocator(locator._terminalInstanceLocator), + _nonTerminalInstanceLocator(locator._nonTerminalInstanceLocator), + _occurrenceLocator(locator._occurrenceLocator) +{ +} + +Cell_TerminalInstanceOccurrencesUnder::Locator& Cell_TerminalInstanceOccurrencesUnder::Locator::operator=(const Locator& locator) +// **************************************************************************************************** +{ + _cell = locator._cell; + _area = locator._area; + _state = locator._state; + _terminalInstanceLocator = locator._terminalInstanceLocator; + _nonTerminalInstanceLocator = locator._nonTerminalInstanceLocator; + _occurrenceLocator = locator._occurrenceLocator; + return *this; +} + +Occurrence Cell_TerminalInstanceOccurrencesUnder::Locator::GetElement() const +// ************************************************************************ +{ + if (_state) { + switch (_state) { + case 1 : return Occurrence(_terminalInstanceLocator.GetElement()); + case 2 : { + Occurrence occurrence = _occurrenceLocator.GetElement(); + Entity* entity = occurrence.GetEntity(); + Path path = Path(_nonTerminalInstanceLocator.GetElement(), occurrence.GetPath()); + return Occurrence(entity, path); + } + } + } + return Occurrence(); +} + +Locator* Cell_TerminalInstanceOccurrencesUnder::Locator::GetClone() const +// ******************************************************************************** +{ + return new Locator(*this); +} + +bool Cell_TerminalInstanceOccurrencesUnder::Locator::IsValid() const +// **************************************************************** +{ + return (_state != 0); +} + +void Cell_TerminalInstanceOccurrencesUnder::Locator::Progress() +// *********************************************************** +{ + if (_state) { + switch (_state) { + case 1 : + _terminalInstanceLocator.Progress(); + if (!_terminalInstanceLocator.IsValid()) { + _state = 0; + _nonTerminalInstanceLocator = _cell->GetNonTerminalInstancesUnder(_area).GetLocator(); + while (!_state && _nonTerminalInstanceLocator.IsValid()) { + Instance* instance = _nonTerminalInstanceLocator.GetElement(); + Cell* masterCell = instance->GetMasterCell(); + Box masterArea = _area; + instance->GetTransformation().GetInvert().ApplyOn(masterArea); + _occurrenceLocator = + masterCell->GetTerminalInstanceOccurrencesUnder(masterArea).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _nonTerminalInstanceLocator.Progress(); + } + } + break; + case 2 : + _occurrenceLocator.Progress(); + if (!_occurrenceLocator.IsValid()) { + _state = 0; + if (_nonTerminalInstanceLocator.IsValid()) { + _nonTerminalInstanceLocator.Progress(); + while (!_state && _nonTerminalInstanceLocator.IsValid()) { + Instance* instance = _nonTerminalInstanceLocator.GetElement(); + Cell* masterCell = instance->GetMasterCell(); + Box masterArea = _area; + instance->GetTransformation().GetInvert().ApplyOn(masterArea); + _occurrenceLocator = + masterCell->GetTerminalInstanceOccurrencesUnder(masterArea).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _nonTerminalInstanceLocator.Progress(); + } + } + } + break; + } + } +} + +string Cell_TerminalInstanceOccurrencesUnder::Locator::_GetString() const +// ********************************************************************* +{ + string s = "<" + _TName("Cell::TerminalInstanceOccurrencesUnder::Locator"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_area); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_ComponentOccurrences implementation +// **************************************************************************************************** + +Cell_ComponentOccurrences::Cell_ComponentOccurrences() +// ************************************************* +: Inherit(), + _cell(NULL), + _mask(0) +{ +} + +Cell_ComponentOccurrences::Cell_ComponentOccurrences(const Cell* cell, const Layer::Mask& mask) +// ****************************************************************************************** +: Inherit(), + _cell(cell), + _mask(mask) +{ +} + +Cell_ComponentOccurrences::Cell_ComponentOccurrences(const Cell_ComponentOccurrences& occurrences) +// ******************************************************************************************* +: Inherit(), + _cell(occurrences._cell), + _mask(occurrences._mask) +{ +} + +Cell_ComponentOccurrences& Cell_ComponentOccurrences::operator=(const Cell_ComponentOccurrences& occurrences) +// **************************************************************************************************** +{ + _cell = occurrences._cell; + _mask = occurrences._mask; + return *this; +} + +Collection* Cell_ComponentOccurrences::GetClone() const +// ************************************************************** +{ + return new Cell_ComponentOccurrences(*this); +} + +Locator* Cell_ComponentOccurrences::GetLocator() const +// ************************************************************* +{ + return new Locator(_cell, _mask); +} + +string Cell_ComponentOccurrences::_GetString() const +// ************************************************ +{ + string s = "<" + _TName("Cell::ComponentOccurrences"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_mask); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_ComponentOccurrences::Locator implementation +// **************************************************************************************************** + +Cell_ComponentOccurrences::Locator::Locator() +// ***************************************** +: Inherit(), + _cell(NULL), + _mask(0), + _state(0), + _componentLocator(), + _instanceLocator(), + _occurrenceLocator() +{ +} + +Cell_ComponentOccurrences::Locator::Locator(const Cell* cell, const Layer::Mask& mask) +// ********************************************************************************** +: Inherit(), + _cell(cell), + _mask(mask), + _state(0), + _componentLocator(), + _instanceLocator(), + _occurrenceLocator() +{ + if (_cell && (_mask != 0)) { + _componentLocator = _cell->GetComponents(_mask).GetLocator(); + if (_componentLocator.IsValid()) + _state = 1; + else { + _instanceLocator = _cell->GetInstances().GetLocator(); + while (!_state && _instanceLocator.IsValid()) { + Cell* masterCell = _instanceLocator.GetElement()->GetMasterCell(); + _occurrenceLocator = masterCell->GetComponentOccurrences(_mask).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _instanceLocator.Progress(); + } + } + } +} + +Cell_ComponentOccurrences::Locator::Locator(const Locator& locator) +// *************************************************************** +: Inherit(), + _cell(locator._cell), + _mask(locator._mask), + _state(locator._state), + _componentLocator(locator._componentLocator), + _instanceLocator(locator._instanceLocator), + _occurrenceLocator(locator._occurrenceLocator) +{ +} + +Cell_ComponentOccurrences::Locator& Cell_ComponentOccurrences::Locator::operator=(const Locator& locator) +// **************************************************************************************************** +{ + _cell = locator._cell; + _mask = locator._mask; + _state = locator._state; + _componentLocator = locator._componentLocator; + _instanceLocator = locator._instanceLocator; + _occurrenceLocator = locator._occurrenceLocator; + return *this; +} + +Occurrence Cell_ComponentOccurrences::Locator::GetElement() const +// ************************************************************ +{ + if (_state) { + switch (_state) { + case 1 : return Occurrence(_componentLocator.GetElement()); + case 2 : { + Occurrence occurrence = _occurrenceLocator.GetElement(); + Entity* entity = occurrence.GetEntity(); + Path path = Path(_instanceLocator.GetElement(), occurrence.GetPath()); + return Occurrence(entity, path); + } + } + } + return Occurrence(); +} + +Locator* Cell_ComponentOccurrences::Locator::GetClone() const +// ******************************************************************** +{ + return new Locator(*this); +} + +bool Cell_ComponentOccurrences::Locator::IsValid() const +// **************************************************** +{ + return (_state != 0); +} + +void Cell_ComponentOccurrences::Locator::Progress() +// *********************************************** +{ + if (_state) { + switch (_state) { + case 1 : + _componentLocator.Progress(); + if (!_componentLocator.IsValid()) { + _state = 0; + _instanceLocator = _cell->GetInstances().GetLocator(); + while (!_state && _instanceLocator.IsValid()) { + Cell* masterCell = _instanceLocator.GetElement()->GetMasterCell(); + _occurrenceLocator = masterCell->GetComponentOccurrences(_mask).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _instanceLocator.Progress(); + } + } + break; + case 2 : + _occurrenceLocator.Progress(); + if (!_occurrenceLocator.IsValid()) { + _state = 0; + if (_instanceLocator.IsValid()) { + _instanceLocator.Progress(); + while (!_state && _instanceLocator.IsValid()) { + Cell* masterCell = _instanceLocator.GetElement()->GetMasterCell(); + _occurrenceLocator = masterCell->GetComponentOccurrences(_mask).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _instanceLocator.Progress(); + } + } + } + break; + } + } +} + +string Cell_ComponentOccurrences::Locator::_GetString() const +// ********************************************************* +{ + string s = "<" + _TName("Cell::ComponentOccurrences::Locator"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_mask); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_ComponentOccurrencesUnder implementation +// **************************************************************************************************** + +Cell_ComponentOccurrencesUnder::Cell_ComponentOccurrencesUnder() +// *********************************************************** +: Inherit(), + _cell(NULL), + _area(), + _mask(0) +{ +} + +Cell_ComponentOccurrencesUnder::Cell_ComponentOccurrencesUnder(const Cell* cell, const Box& area, const Layer::Mask& mask) +// **************************************************************************************************** +: Inherit(), + _cell(cell), + _area(area), + _mask(mask) +{ +} + +Cell_ComponentOccurrencesUnder::Cell_ComponentOccurrencesUnder(const Cell_ComponentOccurrencesUnder& occurrences) +// **************************************************************************************************** +: Inherit(), + _cell(occurrences._cell), + _area(occurrences._area), + _mask(occurrences._mask) +{ +} + +Cell_ComponentOccurrencesUnder& Cell_ComponentOccurrencesUnder::operator=(const Cell_ComponentOccurrencesUnder& occurrences) +// **************************************************************************************************** +{ + _cell = occurrences._cell; + _area = occurrences._area; + _mask = occurrences._mask; + return *this; +} + +Collection* Cell_ComponentOccurrencesUnder::GetClone() const +// ******************************************************************* +{ + return new Cell_ComponentOccurrencesUnder(*this); +} + +Locator* Cell_ComponentOccurrencesUnder::GetLocator() const +// ****************************************************************** +{ + return new Locator(_cell, _area, _mask); +} + +string Cell_ComponentOccurrencesUnder::_GetString() const +// ***************************************************** +{ + string s = "<" + _TName("Cell::ComponentOccurrencesUnder"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_area); + s += " " + GetString(_mask); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_ComponentOccurrencesUnder::Locator implementation +// **************************************************************************************************** + +Cell_ComponentOccurrencesUnder::Locator::Locator() +// ********************************************** +: Inherit(), + _cell(NULL), + _area(), + _mask(0), + _state(0), + _componentLocator(), + _instanceLocator(), + _occurrenceLocator() +{ +} + +Cell_ComponentOccurrencesUnder::Locator::Locator(const Cell* cell, const Box& area, const Layer::Mask& mask) +// **************************************************************************************************** +: Inherit(), + _cell(cell), + _area(area), + _mask(mask), + _state(0), + _componentLocator(), + _instanceLocator(), + _occurrenceLocator() +{ + if (_cell && !_area.IsEmpty() && (_mask != 0)) { + _componentLocator = _cell->GetComponentsUnder(_area, _mask).GetLocator(); + if (_componentLocator.IsValid()) + _state = 1; + else { + _instanceLocator = _cell->GetInstancesUnder(_area).GetLocator(); + while (!_state && _instanceLocator.IsValid()) { + Instance* instance = _instanceLocator.GetElement(); + Cell* masterCell = instance->GetMasterCell(); + Box masterArea = _area; + instance->GetTransformation().GetInvert().ApplyOn(masterArea); + _occurrenceLocator = + masterCell->GetComponentOccurrencesUnder(masterArea, _mask).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _instanceLocator.Progress(); + } + } + } +} + +Cell_ComponentOccurrencesUnder::Locator::Locator(const Locator& locator) +// ******************************************************************** +: Inherit(), + _cell(locator._cell), + _area(locator._area), + _mask(locator._mask), + _state(locator._state), + _componentLocator(locator._componentLocator), + _instanceLocator(locator._instanceLocator), + _occurrenceLocator(locator._occurrenceLocator) +{ +} + +Cell_ComponentOccurrencesUnder::Locator& Cell_ComponentOccurrencesUnder::Locator::operator=(const Locator& locator) +// **************************************************************************************************** +{ + _cell = locator._cell; + _area = locator._area; + _mask = locator._mask; + _state = locator._state; + _componentLocator = locator._componentLocator; + _instanceLocator = locator._instanceLocator; + _occurrenceLocator = locator._occurrenceLocator; + return *this; +} + +Occurrence Cell_ComponentOccurrencesUnder::Locator::GetElement() const +// ***************************************************************** +{ + if (_state) { + switch (_state) { + case 1 : return Occurrence(_componentLocator.GetElement()); + case 2 : { + Occurrence occurrence = _occurrenceLocator.GetElement(); + Entity* entity = occurrence.GetEntity(); + Path path = Path(_instanceLocator.GetElement(), occurrence.GetPath()); + return Occurrence(entity, path); + } + } + } + return Occurrence(); +} + +Locator* Cell_ComponentOccurrencesUnder::Locator::GetClone() const +// ************************************************************************* +{ + return new Locator(*this); +} + +bool Cell_ComponentOccurrencesUnder::Locator::IsValid() const +// ********************************************************* +{ + return (_state != 0); +} + +void Cell_ComponentOccurrencesUnder::Locator::Progress() +// **************************************************** +{ + if (_state) { + switch (_state) { + case 1 : + _componentLocator.Progress(); + if (!_componentLocator.IsValid()) { + _state = 0; + _instanceLocator = _cell->GetInstancesUnder(_area).GetLocator(); + while (!_state && _instanceLocator.IsValid()) { + Instance* instance = _instanceLocator.GetElement(); + Cell* masterCell = instance->GetMasterCell(); + Box masterArea = _area; + instance->GetTransformation().GetInvert().ApplyOn(masterArea); + _occurrenceLocator = + masterCell->GetComponentOccurrencesUnder(masterArea, _mask).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _instanceLocator.Progress(); + } + } + break; + case 2 : + _occurrenceLocator.Progress(); + if (!_occurrenceLocator.IsValid()) { + _state = 0; + if (_instanceLocator.IsValid()) { + _instanceLocator.Progress(); + while (!_state && _instanceLocator.IsValid()) { + Instance* instance = _instanceLocator.GetElement(); + Cell* masterCell = instance->GetMasterCell(); + Box masterArea = _area; + instance->GetTransformation().GetInvert().ApplyOn(masterArea); + _occurrenceLocator = + masterCell->GetComponentOccurrencesUnder(masterArea, _mask).GetLocator(); + if (_occurrenceLocator.IsValid()) + _state = 2; + else + _instanceLocator.Progress(); + } + } + } + break; + } + } +} + +string Cell_ComponentOccurrencesUnder::Locator::_GetString() const +// ************************************************************** +{ + string s = "<" + _TName("Cell::ComponentOccurrencesUnder::Locator"); + if (_cell) { + s += " " + GetString(_cell); + s += " " + GetString(_area); + s += " " + GetString(_mask); + } + s += ">"; + return s; +} + +// **************************************************************************************************** +// Cell_HyperNetRootNetOccurrences implementation +// **************************************************************************************************** + +Cell_HyperNetRootNetOccurrences::Cell_HyperNetRootNetOccurrences() +// ************************************* +: Inherit(), + _cell(NULL), + _path() +{ +} + +Cell_HyperNetRootNetOccurrences::Cell_HyperNetRootNetOccurrences(const Cell* cell, Path path) +// **************************************************************** +: Inherit(), + _cell(cell), + _path(path) +{ +} + +Cell_HyperNetRootNetOccurrences::Cell_HyperNetRootNetOccurrences(const Cell_HyperNetRootNetOccurrences& netOccurrences) +// **************************************************************************** +: Inherit(), + _cell(netOccurrences._cell), + _path(netOccurrences._path) +{ +} + +Cell_HyperNetRootNetOccurrences& Cell_HyperNetRootNetOccurrences::operator=(const Cell_HyperNetRootNetOccurrences& netOccurrences) +// *************************************************************************************** +{ + _cell = netOccurrences._cell; + _path = netOccurrences._path; + return *this; +} + +Collection* Cell_HyperNetRootNetOccurrences::GetClone() const +// ******************************************************** +{ + return new Cell_HyperNetRootNetOccurrences(*this); +} + +Locator* Cell_HyperNetRootNetOccurrences::GetLocator() const +// ******************************************************* +{ + return new Locator(_cell, _path); +} + +string Cell_HyperNetRootNetOccurrences::_GetString() const +// ****************************************** +{ + string s = "<" + _TName("Cell::HyperNetRootNetOccurrences"); + if (_cell) { + s += " " + GetString(_cell); + if (!_path.IsEmpty()) s += " " + GetString(_path); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_HyperNetRootNetOccurrences::Locator implementation +// **************************************************************************************************** + +Cell_HyperNetRootNetOccurrences::Locator::Locator() +// *********************************** +: Inherit(), + _path(), + _netLocator(), + _instanceLocator(), + _hyperNetRootNetOccurrenceLocator() +{ +} + +Cell_HyperNetRootNetOccurrences::Locator::Locator(const Cell* cell, Path path) +// ************************************************************** +: Inherit(), + _path(path), + _netLocator(), + _instanceLocator(), + _hyperNetRootNetOccurrenceLocator() +{ + _netLocator=cell->GetNets().GetLocator(); + + _instanceLocator=cell->GetInstances().GetLocator(); + + while (_netLocator.IsValid() && !IsHyperNetRootNetOccurrence(Occurrence(_netLocator.GetElement(),_path))) + _netLocator.Progress(); + + if (!_netLocator.IsValid()) + while (!_hyperNetRootNetOccurrenceLocator.IsValid() && _instanceLocator.IsValid()) + { + Instance* instance = _instanceLocator.GetElement(); + _hyperNetRootNetOccurrenceLocator=Locator(instance->GetMasterCell(),Path(_path,instance)); + _instanceLocator.Progress(); + } +} + +Cell_HyperNetRootNetOccurrences::Locator::Locator(const Locator& locator) +// ********************************************************* +: Inherit(), + _path(locator._path), + _netLocator(locator._netLocator), + _instanceLocator(locator._instanceLocator), + _hyperNetRootNetOccurrenceLocator(locator._hyperNetRootNetOccurrenceLocator) +{ +} + +Cell_HyperNetRootNetOccurrences::Locator& Cell_HyperNetRootNetOccurrences::Locator::operator=(const Locator& locator) +// **************************************************************************************** +{ + _path = locator._path; + _netLocator = locator._netLocator; + _instanceLocator = locator._instanceLocator; + _hyperNetRootNetOccurrenceLocator = locator._hyperNetRootNetOccurrenceLocator; + return *this; +} + +Occurrence Cell_HyperNetRootNetOccurrences::Locator::GetElement() const +// ****************************************************** +{ + if (_netLocator.IsValid()) + return Occurrence(_netLocator.GetElement(),_path); + else if (_hyperNetRootNetOccurrenceLocator.IsValid()) + return _hyperNetRootNetOccurrenceLocator.GetElement(); + else + return Occurrence(); + +} + +Locator* Cell_HyperNetRootNetOccurrences::Locator::GetClone() const +// ************************************************************** +{ + return new Locator(*this); +} + +bool Cell_HyperNetRootNetOccurrences::Locator::IsValid() const +// ********************************************** +{ + return (_netLocator.IsValid() || (_hyperNetRootNetOccurrenceLocator.IsValid())); +} + +void Cell_HyperNetRootNetOccurrences::Locator::Progress() +// ***************************************** +{ + if (_netLocator.IsValid()) + { + do { + _netLocator.Progress(); + } + while (_netLocator.IsValid() && !IsHyperNetRootNetOccurrence(Occurrence(_netLocator.GetElement(),_path))); + } + else if (_hyperNetRootNetOccurrenceLocator.IsValid()) + _hyperNetRootNetOccurrenceLocator.Progress(); + + if (!_netLocator.IsValid()) + while (!_hyperNetRootNetOccurrenceLocator.IsValid() && _instanceLocator.IsValid()) + { + Instance* instance = _instanceLocator.GetElement(); + _hyperNetRootNetOccurrenceLocator=Locator(instance->GetMasterCell(),Path(_path,instance)); + _instanceLocator.Progress(); + } + +} + +string Cell_HyperNetRootNetOccurrences::Locator::_GetString() const +// *************************************************** +{ + string s = "<" + _TName("Cell::HyperNetRootNetOccurrences::Locator"); + if (!_path.IsEmpty()) + s += " " + _path.GetName(); + s += ">"; + return s; +} + + +// **************************************************************************************************** +// Cell_ImpactedMainViews implementation +// **************************************************************************************************** + +//Cell_ImpactedMainViews::Cell_ImpactedMainViews(const Cell* cell) +//// ************************************************************* +//: Inherit(), +// _cell(cell) +//{ +//} +// +//Cell_ImpactedMainViews::Cell_ImpactedMainViews(const Cell_ImpactedMainViews& impactedMainViews) +//// ******************************************************************************************** +//: Inherit(), +// _cell(impactedMainViews._cell) +//{ +//} +// +//Cell_ImpactedMainViews& Cell_ImpactedMainViews::operator=(const Cell_ImpactedMainViews& impactedMainViews) +//// **************************************************************************************************** +//{ +// _cell = impactedMainViews._cell; +// return *this; +//} +// +//Collection* Cell_ImpactedMainViews::GetClone() const +//// ************************************************************ +//{ +// return new Cell_ImpactedMainViews(*this); +//} +// +//Locator* Cell_ImpactedMainViews::GetLocator() const +//// *********************************************************** +//{ +// return new Locator(_cell); +//} +// +//string Cell_ImpactedMainViews::_GetString() const +//// ********************************************** +//{ +// string s = "<" + _TName("Cell::ImpactedMainViews"); +// if (_cell) s += " " + GetString(_cell); +// s += ">"; +// return s; +//} +// +// +// +//// **************************************************************************************************** +//// Cell_ImpactedMainViews::Locator implementation +//// **************************************************************************************************** +// +//Cell_ImpactedMainViews::Locator::Locator(const Cell* cell) +//// ******************************************************* +//: Inherit(), +// _cell(cell), +// _cellSet(), +// _cellStack(), +// _mainViewLocator(), +// _mainView(NULL) +//{ +// if (_cell) { +// _cellSet.insert((Cell*)_cell); +// _cellStack.push((Cell*)_cell); +// while (!_mainView && !_cellStack.empty()) { +// Cell* cell = _cellStack.top(); +// _cellStack.pop(); +// for_each_instance(instance, cell->GetSlaveInstances()) { +// Cell* cell = instance->GetCell(); +// if (_cellSet.find(cell) == _cellSet.end()) { +// _cellSet.insert(cell); +// _cellStack.push(cell); +// } +// end_for; +// } +// _mainViewLocator = cell->GetMainViews().GetLocator(); +// _mainView = _mainViewLocator.GetElement(); +// } +// } +//} +// +//Cell_ImpactedMainViews::Locator::Locator(const Locator& locator) +//// ************************************************************* +//: Inherit(), +// _cell(locator._cell), +// _cellSet(locator._cellSet), +// _cellStack(locator._cellStack), +// _mainViewLocator(locator._mainViewLocator), +// _mainView(locator._mainView) +//{ +//} +// +//Cell_ImpactedMainViews::Locator& Cell_ImpactedMainViews::Locator::operator=(const Locator& locator) +//// ************************************************************************************************ +//{ +// _cell = locator._cell; +// _cellSet = locator._cellSet; +// _cellStack = locator._cellStack; +// _mainViewLocator = locator._mainViewLocator; +// _mainView = locator._mainView; +// return *this; +//} +// +//MainView* Cell_ImpactedMainViews::Locator::GetElement() const +//// ********************************************************** +//{ +// return _mainView; +//} +// +//Locator* Cell_ImpactedMainViews::Locator::GetClone() const +//// ****************************************************************** +//{ +// return new Locator(*this); +//} +// +//bool Cell_ImpactedMainViews::Locator::IsValid() const +//// ************************************************** +//{ +// return (_mainView != NULL); +//} +// +//void Cell_ImpactedMainViews::Locator::Progress() +//// ********************************************* +//{ +// if (_mainView) { +// _mainView = NULL; +// do { +// _mainViewLocator.Progress(); +// _mainView = _mainViewLocator.GetElement(); +// if (!_mainView && !_cellStack.empty()) { +// Cell* cell = _cellStack.top(); +// _cellStack.pop(); +// for_each_instance(instance, cell->GetSlaveInstances()) { +// Cell* cell = instance->GetCell(); +// if (_cellSet.find(cell) == _cellSet.end()) { +// _cellSet.insert(cell); +// _cellStack.push(cell); +// } +// end_for; +// } +// _mainViewLocator = cell->GetMainViews().GetLocator(); +// _mainView = _mainViewLocator.GetElement(); +// } +// } while (!_mainView && !_cellStack.empty()); +// } +//} +// +//string Cell_ImpactedMainViews::Locator::_GetString() const +//// ******************************************************* +//{ +// string s = "<" + _TName("Cell::ImpactedMainViews::Locator"); +// if (_cell) s += " " + GetString(_cell); +// s += ">"; +// return s; +//} +// +// +// **************************************************************************************************** +// Cell_SubCells implementation +// **************************************************************************************************** + +Cell_SubCells::Cell_SubCells() +// *************************** +: Inherit(), + _cell(NULL) +{ +} + +Cell_SubCells::Cell_SubCells(const Cell* cell) +// ******************************************* +: Inherit(), + _cell(cell) +{ +} + +Cell_SubCells::Cell_SubCells(const Cell_SubCells& subCells) +// ******************************************************** +: Inherit(), + _cell(subCells._cell) +{ +} + +Cell_SubCells& Cell_SubCells::operator=(const Cell_SubCells& subCells) +// ******************************************************************* +{ + _cell = subCells._cell; + return *this; +} + +Collection* Cell_SubCells::GetClone() const +// *********************************************** +{ + return new Cell_SubCells(*this); +} + +Locator* Cell_SubCells::GetLocator() const +// ********************************************** +{ + return new Locator(_cell->GetInstances().GetLocator()); +} + +string Cell_SubCells::_GetString() const +// ************************************* +{ + string s = "<" + _TName("Cell::SubCells"); + if (_cell) { + s += " " + GetString(_cell); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Cell_SubCells::Locator implementation +// **************************************************************************************************** + +Cell_SubCells::Locator::Locator() +// ********************************** +: Inherit(), + _cellSet(), + _instanceLocator() +{ +} + +Cell_SubCells::Locator::Locator(InstanceLocator instanceLocator) +// ************************************************************* +: Inherit(), + _cellSet(), + _instanceLocator(instanceLocator) +{ + if ( IsValid() ) + _cellSet.insert ( _instanceLocator.GetElement()->GetMasterCell() ); +} + +Cell_SubCells::Locator::Locator(const Locator& locator) +// **************************************************** +: Inherit(), + _cellSet(locator._cellSet), + _instanceLocator(locator._instanceLocator) +{ +} + +Cell_SubCells::Locator& Cell_SubCells::Locator::operator=(const Locator& locator) +// ****************************************************************************** +{ + _cellSet = locator._cellSet; + _instanceLocator = locator._instanceLocator; + return *this; +} + +Cell* Cell_SubCells::Locator::GetElement() const +// ********************************************* +{ + return _instanceLocator.GetElement()->GetMasterCell(); +} + +Locator* Cell_SubCells::Locator::GetClone() const +// ***************************************************** +{ + return new Locator(*this); +} + +bool Cell_SubCells::Locator::IsValid() const +// ***************************************** +{ + return _instanceLocator.IsValid(); +} + +void Cell_SubCells::Locator::Progress() +// ************************************ +{ + while ( IsValid() && ( _cellSet.find ( _instanceLocator.GetElement()->GetMasterCell() ) != _cellSet.end() ) ) + _instanceLocator.Progress(); + if ( IsValid() ) + _cellSet.insert ( _instanceLocator.GetElement()->GetMasterCell() ); +} + +string Cell_SubCells::Locator::_GetString() const +// ************************************************** +{ + string s = "<" + _TName("Cell::SubCells::Locator"); + s += " " + _GetString(); + s += " " + GetString(_instanceLocator); + s += ">"; + return s; +} + + + + +// x-----------------------------------------------------------------x +// | "::Cell_RecursiveSlavePathes::Locator" Class Definitions | +// x-----------------------------------------------------------------x + + +// ------------------------------------------------------------------- +// Constructor : "Cell_RecursiveSlavePathes::Locator::Locator ()". + +Cell_RecursiveSlavePathes::Locator::Locator ( const Cell* cell ) + : Hurricane::Locator() + , _instancesStack() + , _instancePath() + , _isInPop(false) +{ + const Cell* topCell = cell; + + do { + Instances slaveInstances = topCell->GetSlaveInstances(); + + if ( !slaveInstances.IsEmpty() ) { + _instancesStack.push_back ( *slaveInstances.GetLocator() ); + _instancePath = Path ( _instancesStack.back().GetElement(), _instancePath ); + +// cerr << "Instances of I: " << topCell->GetName() << endl; +// cerr << "Head I: " << _instancesStack.back().GetElement()->GetName() << endl; +// cerr << "TailPath I: " << _instancePath.GetName() << endl; + + topCell = _instancesStack.back().GetElement()->GetCell(); + } else + topCell = NULL; + + } while ( topCell ); +} + + + + +// ------------------------------------------------------------------- +// Modifier : "Cell_RecursiveSlavePathes::Locator::Progress ()". + +void Cell_RecursiveSlavePathes::Locator::Progress () +{ + if ( !IsValid() ) return; + + _instancesStack.back().Progress(); + if ( _instancesStack.back().IsValid() ) { +// cerr << "Head N: " << _instancesStack.back().GetElement()->GetName() << endl; +// cerr << "TailPath N: " << _instancePath.GetTailPath().GetName() << endl; + _instancePath = Path ( _instancesStack.back().GetElement(), _instancePath.GetTailPath() ); + + Cell* topCell = _instancesStack.back().GetElement()->GetCell(); + + do { + Instances slaveInstances = topCell->GetSlaveInstances(); + + if ( !slaveInstances.IsEmpty() ) { + _instancesStack.push_back ( *slaveInstances.GetLocator() ); +// cerr << "Instances of R: " << topCell->GetName() << endl; +// cerr << "Head R: " << _instancesStack.back().GetElement()->GetName() << endl; +// cerr << "TailPath R: " << _instancePath.GetName() << endl; + _instancePath = Path ( _instancesStack.back().GetElement(), _instancePath ); + + topCell = _instancesStack.back().GetElement()->GetCell(); + } else + topCell = NULL; + } while ( topCell ); + + return; + } else { + _instancesStack.pop_back(); + _instancePath = _instancePath.GetTailPath(); +// cerr << "TailPath F: " << _instancePath.GetName() << endl; + return; + } +} + + + + +// ------------------------------------------------------------------- +// Hurricane Management : "Cell_RecursiveSlavePathes::Locator::_GetString ()". + +string Cell_RecursiveSlavePathes::Locator::_GetString () const +{ + Name masterCellName = "Finished"; + + if ( IsValid() ) + masterCellName = _instancesStack.front().GetElement()->GetMasterCell()->GetName(); + + string s = "<" + _TName("Cell_RecursiveSlavePathes::Locator") + + GetString(masterCellName) + + ">"; + + return s; +} + + + + +// x-----------------------------------------------------------------x +// | "::Cell_RecursiveSlavePathes" Class Definitions | +// x-----------------------------------------------------------------x + + +// ------------------------------------------------------------------- +// Hurricane Management : "Cell_RecursiveSlavePathes::_GetString ()". + +string Cell_RecursiveSlavePathes::_GetString () const +{ + string s = "<" + _TName("Cell_RecursiveSlavePathes") + " " + + GetString(_cell) + " " + + ">"; + + return s; +} + + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Cells.h b/hurricane/src/hurricane/Cells.h new file mode 100644 index 00000000..7fc6c58b --- /dev/null +++ b/hurricane/src/hurricane/Cells.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Cells.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_CELLS +#define HURRICANE_CELLS + +#include "Collection.h" + +namespace Hurricane { + +class Cell; + + + +// **************************************************************************************************** +// Cells declaration +// **************************************************************************************************** + +typedef GenericCollection Cells; + + + +// **************************************************************************************************** +// CellLocator declaration +// **************************************************************************************************** + +typedef GenericLocator CellLocator; + + + +// **************************************************************************************************** +// CellFilter declaration +// **************************************************************************************************** + +typedef GenericFilter CellFilter; + + + +// **************************************************************************************************** +// for_each_cell declaration +// **************************************************************************************************** + +#define for_each_cell(cell, cells)\ +/*********************************/\ +{\ + CellLocator _locator = cells.GetLocator();\ + while (_locator.IsValid()) {\ + Cell* cell = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_CELLS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Collection.h b/hurricane/src/hurricane/Collection.h new file mode 100644 index 00000000..ea28cad3 --- /dev/null +++ b/hurricane/src/hurricane/Collection.h @@ -0,0 +1,837 @@ +// **************************************************************************************************** +// File: Collection.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment LIP6 & BULL versions + +#ifndef HURRICANE_COLLECTION +#define HURRICANE_COLLECTION + +#include "Locator.h" +#include "Filter.h" + +namespace Hurricane { + +template class GenericCollection; +template class SubTypeCollection; +template class SubSetCollection; + + + +// **************************************************************************************************** +// Collection declaration +// **************************************************************************************************** + +template class Collection : public NestedSlotAdapter { +// ************************************************************* + +// Constructors +// ************ + + protected: Collection() + // ******************** + { + } + + private: Collection(const Collection& collection); + // *********************************************** + // not implemented to forbid copy construction + // *********************************************** + +// Destructor +// ********** + + public: virtual ~Collection() + // ************************** + { + } + +// Operators +// ********* + + private: Collection& operator=(const Collection& collection); + // ********************************************************** + // not implemented to forbid assignment + // ********************************************************** + +// Accessors +// ********* + + public: virtual Collection* GetClone() const = 0; + + public: virtual Locator* GetLocator() const = 0; + + public: virtual unsigned GetSize() const + // ************************************* + { + unsigned size = 0; + // we use a GenericLocator to delete the locator allocated by GetLocator() + GenericLocator locator = GetLocator(); + while (locator.IsValid()) { + size++; + locator.Progress(); + } + return size; + } + + public: Type GetFirst() const + // ************************** + { + // we use a GenericLocator to delete the locator allocated by GetLocator() + return GenericLocator(GetLocator()).GetElement(); + } + + public: GenericCollection GetSubSet(const Filter& filter) const + // ************************************************************************ + { + return SubSetCollection(*this, filter); + } + + public: template GenericCollection GetSubSet() const + // ************************************************************************* + { + return SubTypeCollection(this); + } + + public: template + GenericCollection GetSubSet(const Filter& filter) const + // ****************************************************************************** + { + return GetSubSet().GetSubSet(filter); + } + +// Predicates +// ********** + + public: bool IsEmpty() const + // ************************* + { + // we use a GenericLocator to delete the locator allocated by GetLocator() + return !GenericLocator(GetLocator()).IsValid(); + } + +// Utilitarians +// ************ + + public: void Fill(list& list) const + // ************************************** + { + GenericLocator locator = GetLocator(); + while (locator.IsValid()) { + list.push_back(locator.GetElement()); + locator.Progress(); + } + } + + public: void Fill(set& set) const + // ************************************ + { + GenericLocator locator = GetLocator(); + while (locator.IsValid()) { + set.insert(locator.GetElement()); + locator.Progress(); + } + } + + public: template void Fill(set& set) const + // ********************************************************************* + { + GenericLocator locator = GetLocator(); + while (locator.IsValid()) { + set.insert(locator.GetElement()); + locator.Progress(); + } + } + + public: void Fill(vector& vector) const + // ****************************************** + { + GenericLocator locator = GetLocator(); + while (locator.IsValid()) { + vector.push_back(locator.GetElement()); + locator.Progress(); + } + } + +// Others +// ****** + + public: virtual string _GetTypeName() const + // ************************************** + { + return _TName("Collection"); + }; + + public: virtual string _GetString() const = 0; + + public: Record* _GetRecord() const + // ************************* + { + Record* record = NULL; + if (!IsEmpty()) { + record = new Record(GetString(this)); + unsigned n = 1; + GenericLocator locator = GetLocator(); + while (locator.IsValid()) { + string slotName = GetString(n++); + Type slotRecord = locator.GetElement(); + record->Add(GetSlot(slotName, slotRecord)); + locator.Progress(); + } + } + return record; + } + +}; + + + +// **************************************************************************************************** +// GenericCollection declaration +// **************************************************************************************************** + +template class GenericCollection : public Collection { +// ******************************************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + +// Attributes +// ********** + + private: Collection* _collection; + +// Constructors +// ************ + + public: GenericCollection() + // *********************** + : Inherit(), + _collection(NULL) + { + } + + public: GenericCollection(const Collection& collection) + // ********************************************************** + : Inherit(), + _collection(collection.GetClone()) + { + } + + public: GenericCollection(const GenericCollection& genericCollection) + // ************************************************************************ + : Inherit(), + _collection(genericCollection.GetClone()) + { + } + + public: GenericCollection(Collection* collection) + // ************************************************************* + // CAUTION : collection will be deleted by the GenericCollection + // ************************************************************* + : Inherit(), + _collection(collection) + { + } + +// Destructor +// ********** + + public: virtual ~GenericCollection() + // ********************************* + { + if (_collection) delete _collection; + } + +// Operators +// ********* + + public: GenericCollection& operator=(const Collection& collection) + // ********************************************************************* + { + if (_collection) delete _collection; + _collection = collection.GetClone(); + return *this; + } + + public: GenericCollection& operator=(const GenericCollection& genericCollection) + // ***************************************************************************** + { + if (_collection) delete _collection; + _collection = genericCollection.GetClone(); + return *this; + } + + public: GenericCollection& operator=(Collection* collection) + // *************************************************************** + // CAUTION : collection will be deleted by the GenericCollection + // *************************************************************** + { + if (_collection) delete _collection; + _collection = collection; + return *this; + } + +// Accessors +// ********* + + public: virtual Collection* GetClone() const + // *********************************************** + { + return (_collection) ? _collection->GetClone() : NULL; + } + + public: virtual Locator* GetLocator() const + // ********************************************** + { + return (_collection) ? _collection->GetLocator() : NULL; + } + + public: virtual unsigned GetSize() const + // ************************************* + { + return (_collection) ? _collection->GetSize() : 0; + } + +// Others +// ****** + + public: virtual string _GetTypeName() const + // ************************************** + { + return _TName("GenericCollection"); + }; + + public: virtual string _GetString() const + // ************************************** + { + if (!_collection) + return "<" + _GetTypeName() + " unbound>"; + else + return "<" + _GetTypeName()+ " " + GetString(_collection) + ">"; + } + +}; + + + +// **************************************************************************************************** +// ElementCollection declaration +// **************************************************************************************************** + +template class ElementCollection : public Collection { +// ********************************************************************* + + // ----------------------------------------------------------------- + // Sub-Class : "::ElementCollection::Locator". + public: template class Locator : public Hurricane::Locator { + + // Attributes + // ********** + protected: const ElType _element; + protected: bool _done; + + // Constructors + // ************ + public: Locator ( const ElType _element ) : _element(_element), _done(false) {}; + public: Locator ( const Locator &locator ) : _element(locator._element), _done(locator._done) {}; + + // Accessors + // ********* + public: virtual ElType GetElement () const { return const_cast(_element); }; + public: virtual Locator* GetClone () const { return new Locator(*this); }; + public: virtual bool IsValid () const { return !_done; }; + public: virtual void Progress () { _done = true; }; + + // Hurricane Management + // ******************** + public: virtual string _GetString () const { + if (!_element) + return "<" + _TName("ElementCollection::Locator") + " unbound>"; + else + return "<" + _TName("ElementCollection::Locator") + " " + GetString(_element) + ">"; + } + + }; + +// Types +// ***** + + public: typedef Collection Inherit; + +// Attributes +// ********** + + private: Type _element; + +// Constructors +// ************ + + public: ElementCollection() + // *********************** + : Inherit(), + _element(NULL) + { + } + + public: ElementCollection(const Type element) + // ********************************************************** + : Inherit(), + _element(element) + { + } + + public: ElementCollection(const ElementCollection& elementCollection) + // ************************************************************************ + : Inherit(), + _element(elementCollection._element) + { + } + +// Accessors +// ********* + + public: virtual Collection* GetClone() const + // *********************************************** + { + return ( new ElementCollection (*this) ); + } + + public: virtual Locator* GetLocator() const + // ********************************************** + { + return ( new Locator (_element) ); + } + + public: virtual unsigned GetSize() const + // ************************************* + { + return (_element) ? 1 : 0; + } + +// Others +// ****** + + public: virtual string _GetString() const + // ************************************** + { + if (!_element) + return "<" + _TName("ElementCollection") + " unbound>"; + else + return "<" + _TName("ElementCollection") + " " + GetString(_element) + ">"; + } + +}; + + + +// **************************************************************************************************** +// SubTypeCollection declaration +// **************************************************************************************************** + +template class SubTypeCollection : public Collection { +// ************************************************************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ******************************************************* + + // Types + // ***** + + public: typedef Hurricane::Locator Inherit; + + // Attributes + // ********** + + private: GenericLocator _locator; + + // Constructors + // ************ + + public: Locator(const GenericCollection& collection) + // ******************************************************** + : Inherit(), + _locator(collection.GetLocator()) + { + while (_locator.IsValid() && !is_a(_locator.GetElement())) + _locator.Progress(); + } + + public: Locator(const GenericLocator& genericLocator) + // ******************************************************** + : Inherit(), + _locator(genericLocator.GetClone()) + { + while (_locator.IsValid() && !is_a(_locator.GetElement())) + _locator.Progress(); + } + + // Accessors + // ********* + + public: virtual SubType GetElement() const + // *************************************** + { + return (_locator.IsValid()) ? (SubType)_locator.GetElement() : SubType(); + } + + public: virtual Hurricane::Locator* GetClone() const + // ********************************************************** + { + return new Locator(_locator); + } + + public: virtual Hurricane::Locator* GetLocator() // 21-10-03 + // ************************************************* + { + return dynamic_cast*> ( + _locator.GetLocator()->GetLocator() ); + } + + + // Predicates + // ********** + + public: virtual bool IsValid() const + // ********************************* + { + return _locator.IsValid(); + } + + // Updators + // ******** + + public: virtual void Progress() + // **************************** + { + if (_locator.IsValid()) { + do { + _locator.Progress(); + } while (_locator.IsValid() && !is_a(_locator.GetElement())); + } + } + + }; + +// Attributes +// ********** + + private: GenericCollection _collection; + +// Constructors +// ************ + + public: SubTypeCollection() + // ******************** + : Inherit(), + _collection() + { + } + + public: SubTypeCollection(const Collection* collection) + // ********************************************************** + : Inherit(), + _collection(collection->GetClone()) + { + } + + public: SubTypeCollection(const GenericCollection& collection) + // ***************************************************************** + : Inherit(), + _collection(collection) + { + } + + public: SubTypeCollection(const SubTypeCollection& subTypeCollection) + // ****************************************************************** + : Inherit(), + _collection(subTypeCollection._collection) + { + } + +// Operators +// ********* + + public: SubTypeCollection& operator=(const SubTypeCollection& subTypeCollection) + // ***************************************************************************** + { + _collection = subTypeCollection._collection; + return *this; + } + +// Accessors +// ********* + + public: virtual Collection* GetClone() const + // ************************************************** + { + return new SubTypeCollection(_collection); + } + + public: virtual Hurricane::Locator* GetLocator() const + // ************************************************************ + { + return new Locator(_collection); + } + +// Accessors +// ********* + + public: virtual string _GetString() const + // ************************************** + { + return "<" + _TName("SubTypeCollection") + " " + GetString(_collection) + ">"; + } + +}; + + + +// **************************************************************************************************** +// SubSetCollection implementation +// **************************************************************************************************** + +template class SubSetCollection : public Collection { +// ****************************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // **************************************************** + + // Types + // ***** + + public: typedef Hurricane::Locator Inherit; + + // Attributes + // ********** + + private: GenericLocator _locator; + private: GenericFilter _filter; + + // Constructors + // ************ + + public: Locator(const SubSetCollection& collection, const Filter& filter) + // ********************************************************************************** + : Inherit(), + _locator(collection.GetLocator()), + _filter(filter) + { + while (_locator.IsValid() && !_filter.Accept(_locator.GetElement())) + _locator.Progress(); + } + + public: Locator(const Collection& collection, const Filter& filter) + // **************************************************************************** + : Inherit(), + _locator(collection.GetLocator()), + _filter(filter) + { + while (_locator.IsValid() && !_filter.Accept(_locator.GetElement())) + _locator.Progress(); + } + + public: Locator(const GenericCollection& genericCollection, const Filter& filter) + // ****************************************************************************************** + : Inherit(), + _locator(genericCollection.GetLocator()), + _filter(filter) + { + while (_locator.IsValid() && !_filter.Accept(_locator.GetElement())) + _locator.Progress(); + } + + public: Locator(const GenericLocator& genericLocator, const Filter& filter) + // ************************************************************************************ + : Inherit(), + _locator(genericLocator), + _filter(filter) + { + while (_locator.IsValid() && !_filter.Accept(_locator.GetElement())) + _locator.Progress(); + } + + // Accessors + // ********* + + public: virtual Type GetElement() const + // ************************************ + { + return (_locator.IsValid()) ? _locator.GetElement() : Type(); + } + + public: virtual Hurricane::Locator* GetClone() const + // ******************************************************* + { + return new Locator(_locator, _filter); + } + + public: virtual Hurricane::Locator* GetLocator() // 21-10-03 + // *************************************************** + { + return ( _locator.GetLocator()->GetLocator() ); + } + + // Predicates + // ********** + + public: virtual bool IsValid() const + // ********************************* + { + return _locator.IsValid(); + } + + // Updators + // ******** + + public: virtual void Progress() + // **************************** + { + if (_locator.IsValid()) { + do { + _locator.Progress(); + } while (_locator.IsValid() && !_filter.Accept(_locator.GetElement())); + } + } + + }; + +// Attributes +// ********** + + private: GenericCollection _collection; + private: GenericFilter _filter; + +// Constructors +// ************ + + public: SubSetCollection() + // *********************** + : Inherit(), + _collection(), + _filter() + { + } + + public: SubSetCollection(const Collection& collection, const Filter& filter) + // ************************************************************************************* + : Inherit(), + _collection(collection), + _filter(filter) + { + } + + public: SubSetCollection(const SubSetCollection& subSetCollection) + // *************************************************************** + : Inherit(), + _collection(subSetCollection._collection), + _filter(subSetCollection._filter) + { + } + +// Operators +// ********* + + public: SubSetCollection& operator=(const SubSetCollection& subSetCollection) + // ************************************************************************** + { + _collection = subSetCollection._collection; + _filter = subSetCollection._filter; + return *this; + } + +// Accessors +// ********* + + public: virtual Collection* GetClone() const + // *********************************************** + { + return new SubSetCollection(_collection, _filter); + } + + public: virtual Hurricane::Locator* GetLocator() const + // ********************************************************* + { + return new Locator(_collection, _filter); + } + +// Accessors +// ********* + + public: virtual string _GetString() const + // ************************************** + { + return "<" + _TName("SubSetCollection") + " " + GetString(_collection) + ">"; + } + +}; + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + + + +// **************************************************************************************************** +// Macros declaration +// **************************************************************************************************** + +#define end_for\ +/**************/\ + }\ + } + +#define for_each_object(Type, element, collection)\ +/*************************************************/\ +{\ + GenericLocator _locator = collection.GetLocator();\ + while (_locator.IsValid()) {\ + Type element = _locator.GetElement();\ + _locator.Progress(); + +#define for_each_element(Type, element, collection)\ +/*************************************************/\ +{\ + ElementCollection::Locator* _locator = collection.GetLocator();\ + while (_locator->IsValid()) {\ + Type element = _locator->GetElement();\ + _locator->Progress(); + + +template + class IsNestedSlotAdapter > { + public: + enum { True=1, False=0 }; + }; + + + +} // End of Hurricane namespace. + + +#include "MultisetCollection.h" +#include "SetCollection.h" +#include "MapCollection.h" +#include "ListCollection.h" +#include "VectorCollection.h" + +#endif // HURRICANE_COLLECTION + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Commons.cpp b/hurricane/src/hurricane/Commons.cpp new file mode 100644 index 00000000..73102fa2 --- /dev/null +++ b/hurricane/src/hurricane/Commons.cpp @@ -0,0 +1,221 @@ +// **************************************************************************************************** +// File: Commons.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + + +#ifdef HAVE_LIBIBERTY +# include "demangle.h" +# include "libiberty.h" +#endif + +#include "Commons.h" + + +namespace Hurricane { + + + +// **************************************************************************************************** +// Tracing tools +// **************************************************************************************************** + +static long TRACE_LEVEL = 0; +static unsigned int TRACE_SHOW_LEVEL = (unsigned int)-1; + +bool in_trace() +// ************ +{ + return (0 < TRACE_LEVEL); +} + +void trace_on() +// ************ +{ + TRACE_LEVEL++; +} + +void trace_off() +// ************* +{ + if (0 < TRACE_LEVEL) TRACE_LEVEL--; +} + +void trace_in() +// ************ +{ + if (0 < TRACE_LEVEL) tab++; +} + +void trace_out() +// ************* +{ + if (0 < TRACE_LEVEL) tab--; +} + +bool inltrace ( unsigned int level ) +//*********************************** +{ + return TRACE_SHOW_LEVEL <= level; +} + +unsigned int ltracelevel ( unsigned int level ) +//********************************************** +{ + unsigned int previousLevel = TRACE_SHOW_LEVEL; + TRACE_SHOW_LEVEL = level; + + return previousLevel; +} + +void ltracein (unsigned int level, unsigned int count ) +//****************************************************** +{ + if ( inltrace(level) ) while ( count-- ) tab++; +} + +void ltraceout (unsigned int level, unsigned int count ) +//******************************************************* +{ + if ( inltrace(level) ) while ( count-- ) tab--; +} + +// ------------------------------------------------------------------- +// Function : "Demangle ()". + +string Demangle ( const char* symbol ) +{ + string mangled = "_Z"; + mangled += symbol; + +# ifdef HAVE_LIBIBERTY + char* result = cplus_demangle ( mangled.c_str(), DMGL_PARAMS|DMGL_ANSI|DMGL_TYPES ); + + if ( result ) { + mangled = result; + free ( result ); + return mangled; + } +# endif + + return mangled; +} + + + +} // End of Hurricane namespace. + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +bool Scan(const string& s, unsigned& u) +// ************************************ +{ + unsigned v, n; + sscanf(s.c_str(), "%u%n", &v, &n); + if (n != s.size()) return false; + u = v; + return true; +} + +bool Scan(const string& s, unsigned short& u) +// ****************************************** +{ + unsigned short v; + unsigned n; + sscanf(s.c_str(), "%hu%n", &v, &n); + if (n != s.size()) return false; + u = v; + return true; +} + +bool Scan(const string& s, double& d) +// ********************************** +{ + unsigned n; + double v; + sscanf(s.c_str(), "%lf%n", &v, &n); + if (n != s.size()) return false; + d = v; + return true; +} + +bool Scan(const string& s, int& i) +// ******************************* +{ + int v; + unsigned n; + sscanf(s.c_str(), "%d%n", &v, &n); + if (n != s.size()) return false; + i = v; + return true; +} + + +// ------------------------------------------------------------------- +// Function : "Scan()". + + /*! \overload bool Scan ( const string &s, string &pattern ) + * \param s string to interpret. + * \param pattern a stipple pattern for a layer. + * \return true if the conversion was correct. + * + * Look for a stipple patern. Checks the string length (must be + * equal to 16) and only made of hexadecimal characters. + */ + +bool Scan ( const string &s, string &pattern ) +{ + if ( s.size() != 16 ) return ( false ); + + string validChars = "0123456789ABCDEFabcdef"; + for ( unsigned i=0 ; i<16 ; i++ ) { + if ( validChars.find(s[i]) == string::npos ) return ( false ); + } + pattern = s; + + return ( true ); +} + + +// ------------------------------------------------------------------- +// Function : "Scan()". + + /*! \overload bool Scan ( const string &s, unsigned short &redValue, unsigned short &greenValue, unsigned short &blueValue ) + * \param s string to interpret. + * \param redValue the red color's component. + * \param greenValue the green color's component. + * \param blueValue the blue color's component. + * \return true if the conversion was correct. + * + * Split a string of the form \c "RRR,GGG,BBB" into its numerical + * components (between 0 and 255). + */ + +bool Scan ( const string &s + , unsigned short &redValue + , unsigned short &greenValue + , unsigned short &blueValue ) +{ + unsigned n; + unsigned short red; + unsigned short green; + unsigned short blue; + + sscanf ( s.c_str(), "%hu,%hu,%hu%n", &red, &green, &blue, &n ); + if ( n != s.size() ) return ( false ); + + redValue = red; + greenValue = green; + blueValue = blue; + + return ( true ); +} + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Commons.h b/hurricane/src/hurricane/Commons.h new file mode 100644 index 00000000..f2833124 --- /dev/null +++ b/hurricane/src/hurricane/Commons.h @@ -0,0 +1,174 @@ + + +// -*- C++ -*- +// +// This file is part of the Hurricane Software. +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// +// =================================================================== +// +// $Id: Commons.h,v 1.19 2007/07/29 15:24:52 jpc Exp $ +// +// x-----------------------------------------------------------------x +// | | +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Remy Escassut | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./Commons.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + + + +# ifndef __HURRICANE_COMMONS__ +# define __HURRICANE_COMMONS__ + + +# include +# include + +# include +# include +# include +# include +# include +# include +# include +# include + + + + +// x-----------------------------------------------------------------x +// | Macros Definition | +// x-----------------------------------------------------------------x + + +# define Hurricane H +# define BEGIN_NAMESPACE_HURRICANE namespace Hurricane { +# define END_NAMESPACE_HURRICANE } +# define USING_NAMESPACE_HURRICANE using namespace std; using namespace Hurricane; + + +# define is_a (bool)dynamic_cast + + +using namespace std; + + +namespace Hurricane { + + using namespace std; + + + // --------------------------------------------------------------- + // Forward Declarations. + + class Slot; + class Record; + + + + + // x-------------------------------------------------------------x + // | Tracing/Debugging Utilites | + // x-------------------------------------------------------------x + + + bool in_trace (); + void trace_on (); + void trace_off (); + void trace_in (); + void trace_out (); + bool inltrace ( unsigned int level ); + unsigned int ltracelevel ( unsigned int level ); + void ltracein ( unsigned int level, unsigned int count=1 ); + void ltraceout ( unsigned int level, unsigned int count=1 ); + +# define trace if (in_trace() ) cerr << tab +# define ltrace(level) if (inltrace(level)) cerr << tab + + + + + // x-------------------------------------------------------------x + // | Miscellaneous Utilites | + // x-------------------------------------------------------------x + + + inline string _TName ( const string& s ) { return s; } + inline string _PName ( const string& s ) { return "Hurricane::" + s; } + + template + inline Type abs ( const Type& value ) { return (value<0) ? -value : value; } + + string Demangle ( const char* symbol ); + inline string Demangle ( const type_info& info ) { return Demangle(info.name()); } + + + + +} // End of Hurricane namespace. + + + + +// x-----------------------------------------------------------------x +// | Generic Functions Definition | +// x-----------------------------------------------------------------x + + +using namespace std; + + + + +// x-----------------------------------------------------------------x +// | GetString() Overloads for POD/STL types | +// x-----------------------------------------------------------------x + +// Note: we are outside the Hurricane namespace. + + +# include "SlotAdapter.h" + + + + +// x-----------------------------------------------------------------x +// | Scan() Overloads for POD/STL types | +// x-----------------------------------------------------------------x + +// Note: we are outside the Hurricane namespace. + + +bool Scan ( const string& s, int& i ); +bool Scan ( const string& s, unsigned& u ); +bool Scan ( const string& s, unsigned short& u ); +bool Scan ( const string& s, double& d ); +bool Scan ( const string& s, string& pattern ); +bool Scan ( const string& s, unsigned short& redValue + , unsigned short& greenValue + , unsigned short& blueValue ); + + + +// x-----------------------------------------------------------------x +// | Record & Tabulation Types Definitions | +// x-----------------------------------------------------------------x + +// Note: Record & Tabulation are not templates, so they can be defined +// early. + +# include "Tabulation.h" + + + + +# endif diff --git a/hurricane/src/hurricane/Component.cpp b/hurricane/src/hurricane/Component.cpp new file mode 100644 index 00000000..a6f7bca0 --- /dev/null +++ b/hurricane/src/hurricane/Component.cpp @@ -0,0 +1,946 @@ +// **************************************************************************************************** +// File: Component.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Component.h" +#include "Net.h" +#include "Cell.h" +#include "Rubber.h" +#include "Slice.h" +#include "BasicLayer.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Filters declaration & implementation +// **************************************************************************************************** + +class Component_IsUnderFilter : public Filter { +// ****************************************************** + + public: Box _area; + + public: Component_IsUnderFilter(const Box& area) + // ********************************************* + : _area(area) + { + }; + + public: Component_IsUnderFilter(const Component_IsUnderFilter& filter) + // ******************************************************************* + : _area(filter._area) + { + }; + + public: Component_IsUnderFilter& operator=(const Component_IsUnderFilter& filter) + // ****************************************************************************** + { + _area = filter._area; + return *this; + }; + + public: virtual Filter* GetClone() const + // ************************************************* + { + return new Component_IsUnderFilter(*this); + }; + + public: virtual bool Accept(Component* component) const + // **************************************************** + { + return _area.Intersect(component->GetBoundingBox()); + }; + + public: virtual string _GetString() const + // ************************************** + { + return "<" + _TName("Component::IsUnderFilter") + " " + GetString(_area) + ">"; + }; + +}; + + + +// **************************************************************************************************** +// Component_Hooks declaration +// **************************************************************************************************** + +class Component_Hooks : public Collection { +// ********************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ***************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Component* _component; + private: Hook* _hook; + + public: Locator(const Component* component = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Hook* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Component* _component; + +// Constructors +// ************ + + public: Component_Hooks(const Component* component = NULL); + public: Component_Hooks(const Component_Hooks& hooks); + +// Operators +// ********* + + public: Component_Hooks& operator=(const Component_Hooks& hooks); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Component_ConnexComponents declaration +// **************************************************************************************************** + +class Component_ConnexComponents : public Collection { +// ************************************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Component* _component; + private: set _componentSet; + private: stack _componentStack; + + public: Locator(const Component* component = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Component* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Component* _component; + +// Constructors +// ************ + + public: Component_ConnexComponents(const Component* component = NULL); + public: Component_ConnexComponents(const Component_ConnexComponents& connexComponents); + +// Operators +// ********* + + public: Component_ConnexComponents& operator=(const Component_ConnexComponents& connexComponents); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Component_SlaveComponents declaration +// **************************************************************************************************** + +class Component_SlaveComponents : public Collection { +// ************************************************************ + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Component* _component; + private: set _componentSet; + private: stack _componentStack; + + public: Locator(const Component* component = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Component* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + +}; + +// Attributes +// ********** + + private: const Component* _component; + +// Constructors +// ************ + + public: Component_SlaveComponents(const Component* component = NULL); + public: Component_SlaveComponents(const Component_SlaveComponents& slaveComponents); + +// Operators +// ********* + + public: Component_SlaveComponents& operator=(const Component_SlaveComponents& slaveComponents); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; +}; + + + +// **************************************************************************************************** +// Component implementation +// **************************************************************************************************** + +Component::Component(Net* net, bool inPlugCreate) +// ********************************************** +: Inherit(), + _net(net), + _rubber(NULL), + _bodyHook(this), + _nextOfNetComponentSet(NULL) +{ + if (!inPlugCreate && !_net) + throw Error("Can't create " + _TName("Component") + " : null net"); +} + +Cell* Component::GetCell() const +// ***************************** +{ + return _net->GetCell(); +} + +Hooks Component::GetHooks() const +// ****************************** +{ + return Component_Hooks(this); +} + +Components Component::GetConnexComponents() const +// ********************************************** +{ + return Component_ConnexComponents(this); +} + +Components Component::GetSlaveComponents() const +// ********************************************* +{ + return Component_SlaveComponents(this); +} + +ComponentFilter Component::GetIsUnderFilter(const Box& area) +// ********************************************************* +{ + return Component_IsUnderFilter(area); +} + +void Component::Materialize() +// ************************** +{ +// trace << "Materialize() - " << this << endl; + + if (!IsMaterialized()) { + Cell* cell = GetCell(); + Layer* layer = GetLayer(); + if (cell && layer) { + Slice* slice = cell->GetSlice(layer); + if (!slice) slice = Slice::_Create(cell, layer); + QuadTree* quadTree = slice->_GetQuadTree(); + quadTree->Insert(this); + cell->_Fit(quadTree->GetBoundingBox()); + } else { + //cerr << "[WARNING] " << this << " not inserted into QuadTree." << endl; + } + } +} + +void Component::Unmaterialize() +// **************************** +{ +// trace << "Unmaterializing " << this << endl; + + if (IsMaterialized()) { + Cell* cell = GetCell(); + Slice* slice = cell->GetSlice(GetLayer()); + if (slice) { + cell->_Unfit(GetBoundingBox()); + slice->_GetQuadTree()->Remove(this); + if (slice->IsEmpty()) slice->_Delete(); + } + } +} + +void Component::Invalidate(bool propagateFlag) +// ******************************************* +{ + Inherit::Invalidate(false); + + if (propagateFlag) { + Rubber* rubber = GetRubber(); + if (rubber) rubber->Invalidate(); + for_each_component(component, GetSlaveComponents()) { + component->Invalidate(false); + end_for; + } + } +} + +void Component::_PostCreate() +// ************************** +{ + if (_net) _net->_GetComponentSet()._Insert(this); + + Inherit::_PostCreate(); +} + +void Component::_PreDelete() +// ************************* +{ +// trace << "entering Component::_PreDelete: " << this << endl; +// trace_in(); + + ClearProperties(); + + set componentSet; + GetSlaveComponents().Fill(componentSet); + + set masterHookSet; + componentSet.insert(this); + for_each_component(component, GetCollection(componentSet)) { + component->Unmaterialize(); + for_each_hook(hook, component->GetHooks()) { + for_each_hook(hook, hook->GetHooks()) { + if (hook->IsMaster() && (componentSet.find(hook->GetComponent()) == componentSet.end())) + masterHookSet.insert(hook); + end_for; + } + if (!hook->IsMaster()) hook->Detach(); + end_for; + } + end_for; + } + + componentSet.erase(this); + for_each_component(component, GetCollection(componentSet)) { + component->Delete(); + end_for; + } + + set rubberSet; + set mainMasterHookSet; + for_each_hook(hook, GetCollection(masterHookSet)) { + Rubber* rubber = hook->GetComponent()->GetRubber(); + if (!rubber) + mainMasterHookSet.insert(hook); + else { + if (rubberSet.find(rubber) == rubberSet.end()) { + rubberSet.insert(rubber); + mainMasterHookSet.insert(hook); + } + } + end_for; + } + Hook* masterHook = NULL; + for_each_hook(hook, GetCollection(mainMasterHookSet)) { + if (!masterHook) + masterHook = hook; + else + hook->Merge(masterHook); + end_for; + } + /**/ + + _bodyHook.Detach(); + + Inherit::_PreDelete(); + + if (_net) _net->_GetComponentSet()._Remove(this); + + + // trace << "exiting Component::_PreDelete:" << endl; + // trace_out(); +} + +string Component::_GetString() const +// ********************************* +{ + string s = Inherit::_GetString(); + if (!_net) + s.insert(s.length() - 1, " UNCONNECTED"); + else + s.insert(s.length() - 1, " " + GetString(_net->GetName())); + return s; +} + +Record* Component::_GetRecord() const +// **************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Net", _net)); + record->Add(GetSlot("Rubber", _rubber)); + record->Add(GetSlot("BodyHook", &_bodyHook)); + } + return record; +} + +void Component::_SetNet(Net* net) +// ****************************** +{ + if (net != _net) { + if (_net) _net->_GetComponentSet()._Remove(this); + _net = net; + if (_net) _net->_GetComponentSet()._Insert(this); + } +} + +void Component::_SetRubber(Rubber* rubber) +// *************************************** +{ + if (rubber != _rubber) { + if (_rubber) _rubber->_Release(); + _rubber = rubber; + if (_rubber) _rubber->_Capture(); + } +} + +//bool Component::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +//// ***************************************************************************************** +//{ +// Box area(point); +// area.Inflate(aperture); +// for_each_basic_layer(basicLayer, GetLayer()->GetBasicLayers()) { +// if (view->IsVisible(basicLayer) && GetBoundingBox(basicLayer).Intersect(area)) +// return true; +// end_for; +// } +// +// return false; +//} +// +//void Component::_Highlight(View* view, const Box& updateArea, const Transformation& transformation) +//// ************************************************************************************************ +//{ +// for_each_basic_layer(basicLayer, GetLayer()->GetBasicLayers()) { +// _Draw(view, basicLayer, updateArea, transformation); +// end_for; +// } +//} +// + +// **************************************************************************************************** +// Component::BodyHook implementation +// **************************************************************************************************** + +static int BODY_HOOK_OFFSET = -1; + +Component::BodyHook::BodyHook(Component* component) +// ************************************************ +: Inherit() +{ + if (!component) + throw Error("Can't create " + _TName("Component::BodyHook") + " : null component"); + + if (BODY_HOOK_OFFSET == -1) + BODY_HOOK_OFFSET = (unsigned long)this - (unsigned long)component; +} + +Component* Component::BodyHook::GetComponent() const +// ************************************************* +{ + return (Component*)((unsigned long)this - BODY_HOOK_OFFSET); +} + +string Component::BodyHook::_GetString() const +// ******************************************* +{ + return "<" + _TName("Component::BodyHook") + " " + GetString(GetComponent()) + ">"; +} + +// **************************************************************************************************** +// Component_Hooks implementation +// **************************************************************************************************** + +Component_Hooks::Component_Hooks(const Component* component) +// ********************************************************* +: Inherit(), + _component(component) +{ +} + +Component_Hooks::Component_Hooks(const Component_Hooks& hooks) +// *********************************************************** +: Inherit(), + _component(hooks._component) +{ +} + +Component_Hooks& Component_Hooks::operator=(const Component_Hooks& hooks) +// ********************************************************************** +{ + _component = hooks._component; + return *this; +} + +Collection* Component_Hooks::GetClone() const +// ************************************************* +{ + return new Component_Hooks(*this); +} + +Locator* Component_Hooks::GetLocator() const +// ************************************************ +{ + return new Locator(_component); +} + +string Component_Hooks::_GetString() const +// *************************************** +{ + string s = "<" + _TName("Component::Hooks"); + if (_component) s += " " + GetString(_component); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Component_Hooks::Locator implementation +// **************************************************************************************************** + +Component_Hooks::Locator::Locator(const Component* component) +// ********************************************************** +: Inherit(), + _component(component), + _hook(NULL) +{ + if (_component) _hook = ((Component*)_component)->GetBodyHook(); +} + +Component_Hooks::Locator::Locator(const Locator& locator) +// ****************************************************** +: Inherit(), + _component(locator._component), + _hook(locator._hook) +{ +} + +Component_Hooks::Locator& Component_Hooks::Locator::operator=(const Locator& locator) +// ********************************************************************************** +{ + _component = locator._component; + _hook = locator._hook; + return *this; +} + +Hook* Component_Hooks::Locator::GetElement() const +// *********************************************** +{ + return _hook; +} + +Locator* Component_Hooks::Locator::GetClone() const +// ******************************************************* +{ + return new Locator(*this); +} + +bool Component_Hooks::Locator::IsValid() const +// ******************************************* +{ + return (_hook != NULL); +} + +void Component_Hooks::Locator::Progress() +// ************************************** +{ + _hook = NULL; +} + +string Component_Hooks::Locator::_GetString() const +// ************************************************ +{ + string s = "<" + _TName("Component::Hooks::Locator"); + if (_component) s += " " + GetString(_component); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Component_ConnexComponents implementation +// **************************************************************************************************** + +Component_ConnexComponents::Component_ConnexComponents(const Component* component) +// ******************************************************************************* +: Inherit(), + _component(component) +{ +} + +Component_ConnexComponents::Component_ConnexComponents(const Component_ConnexComponents& connexComponents) +// **************************************************************************************************** +: Inherit(), + _component(connexComponents._component) +{ +} + +Component_ConnexComponents& + Component_ConnexComponents::operator=(const Component_ConnexComponents& connexComponents) +// ***************************************************************************************** +{ + _component = connexComponents._component; + return *this; +} + +Collection* Component_ConnexComponents::GetClone() const +// ***************************************************************** +{ + return new Component_ConnexComponents(*this); +} + +Locator* Component_ConnexComponents::GetLocator() const +// **************************************************************** +{ + return new Locator(_component); +} + +string Component_ConnexComponents::_GetString() const +// ************************************************** +{ + string s = "<" + _TName("Component::ConnexComponents"); + if (_component) s += " " + GetString(_component); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Component_ConnexComponents::Locator implementation +// **************************************************************************************************** + +Component_ConnexComponents::Locator::Locator(const Component* component) +// ********************************************************************* +: Inherit(), + _component(component), + _componentSet(), + _componentStack() +{ + if (_component) { + _componentSet.insert((Component*)_component); + _componentStack.push((Component*)_component); + } +} + +Component_ConnexComponents::Locator::Locator(const Locator& locator) +// ***************************************************************** +: Inherit(), + _component(locator._component), + _componentSet(locator._componentSet), + _componentStack(locator._componentStack) +{ +} + +Component_ConnexComponents::Locator& Component_ConnexComponents::Locator::operator=(const Locator& locator) +// **************************************************************************************************** +{ + _component = locator._component; + _componentSet = locator._componentSet; + _componentStack = locator._componentStack; + return *this; +} + +Component* Component_ConnexComponents::Locator::GetElement() const +// *************************************************************** +{ + return _componentStack.top(); +} + +Locator* Component_ConnexComponents::Locator::GetClone() const +// *********************************************************************** +{ + return new Locator(*this); +} + +bool Component_ConnexComponents::Locator::IsValid() const +// ****************************************************** +{ + return !_componentStack.empty(); +} + +void Component_ConnexComponents::Locator::Progress() +// ************************************************* +{ + if (!_componentStack.empty()) { + Component* component = _componentStack.top(); + _componentStack.pop(); + for_each_hook(componentHook, component->GetHooks()) { + Hook* masterHook = componentHook->GetMasterHook(); + if (masterHook) { + for_each_hook(slaveHook, masterHook->GetSlaveHooks()) { + Component* component = slaveHook->GetComponent(); + if (_componentSet.find(component) == _componentSet.end()) { + _componentSet.insert(component); + _componentStack.push(component); + } + end_for; + } + Component* component = masterHook->GetComponent(); + if (_componentSet.find(component) == _componentSet.end()) { + _componentSet.insert(component); + _componentStack.push(component); + } + } + end_for; + } + } +} + +string Component_ConnexComponents::Locator::_GetString() const +// *********************************************************** +{ + string s = "<" + _TName("Component::ConnexComponents::Locator"); + if (_component) s += " " + GetString(_component); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Component_SlaveComponents implementation +// **************************************************************************************************** + +Component_SlaveComponents::Component_SlaveComponents(const Component* component) +// ***************************************************************************** +: Inherit(), + _component(component) +{ +} + +Component_SlaveComponents::Component_SlaveComponents(const Component_SlaveComponents& slaveComponents) +// *************************************************************************************************** +: Inherit(), + _component(slaveComponents._component) +{ +} + +Component_SlaveComponents& + Component_SlaveComponents::operator=(const Component_SlaveComponents& slaveComponents) +// ************************************************************************************** +{ + _component = slaveComponents._component; + return *this; +} + +Collection* Component_SlaveComponents::GetClone() const +// **************************************************************** +{ + return new Component_SlaveComponents(*this); +} + +Locator* Component_SlaveComponents::GetLocator() const +// *************************************************************** +{ + return new Locator(_component); +} + +string Component_SlaveComponents::_GetString() const +// ************************************************* +{ + string s = "<" + _TName("Component::SlaveComponents"); + if (_component) s += " " + GetString(_component); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Component_SlaveComponents::Locator implementation +// **************************************************************************************************** + +Component_SlaveComponents::Locator::Locator(const Component* component) +// ******************************************************************** +: Inherit(), + _component(component), + _componentSet(), + _componentStack() +{ + if (_component) { + _componentSet.insert((Component*)_component); + Hook* masterHook = ((Component*)_component)->GetBodyHook(); + for_each_hook(slaveHook, masterHook->GetSlaveHooks()) { + Component* component = slaveHook->GetComponent(); + if (_componentSet.find(component) == _componentSet.end()) { + _componentSet.insert(component); + _componentStack.push(component); + } + end_for; + } + } +} + +Component_SlaveComponents::Locator::Locator(const Locator& locator) +// **************************************************************** +: Inherit(), + _component(locator._component), + _componentSet(locator._componentSet), + _componentStack(locator._componentStack) +{ +} + +Component_SlaveComponents::Locator& + Component_SlaveComponents::Locator::operator=(const Locator& locator) +// ********************************************************************* +{ + _component = locator._component; + _componentSet = locator._componentSet; + _componentStack = locator._componentStack; + return *this; +} + +Component* Component_SlaveComponents::Locator::GetElement() const +// ************************************************************** +{ + return _componentStack.top(); +} + +Locator* Component_SlaveComponents::Locator::GetClone() const +// ********************************************************************** +{ + return new Locator(*this); +} + +bool Component_SlaveComponents::Locator::IsValid() const +// ***************************************************** +{ + return !_componentStack.empty(); +} + +void Component_SlaveComponents::Locator::Progress() +// ************************************************ +{ + if (!_componentStack.empty()) { + Component* component = _componentStack.top(); + _componentStack.pop(); + Hook* masterHook = component->GetBodyHook(); + for_each_hook(slaveHook, masterHook->GetSlaveHooks()) { + Component* component = slaveHook->GetComponent(); + if (_componentSet.find(component) == _componentSet.end()) { + _componentSet.insert(component); + _componentStack.push(component); + } + end_for; + } + } +} + +string Component_SlaveComponents::Locator::_GetString() const +// ********************************************************** +{ + string s = "<" + _TName("Component::SlaveComponents::Locator"); + if (_component) s += " " + GetString(_component); + s += ">"; + return s; +} + +double GetArea ( Component* component ) +//************************************** +{ + Box bb = component->GetBoundingBox (); + + return GetValue(bb.GetWidth()) * GetValue(bb.GetHeight()); +} + + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Component.h b/hurricane/src/hurricane/Component.h new file mode 100644 index 00000000..042bb39a --- /dev/null +++ b/hurricane/src/hurricane/Component.h @@ -0,0 +1,132 @@ +// **************************************************************************************************** +// File: Component.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_COMPONENT +#define HURRICANE_COMPONENT + +#include "Go.h" +#include "Components.h" +#include "Hook.h" +#include "Hooks.h" +#include "Interval.h" + +namespace Hurricane { + +class Net; +class Rubber; +class Layer; + + + +// **************************************************************************************************** +// Component declaration +// **************************************************************************************************** + +class Component : public Go { +// ************************ + +// Types +// ***** + + public: typedef Go Inherit; + + public: class BodyHook : public Hook { + // ********************************* + + friend class Component; + + public: typedef Hook Inherit; + + private: BodyHook(Component* component); + + public: virtual Component* GetComponent() const; + + public: virtual bool IsMaster() const {return true;}; + + public: virtual string _GetTypeName() const { return _TName("Component::BodyHook"); }; + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: Net* _net; + private: Rubber* _rubber; + private: BodyHook _bodyHook; + private: Component* _nextOfNetComponentSet; + +// Constructors +// ************ + + protected: Component(Net* net, bool inPlugCreate = false); + +// Accessors +// ********* + + public: virtual Cell* GetCell() const; + public: Net* GetNet() const {return _net;}; + public: Rubber* GetRubber() const {return _rubber;}; + public: Hook* GetBodyHook() {return &_bodyHook;}; + public: virtual Hooks GetHooks() const; + public: virtual Unit GetX() const = 0; + public: virtual Unit GetY() const = 0; + public: virtual Point GetPosition() const {return Point(GetX(), GetY());}; + public: virtual Point GetCenter() const {return GetPosition();}; + public: virtual Layer* GetLayer() const = 0; + public: virtual Box GetBoundingBox() const = 0; + public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const = 0; + public: Components GetConnexComponents() const; + public: Components GetSlaveComponents() const; + +// Updators +// ******** + + public: virtual void Materialize(); + public: virtual void Unmaterialize(); + public: virtual void Invalidate(bool propagateFlag = true); + +// Filters +// ******* + + public: static ComponentFilter GetIsUnderFilter(const Box& area); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: Component* _GetNextOfNetComponentSet() const {return _nextOfNetComponentSet;}; + + public: void _SetNet(Net* net); + public: void _SetRubber(Rubber* rubber); + public: void _SetNextOfNetComponentSet(Component* component) {_nextOfNetComponentSet = component;}; + + //public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; + //public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + +double GetArea ( Component* component ); + + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Component) +SetNestedSlotAdapter(Hurricane::Component::BodyHook) + +#endif // HURRICANE_COMPONENT + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Components.h b/hurricane/src/hurricane/Components.h new file mode 100644 index 00000000..4f386933 --- /dev/null +++ b/hurricane/src/hurricane/Components.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Components.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_COMPONENTS +#define HURRICANE_COMPONENTS + +#include "Collection.h" + +namespace Hurricane { + +class Component; + + + +// **************************************************************************************************** +// Components declaration +// **************************************************************************************************** + +typedef GenericCollection Components; + + + +// **************************************************************************************************** +// ComponentLocator declaration +// **************************************************************************************************** + +typedef GenericLocator ComponentLocator; + + + +// **************************************************************************************************** +// ComponentFilter declaration +// **************************************************************************************************** + +typedef GenericFilter ComponentFilter; + + + +// **************************************************************************************************** +// for_each_component declaration +// **************************************************************************************************** + +#define for_each_component(component, components)\ +/************************************************/\ +{\ + ComponentLocator _locator = components.GetLocator();\ + while (_locator.IsValid()) {\ + Component* component = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_COMPONENTS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/CompositeLayer.cpp b/hurricane/src/hurricane/CompositeLayer.cpp new file mode 100644 index 00000000..c4ed01f3 --- /dev/null +++ b/hurricane/src/hurricane/CompositeLayer.cpp @@ -0,0 +1,270 @@ +// **************************************************************************************************** +// File: CompositeLayer.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "CompositeLayer.h" +#include "Technology.h" +#include "BasicLayer.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// CompositeLayer implementation +// **************************************************************************************************** + +CompositeLayer::CompositeLayer(Technology* technology, const Name& name, const Type& type, const Unit& minimalSize, const Unit& minimalSpacing) +// **************************************************************************************************** +: Inherit(technology, name, minimalSize, minimalSpacing), + _type(type), + _basicLayerList(), + _contactSizeMap(), + _segmentSizeMap(), + _segmentExtentionMap(), + _padSizeMap(), + _maximalContactSize(0), + _maximalSegmentSize(0), + _maximalSegmentExtention(0), + _maximalPadSize(0), + _symbolicBasicLayer(NULL) +{ +} + +CompositeLayer* CompositeLayer::Create(Technology* technology, const Name& name, const Type& type, const Unit& minimalSize, const Unit& minimalSpacing) +// **************************************************************************************************** +{ + CompositeLayer* compositeLayer = + new CompositeLayer(technology, name, type, minimalSize, minimalSpacing); + + compositeLayer->_PostCreate(); + + return compositeLayer; +} + +BasicLayers CompositeLayer::GetBasicLayers() const +// *********************************************** +{ + return GetCollection(_basicLayerList); +} + +Unit CompositeLayer::GetContactSize(BasicLayer* basicLayer) const +// ************************************************************** +{ + SizeMap::const_iterator it = _contactSizeMap.find(basicLayer); + return ((it == _contactSizeMap.end()) ? 0 : (*it).second); +} + +Unit CompositeLayer::GetSegmentSize(BasicLayer* basicLayer) const +// ************************************************************** +{ + SizeMap::const_iterator it = _segmentSizeMap.find(basicLayer); + return ((it == _segmentSizeMap.end()) ? 0 : (*it).second); +} + +Unit CompositeLayer::GetSegmentExtention(BasicLayer* basicLayer) const +// ******************************************************************* +{ + SizeMap::const_iterator it = _segmentExtentionMap.find(basicLayer); + return ((it == _segmentExtentionMap.end()) ? 0 : (*it).second); +} + +Unit CompositeLayer::GetPadSize(BasicLayer* basicLayer) const +// ********************************************************** +{ + SizeMap::const_iterator it = _padSizeMap.find(basicLayer); + return ((it == _padSizeMap.end()) ? 0 : (*it).second); +} + +void CompositeLayer::Add(BasicLayer* basicLayer, const Unit& contactSize, const Unit& segmentSize, const Unit& segmentExtention, const Unit& padSize) +// **************************************************************************************************** +{ + if (!basicLayer) + throw Error("Can't add basic layer : null basic layer"); + + if (Contains(basicLayer)) + throw Error("Can't add basic layer : already done"); + + _basicLayerList.push_back(basicLayer); + + _SetMask(GetMask() | basicLayer->GetMask()); + _SetExtractMask(GetExtractMask() | basicLayer->GetExtractMask()); + + if (contactSize != 0) _contactSizeMap[basicLayer] = contactSize; + if (segmentSize != 0) _segmentSizeMap[basicLayer] = segmentSize; + if (segmentExtention != 0) _segmentExtentionMap[basicLayer] = segmentExtention; + if (padSize != 0) _padSizeMap[basicLayer] = padSize; + + _maximalContactSize = max(contactSize, _maximalContactSize); + _maximalSegmentSize = max(segmentSize, _maximalSegmentSize); + _maximalSegmentExtention = max(segmentExtention, _maximalSegmentExtention); + _maximalPadSize = max(padSize, _maximalPadSize); +} + +void CompositeLayer::Remove(BasicLayer* basicLayer) +// ************************************************ +{ + if (!basicLayer) + throw Error("Can't remove basic layer : null basic layer"); + + if (!Contains(basicLayer)) + throw Error("Can't remove basic layer : not contained"); + + _basicLayerList.remove(basicLayer); + + _contactSizeMap.erase(basicLayer); + _segmentSizeMap.erase(basicLayer); + _segmentExtentionMap.erase(basicLayer); + _padSizeMap.erase(basicLayer); + + _maximalContactSize = 0; + _maximalSegmentSize = 0; + _maximalSegmentExtention = 0; + _maximalPadSize = 0; + + Mask mask = 0; + Mask extractMask = 0; + + for_each_basic_layer(basicLayer, GetBasicLayers()) { + mask |= basicLayer->GetMask(); + extractMask |= basicLayer->GetExtractMask(); + _maximalContactSize = max(GetContactSize(basicLayer), _maximalContactSize); + _maximalSegmentSize = max(GetSegmentSize(basicLayer), _maximalSegmentSize); + _maximalSegmentExtention = max(GetSegmentExtention(basicLayer), _maximalSegmentExtention); + _maximalPadSize = max(GetPadSize(basicLayer), _maximalPadSize); + end_for; + } + + _SetMask(mask); + _SetExtractMask(extractMask); +} + +string CompositeLayer::_GetString() const +// ************************************** +{ + string s = Inherit::_GetString(); + /* + s.insert(s.length() - 1, " " + GetString(_type)); + s.insert(s.length() - 1, " {"); + string separator = ""; + for_each_basic_layer(basicLayer, GetBasicLayers()) { + s.insert(s.length() - 1, separator + GetString(basicLayer->GetName())); + separator = "|"; + end_for; + } + s.insert(s.length() - 1, "}"); + */ + return s; +} + +Record* CompositeLayer::_GetRecord() const +// *************************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Type", &_type)); + record->Add(GetSlot("BasicLayers", &_basicLayerList)); + record->Add(GetSlot("ContactSizes", &_contactSizeMap)); + record->Add(GetSlot("SegmentSizes", &_segmentSizeMap)); + record->Add(GetSlot("SegmentExtentions", &_segmentExtentionMap)); + record->Add(GetSlot("PadSizes", &_padSizeMap)); + record->Add(GetSlot("MaximalContactSize", &_maximalContactSize)); + record->Add(GetSlot("MaximalSegmentSize", &_maximalSegmentSize)); + record->Add(GetSlot("MaximalSegmentExtention", &_maximalSegmentExtention)); + record->Add(GetSlot("MaximalPadSize", &_maximalPadSize)); + } + return record; +} + +void CompositeLayer::_UpdateSymbolicBasicLayer(const Layer::Mask& visibleBasicLayersMask) +// ************************************************************************************** +{ + _symbolicBasicLayer = NULL; + BasicLayer* symbolicBasicLayer = NULL; + for_each_basic_layer(basicLayer, GetBasicLayers()) { + if (basicLayer->GetMask() & visibleBasicLayersMask) { + symbolicBasicLayer = basicLayer; + if (basicLayer->GetType() == BasicLayer::Type::CONTACT) + _symbolicBasicLayer = basicLayer; + } + end_for; + } + if (!_symbolicBasicLayer) _symbolicBasicLayer = symbolicBasicLayer; +} + +// **************************************************************************************************** +// CompositeLayer::Type implementation +// **************************************************************************************************** + +CompositeLayer::Type::Type(const Code& code) +// ***************************************** +: _code(code) +{ +} + +CompositeLayer::Type::Type(const Type& type) +// ***************************************** +: _code(type._code) +{ +} + +CompositeLayer::Type& CompositeLayer::Type::operator=(const Type& type) +// ******************************************************************** +{ + _code = type._code; + return *this; +} + +string CompositeLayer::Type::_GetString() const +// ******************************************** +{ + switch (_code) { + case UNDEFINED : return "UNDEFINED"; + case METAL : return "METAL"; + case VIA : return "VIA"; + } + return "ABNORMAL"; +} + +Record* CompositeLayer::Type::_GetRecord() const +// ********************************************* +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Code", (int)_code)); + return record; +} + + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +bool Scan(const string& s, H::CompositeLayer::Type& type) +// *************************************************** +{ + if (s == "UNDEFINED") { + type = H::CompositeLayer::Type::UNDEFINED; + return true; + } + if (s == "METAL") { + type = H::CompositeLayer::Type::METAL; + return true; + } + if (s == "VIA") { + type = H::CompositeLayer::Type::VIA; + return true; + } + return false; +} + + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/CompositeLayer.h b/hurricane/src/hurricane/CompositeLayer.h new file mode 100644 index 00000000..2dbd4f16 --- /dev/null +++ b/hurricane/src/hurricane/CompositeLayer.h @@ -0,0 +1,129 @@ +// **************************************************************************************************** +// File: CompositeLayer.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_COMPOSITE_LAYER +#define HURRICANE_COMPOSITE_LAYER + +#include "Layer.h" +#include "CompositeLayers.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// CompositeLayer declaration +// **************************************************************************************************** + +class CompositeLayer : public Layer { +// ******************************** + +// Types +// ***** + + public: typedef Layer Inherit; + + public: class Type { + // *************** + + public: enum Code {UNDEFINED=0, METAL=1, VIA=2}; + + private: Code _code; + + public: Type(const Code& code = UNDEFINED); + public: Type(const Type& type); + + public: Type& operator=(const Type& type); + + public: operator const Code&() const {return _code;}; + + public: const Code& GetCode() const {return _code;}; + + public: string _GetTypeName() const { return _TName("CompositeLayer::Type"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + }; + + public: typedef list BasicLayerList; + + public: typedef map SizeMap; + +// Attributes +// ********** + + private: Type _type; + private: BasicLayerList _basicLayerList; + private: SizeMap _contactSizeMap; + private: SizeMap _segmentSizeMap; + private: SizeMap _segmentExtentionMap; + private: SizeMap _padSizeMap; + private: Unit _maximalContactSize; + private: Unit _maximalSegmentSize; + private: Unit _maximalSegmentExtention; + private: Unit _maximalPadSize; + private: BasicLayer* _symbolicBasicLayer; + +// Constructors +// ************ + + protected: CompositeLayer(Technology* technology, const Name& name, const Type& type, const Unit& minimalSize = 0, const Unit& minimalSpacing = 0); + + public: static CompositeLayer* Create(Technology* technology, const Name& name, const Type& type, const Unit& minimalSize = 0, const Unit& minimalSpacing = 0); + +// Accessors +// ********* + + public: const Type& GetType() const {return _type;}; + public: virtual BasicLayers GetBasicLayers() const; + public: Unit GetContactSize(BasicLayer* basicLayer) const; + public: Unit GetSegmentSize(BasicLayer* basicLayer) const; + public: Unit GetSegmentExtention(BasicLayer* basicLayer) const; + public: Unit GetPadSize(BasicLayer* basicLayer) const; + public: const Unit& GetMaximalContactSize() const {return _maximalContactSize;}; + public: const Unit& GetMaximalSegmentSize() const {return _maximalSegmentSize;}; + public: const Unit& GetMaximalSegmentExtention() const {return _maximalSegmentExtention;}; + public: const Unit& GetMaximalPadSize() const {return _maximalPadSize;}; + +// Updators +// ******** + + public: void Add(BasicLayer* basicLayer, const Unit& contactSize, const Unit& segmentSize, const Unit& segmentExtention, const Unit& padSize); + public: void Remove(BasicLayer* basicLayer); + +// Others +// ****** + + public: virtual string _GetTypeName() const {return _TName("CompositeLayer");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: virtual BasicLayer* _GetSymbolicBasicLayer() {return _symbolicBasicLayer;}; + public: BasicLayerList& _GetBasicLayerList() {return _basicLayerList;}; + + public: void _UpdateSymbolicBasicLayer(const Layer::Mask& visibleBasicLayersMask); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::CompositeLayer) + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + + +bool Scan(const string& s, H::CompositeLayer::Type& type); + +#endif // HURRICANE_COMPOSITE_LAYER + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/CompositeLayers.h b/hurricane/src/hurricane/CompositeLayers.h new file mode 100644 index 00000000..25dd7a63 --- /dev/null +++ b/hurricane/src/hurricane/CompositeLayers.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: CompositeLayers.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_COMPOSITE_LAYERS +#define HURRICANE_COMPOSITE_LAYERS + +#include "Collection.h" + +namespace Hurricane { + +class CompositeLayer; + + + +// **************************************************************************************************** +// CompositeLayers declaration +// **************************************************************************************************** + +typedef GenericCollection CompositeLayers; + + + +// **************************************************************************************************** +// CompositeLayerLocator declaration +// **************************************************************************************************** + +typedef GenericLocator CompositeLayerLocator; + + + +// **************************************************************************************************** +// CompositeLayerFilter declaration +// **************************************************************************************************** + +typedef GenericFilter CompositeLayerFilter; + + + +// **************************************************************************************************** +// for_each_composite_layer declaration +// **************************************************************************************************** + +#define for_each_composite_layer(compositeLayer, compositeLayers)\ +/****************************************************************/\ +{\ + CompositeLayerLocator _locator = compositeLayers.GetLocator();\ + while (_locator.IsValid()) {\ + CompositeLayer* compositeLayer = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_COMPOSITE_LAYERS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Contact.cpp b/hurricane/src/hurricane/Contact.cpp new file mode 100644 index 00000000..187ffe27 --- /dev/null +++ b/hurricane/src/hurricane/Contact.cpp @@ -0,0 +1,575 @@ +// **************************************************************************************************** +// File: Contact.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Contact.h" +#include "Net.h" +#include "BasicLayer.h" +#include "CompositeLayer.h" +#include "Plug.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Contact_Hooks declaration +// **************************************************************************************************** + +class Contact_Hooks : public Collection { +// ******************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ***************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Contact* _contact; + private: Hook* _hook; + + public: Locator(const Contact* contact = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Hook* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Contact* _contact; + +// Constructors +// ************ + + public: Contact_Hooks(const Contact* contact = NULL); + public: Contact_Hooks(const Contact_Hooks& hooks); + +// Operators +// ********* + + public: Contact_Hooks& operator=(const Contact_Hooks& hooks); + +// Accessors +// ********^ + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Contact implementation +// **************************************************************************************************** + +Contact::Contact(Net* net, Layer* layer, const Unit& x, const Unit& y, const Unit& width, const Unit& height) +// **************************************************************************************************** +: Inherit(net), + _anchorHook(this), + _layer(layer), + _dx(x), + _dy(y), + _width(width), + _height(height) +{ + if (!_layer) + throw Error("Can't create " + _TName("Contact") + " : null layer"); +} + +Contact::Contact(Net* net, Component* anchor, Layer* layer, const Unit& dx, const Unit& dy, const Unit& width, const Unit& height) +// **************************************************************************************************** +: Inherit(net), + _anchorHook(this), + _layer(layer), + _dx(dx), + _dy(dy), + _width(width), + _height(height) +{ + if (!anchor) + throw Error("Can't create " + _TName("Contact") + " : null anchor"); + + if (!anchor->GetNet()) + throw Error("Can't create " + _TName("Contact") + " : unconnected anchor"); + + if (anchor->GetNet() != GetNet()) + throw Error("Can't create " + _TName("Contact") + " : incompatible anchor"); + + if (!_layer) + throw Error("Can't create " + _TName("Contact") + " : null layer"); + + _anchorHook.Attach(anchor->GetBodyHook()); +} + +Contact* Contact::Create(Net* net, Layer* layer, const Unit& x, const Unit& y, const Unit& width, const Unit& height) +// **************************************************************************************************** +{ + Contact* contact = new Contact(net, layer, x, y, width, height); + + contact->_PostCreate(); + + return contact; +} + +Contact* Contact::Create(Component* anchor, Layer* layer, const Unit& dx, const Unit& dy, const Unit& width, const Unit& height) +// **************************************************************************************************** +{ + if (!anchor) + throw Error("Can't create " + _TName("Contact") + " : null anchor"); + + Contact* contact = new Contact(anchor->GetNet(), anchor, layer, dx, dy, width, height); + + contact->_PostCreate(); + + return contact; +} + +Hooks Contact::GetHooks() const +// **************************** +{ + return Contact_Hooks(this); +} + +Unit Contact::GetX() const +// *********************** +{ + Component* anchor = GetAnchor(); + return (!anchor) ? _dx : anchor->GetX() + _dx; +} + +Unit Contact::GetY() const +// *********************** +{ + Component* anchor = GetAnchor(); + return (!anchor) ? _dy : anchor->GetY() + _dy; +} + +Point Contact::GetPosition() const +// ******************************* +{ + Component* anchor = GetAnchor(); + return (!anchor) ? Point(_dx, _dy) : anchor->GetPosition().Translate(_dx, _dy); +} + +Box Contact::GetBoundingBox() const +// ******************************** +{ + Unit size = _GetSize(); + + return Box(GetPosition()).Inflate(GetHalfWidth() + size, GetHalfHeight() + size); +} + +Box Contact::GetBoundingBox(BasicLayer* basicLayer) const +// ****************************************************** +{ + if (!_layer->Contains(basicLayer)) return Box(); + + Unit size = _GetSize(basicLayer); + + return Box(GetPosition()).Inflate(GetHalfWidth() + size, GetHalfHeight() + size); +} + +Component* Contact::GetAnchor() const +// ********************************** +{ + Hook* masterHook = _anchorHook.GetMasterHook(); + return (masterHook) ? masterHook->GetComponent() : NULL; +} + +void Contact::Translate(const Unit& dx, const Unit& dy) +// **************************************************** +{ + if ((dx != 0) || (dy != 0)) { + Invalidate(true); + _dx += dx; + _dy += dy; + } +} + +void Contact::SetLayer(Layer* layer) +// ********************************* +{ + if (!layer) + throw Error("Can't set layer : null layer"); + + if (layer != _layer) { + Invalidate(false); + _layer = layer; + } +} + +void Contact::SetWidth(const Unit& width) +// ************************************** +{ + if (width != _width) { + Invalidate(false); + _width = width; + } +} + +void Contact::SetHeight(const Unit& height) +// **************************************** +{ + if (height != _height) { + Invalidate(false); + _height = height; + } +} + +void Contact::SetSizes(const Unit& width, const Unit& height) +// ********************************************************** +{ + if ((width != _width) || (height != _height)) { + Invalidate(false); + _width = width; + _height = height; + } +} + +void Contact::SetX(const Unit& x) +// ****************************** +{ + SetPosition(x, GetY()); +} + +void Contact::SetY(const Unit& y) +// ****************************** +{ + SetPosition(GetX(), y); +} + +void Contact::SetPosition(const Unit& x, const Unit& y) +// **************************************************** +{ + Component* anchor = GetAnchor(); + if (!anchor) + SetOffset(x, y); + else + SetOffset(x - anchor->GetX(), y - anchor->GetY()); +} + +void Contact::SetPosition(const Point& position) +// ********************************************* +{ + SetPosition(position.GetX(), position.GetY()); +} + +void Contact::SetDx(const Unit& dx) +// ******************************** +{ + SetOffset(dx, _dy); +} + +void Contact::SetDy(const Unit& dy) +// ******************************** +{ + SetOffset(_dx, dy); +} + +void Contact::SetOffset(const Unit& dx, const Unit& dy) +// **************************************************** +{ + if ((dx != _dx) || (dy != _dy)) { + Invalidate(true); + _dx = dx; + _dy = dy; + } +} + +void Contact::_PreDelete() +// *********************** +{ +// trace << "entering Contact::PreDelete: " << this << endl; +// trace_in(); + + Inherit::_PreDelete(); + + _anchorHook.Detach(); + +// trace << "exiting Contact::PreDelete:" << endl; +// trace_out(); +} + +string Contact::_GetString() const +// ******************************* +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_layer->GetName())); + s.insert(s.length() - 1, " [" + GetValueString(GetX())); + s.insert(s.length() - 1, " " + GetValueString(GetY())); + s.insert(s.length() - 1, "] " + GetValueString(_width)); + s.insert(s.length() - 1, "x" + GetValueString(_height)); + return s; +} + +Record* Contact::_GetRecord() const +// ************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("AnchorHook", &_anchorHook)); + record->Add(GetSlot("Anchor", GetAnchor())); + record->Add(GetSlot("Layer", _layer)); + record->Add(GetSlot("Dx", &_dx)); + record->Add(GetSlot("Dy", &_dy)); + record->Add(GetSlot("Width", &_width)); + record->Add(GetSlot("Height", &_height)); + } + return record; +} + +Unit Contact::_GetSize() const +// *************************** +{ + Unit size = 0; + + Layer* layer = GetLayer(); + if (is_a(layer)) + size = ((CompositeLayer*)layer)->GetMaximalContactSize(); + + return size; +} + +Unit Contact::_GetSize(BasicLayer* basicLayer) const +// ************************************************* +{ + Layer* layer = GetLayer(); + + if (!layer->Contains(basicLayer)) return 0; + + Unit size = 0; + + if (is_a(layer)) + size = ((CompositeLayer*)layer)->GetContactSize(basicLayer); + + return size; +} + +//void Contact::_Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) +//// **************************************************************************************************** +//{ +// if (_width && _height) { +// if (1 < view->GetScreenSize(max(_width, _height))) +// basicLayer->_Fill(view, transformation.GetBox(GetBoundingBox(basicLayer))); +// } +// if (basicLayer == _layer->_GetSymbolicBasicLayer()) { +// if (view->CutPointsAreVisible() && (3 < view->GetScale())) { +// Point position = GetPosition(); +// view->DrawPoint(transformation.GetPoint(position), 3); +// if (_width) { +// Box box = transformation.GetBox(Box(position).Inflate(GetHalfWidth(), 0)); +// view->DrawLine(box.GetXMin(), box.GetYMin(), box.GetXMax(), box.GetYMax()); +// } +// if (_height) { +// Box box = transformation.GetBox(Box(position).Inflate(0, GetHalfHeight())); +// view->DrawLine(box.GetXMin(), box.GetYMin(), box.GetXMax(), box.GetYMax()); +// } +// } +// } +//} +// +//void Contact::_Highlight(View* view, const Box& updateArea, const Transformation& transformation) +//// ********************************************************************************************** +//{ +// if (_width && _height) { +// if (1 < view->GetScreenSize(max(_width, _height))) { +// for_each_basic_layer(basicLayer, GetLayer()->GetBasicLayers()) { +// basicLayer->_Fill(view, transformation.GetBox(GetBoundingBox(basicLayer))); +// end_for; +// } +// } +// } +// if (view->GetScale() <= 1) +// view->DrawPoint(transformation.GetPoint(GetPosition()), 1); +// else if (view->GetScale() <= 3) +// view->DrawPoint(transformation.GetPoint(GetPosition()), 2); +// else { +// Point position = GetPosition(); +// view->DrawPoint(transformation.GetPoint(position), 3); +// if (_width) { +// Box box = transformation.GetBox(Box(position).Inflate(GetHalfWidth(), 0)); +// view->DrawLine(box.GetXMin(), box.GetYMin(), box.GetXMax(), box.GetYMax()); +// } +// if (_height) { +// Box box = transformation.GetBox(Box(position).Inflate(0, GetHalfHeight())); +// view->DrawLine(box.GetXMin(), box.GetYMin(), box.GetXMax(), box.GetYMax()); +// } +// } +//} +// + +// **************************************************************************************************** +// Contact::AnchorHook implementation +// **************************************************************************************************** + +static int ANCHOR_HOOK_OFFSET = -1; + +Contact::AnchorHook::AnchorHook(Contact* contact) +// ********************************************** +: Inherit() +{ + if (!contact) + throw Error("Can't create " + _TName("Contact::AnchorHook") + " : null contact"); + + if (ANCHOR_HOOK_OFFSET == -1) + ANCHOR_HOOK_OFFSET = (unsigned long)this - (unsigned long)contact; +} + +Component* Contact::AnchorHook::GetComponent() const +// ************************************************* +{ + return (Component*)((unsigned long)this - ANCHOR_HOOK_OFFSET); +} + +string Contact::AnchorHook::_GetString() const +// ******************************************* +{ + return "<" + _TName("Contact::AnchorHook") + " " + GetString(GetComponent()) + ">"; +} + + + +// **************************************************************************************************** +// Contact_Hooks implementation +// **************************************************************************************************** + +Contact_Hooks::Contact_Hooks(const Contact* contact) +// ************************************************* +: Inherit(), + _contact(contact) +{ +} + +Contact_Hooks::Contact_Hooks(const Contact_Hooks& hooks) +// ***************************************************** +: Inherit(), + _contact(hooks._contact) +{ +} + +Contact_Hooks& Contact_Hooks::operator=(const Contact_Hooks& hooks) +// **************************************************************** +{ + _contact = hooks._contact; + return *this; +} + +Collection* Contact_Hooks::GetClone() const +// *********************************************** +{ + return new Contact_Hooks(*this); +} + +Locator* Contact_Hooks::GetLocator() const +// ********************************************** +{ + return new Locator(_contact); +} + +string Contact_Hooks::_GetString() const +// ************************************* +{ + string s = "<" + _TName("Contact::Hooks"); + if (_contact) s += " " + GetString(_contact); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Contact_Hooks::Locator implementation +// **************************************************************************************************** + +Contact_Hooks::Locator::Locator(const Contact* contact) +// **************************************************** +: Inherit(), + _contact(contact), + _hook(NULL) +{ + if (_contact) _hook = ((Contact*)_contact)->GetBodyHook(); +} + +Contact_Hooks::Locator::Locator(const Locator& locator) +// **************************************************** +: Inherit(), + _contact(locator._contact), + _hook(locator._hook) +{ +} + +Contact_Hooks::Locator& Contact_Hooks::Locator::operator=(const Locator& locator) +// ****************************************************************************** +{ + _contact = locator._contact; + _hook = locator._hook; + return *this; +} + +Hook* Contact_Hooks::Locator::GetElement() const +// ********************************************* +{ + return _hook; +} + +Locator* Contact_Hooks::Locator::GetClone() const +// ***************************************************** +{ + return new Locator(*this); +} + +bool Contact_Hooks::Locator::IsValid() const +// ***************************************** +{ + return (_hook != NULL); +} + +void Contact_Hooks::Locator::Progress() +// ************************************ +{ + if (_hook) { + if (_hook == ((Contact*)_contact)->GetBodyHook()) + _hook = ((Contact*)_contact)->GetAnchorHook(); + else + _hook = NULL; + } +} + +string Contact_Hooks::Locator::_GetString() const +// ********************************************** +{ + string s = "<" + _TName("Contact::Hooks::Locator"); + if (_contact) s += " " + GetString(_contact); + s += ">"; + return s; +} + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Contact.h b/hurricane/src/hurricane/Contact.h new file mode 100644 index 00000000..d53e9917 --- /dev/null +++ b/hurricane/src/hurricane/Contact.h @@ -0,0 +1,128 @@ +// **************************************************************************************************** +// File: Contact.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_CONTACT +#define HURRICANE_CONTACT + +#include "Component.h" +#include "Contacts.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Contact declaration +// **************************************************************************************************** + +class Contact : public Component { +// ***************************** + +// Types +// ***** + + public: typedef Component Inherit; + + public: class AnchorHook : public Hook { + // *********************************** + + friend class Contact; + + public: typedef Hook Inherit; + + private: AnchorHook(Contact* contact); + + public: virtual Component* GetComponent() const; + + public: virtual bool IsMaster() const {return false;}; + + public: virtual string _GetTypeName() const { return _TName("Contact::AnchorHook"); }; + public: virtual string _GetString() const; + }; + +// Attributes +// ********** + + private: AnchorHook _anchorHook; + private: Layer* _layer; + private: Unit _dx; + private: Unit _dy; + protected: Unit _width; + protected: Unit _height; + +// Constructors +// ************ + + protected: Contact(Net* net, Layer* layer, const Unit& x, const Unit& y, const Unit& width = 0, const Unit& height = 0); + protected: Contact(Net* net, Component* anchor, Layer* layer, const Unit& dx, const Unit& dy, const Unit& width = 0, const Unit& height = 0); + + public: static Contact* Create(Net* net, Layer* layer, const Unit& x, const Unit& y, const Unit& width = 0, const Unit& height = 0); + public: static Contact* Create(Component* anchor, Layer* layer, const Unit& dx, const Unit& dy, const Unit& width = 0, const Unit& height = 0); + +// Accessors +// ********* + + public: virtual Hooks GetHooks() const; + public: virtual Unit GetX() const; + public: virtual Unit GetY() const; + public: virtual Point GetPosition() const; + public: virtual Box GetBoundingBox() const; + public: virtual Layer* GetLayer() const {return _layer;}; + public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const; + public: Hook* GetAnchorHook() {return &_anchorHook;}; + public: Component* GetAnchor() const; + public: const Unit& GetDx() const {return _dx;}; + public: const Unit& GetDy() const {return _dy;}; + public: const Unit& GetWidth() const {return _width;}; + public: Unit GetHalfWidth() const {return (_width / 2);}; + public: const Unit& GetHeight() const {return _height;}; + public: Unit GetHalfHeight() const {return (_height / 2);}; + +// Updators +// ******** + + public: virtual void Translate(const Unit& dx, const Unit& dy); + + public: void SetLayer(Layer* layer); + public: void SetWidth(const Unit& width); + public: void SetHeight(const Unit& height); + public: void SetSizes(const Unit& width, const Unit& height); + public: void SetX(const Unit& x); + public: void SetY(const Unit& y); + public: void SetPosition(const Unit& x, const Unit& y); + public: void SetPosition(const Point& position); + public: void SetDx(const Unit& dx); + public: void SetDy(const Unit& dy); + public: void SetOffset(const Unit& dx, const Unit& dy); + +// Others +// ****** + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("Contact");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: Unit _GetSize() const; + public: Unit _GetSize(BasicLayer* basicLayer) const; + + //public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation); + //public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Contact) + +#endif // HURRICANE_CONTACT + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Contacts.h b/hurricane/src/hurricane/Contacts.h new file mode 100644 index 00000000..a242cf58 --- /dev/null +++ b/hurricane/src/hurricane/Contacts.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Contacts.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_CONTACTS +#define HURRICANE_CONTACTS + +#include "Collection.h" + +namespace Hurricane { + +class Contact; + + + +// **************************************************************************************************** +// Contacts declaration +// **************************************************************************************************** + +typedef GenericCollection Contacts; + + + +// **************************************************************************************************** +// ContactLocator declaration +// **************************************************************************************************** + +typedef GenericLocator ContactLocator; + + + +// **************************************************************************************************** +// ContactFilter declaration +// **************************************************************************************************** + +typedef GenericFilter ContactFilter; + + + +// **************************************************************************************************** +// for_each_contact declaration +// **************************************************************************************************** + +#define for_each_contact(contact, contacts)\ +/******************************************/\ +{\ + ContactLocator _locator = contacts.GetLocator();\ + while (_locator.IsValid()) {\ + Contact* contact = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_CONTACTS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/DBo.cpp b/hurricane/src/hurricane/DBo.cpp new file mode 100644 index 00000000..29b986de --- /dev/null +++ b/hurricane/src/hurricane/DBo.cpp @@ -0,0 +1,162 @@ +// **************************************************************************************************** +// File: DBo.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "DBo.h" +#include "Property.h" +#include "Quark.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// DBo implementation +// **************************************************************************************************** + +DBo::DBo() +// ******* +: _propertySet() +{ +} + +DBo::~DBo() +// ******** +{ +} + +void DBo::Delete() +// *************** +{ +// trace << "entering DBo::Delete: " << this << endl; +// trace_in(); + + _PreDelete(); + + delete this; + +// trace << "exiting DBo::Delete:" << endl; +// trace_out(); +} + +Property* DBo::GetProperty(const Name& name) const +// *********************************************** +{ + PropertySet::const_iterator iterator = _propertySet.begin(); + while (iterator != _propertySet.end()) { + Property* property = *iterator; + if (property->GetName() == name) return property; + ++iterator; + } + return NULL; +} + +void DBo::Put(Property* property) +// ****************************** +{ + if (!property) + throw Error("Can't put property : null property"); + + Property* oldProperty = GetProperty(property->GetName()); + if (property != oldProperty) { + if (oldProperty) { + _propertySet.erase(oldProperty); + oldProperty->OnReleasedBy(this); + } + _propertySet.insert(property); + property->OnCapturedBy(this); + } +} + +void DBo::Remove(Property* property) +// ********************************* +{ + if (!property) + throw Error("Can't remove property : null property"); + + if (_propertySet.find(property) != _propertySet.end()) { + _propertySet.erase(property); + property->OnReleasedBy(this); + if (is_a(this) && _propertySet.empty()) Delete(); + } +} + +void DBo::RemoveProperty(const Name& name) +// *************************************** +{ + Property* property = GetProperty(name); + if (property) { + _propertySet.erase(property); + property->OnReleasedBy(this); + if (is_a(this) && _propertySet.empty()) Delete(); + } +} + +void DBo::ClearProperties() +// ************************ +{ +// trace << "entering DBo::ClearProperties: " << this << endl; +// trace_in(); + + while (!_propertySet.empty()) { + Property* property = *_propertySet.begin(); +// trace << property << endl; + _propertySet.erase(property); + property->OnReleasedBy(this); + } + +// trace << "exiting DBo::ClearProperties:" << endl; +// trace_out(); +} + +void DBo::_PostCreate() +// ******************** +{ +} + +void DBo::_PreDelete() +// ******************* +{ +// trace << "entering DBo::_PreDelete: " << this << endl; +// trace_in(); + + ClearProperties(); + + +// trace << "exiting DBo::_PreDelete:" << endl; +// trace_out(); +} + +string DBo::_GetString() const +// *************************** +{ + return "<" + _GetTypeName() + ">"; +} + +Record* DBo::_GetRecord() const +// ********************** +{ + Record* record = new Record(GetString(this)); + if (record) { + record->Add(GetSlot("Properties", &_propertySet)); + } + return record; +} + +void DBo::_OnDeleted(Property* property) +// ************************************* +{ + if (property && (_propertySet.find(property) != _propertySet.end())) { + _propertySet.erase(property); + if (is_a(this) && _propertySet.empty()) Delete(); + } +} + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/DBo.h b/hurricane/src/hurricane/DBo.h new file mode 100644 index 00000000..b29c997e --- /dev/null +++ b/hurricane/src/hurricane/DBo.h @@ -0,0 +1,107 @@ +// **************************************************************************************************** +// File: DBo.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_DBO +#define HURRICANE_DBO + +#include "DBos.h" +#include "Name.h" +#include "Property.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// DBo declaration +// **************************************************************************************************** + +class DBo : public NestedSlotAdapter { +// ********************************* + +# if !defined(__DOXYGEN_PROCESSOR__) + +// Types +// ***** + + public: typedef set PropertySet; + +// Attributs +// ********* + + private: PropertySet _propertySet; + +// Constructors +// ************ + + protected: DBo(); + + private: DBo(const DBo& dbo); // not implemented to forbid copy construction + +// Destructors +// *********** + + protected: virtual ~DBo(); + +// Operators +// ********* + + private: DBo& operator=(const DBo& dbo); // not implemented to forbid assignment + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const = 0; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: PropertySet& _GetPropertySet() {return _propertySet;}; + + public: void _OnDeleted(Property* property); + +# endif + +// Destructors +// *********** + + public: virtual void Delete(); + +// Accessors +// ********* + + public: Property* GetProperty(const Name& name) const; + public: Properties GetProperties() const {return GetCollection(_propertySet);}; + +// Predicates +// ********** + + public: bool HasProperty() const {return !_propertySet.empty();}; + +// Updators +// ******** + + public: void Put(Property* property); + public: void Remove(Property* property); + public: void RemoveProperty(const Name& name); + public: void ClearProperties(); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::DBo) +PointerIOStreamSupport(Hurricane::DBo) + +#endif // HURRICANE_DBO + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/DBos.h b/hurricane/src/hurricane/DBos.h new file mode 100644 index 00000000..8ec4acf8 --- /dev/null +++ b/hurricane/src/hurricane/DBos.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: DBos.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_DBOS +#define HURRICANE_DBOS + +#include "Collection.h" + +namespace Hurricane { + +class DBo; + + + +// **************************************************************************************************** +// DBos declaration +// **************************************************************************************************** + +typedef GenericCollection DBos; + + + +// **************************************************************************************************** +// DBoLocator declaration +// **************************************************************************************************** + +typedef GenericLocator DBoLocator; + + + +// **************************************************************************************************** +// DBoFilter declaration +// **************************************************************************************************** + +typedef GenericFilter DBoFilter; + + + +// **************************************************************************************************** +// for_each_dbo declaration +// **************************************************************************************************** + +#define for_each_dbo(dbo, dbos)\ +/******************************/\ +{\ + DBoLocator _locator = dbos.GetLocator();\ + while (_locator.IsValid()) {\ + DBo* dbo = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_DBOS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/DRCError.cpp b/hurricane/src/hurricane/DRCError.cpp new file mode 100644 index 00000000..9129ec11 --- /dev/null +++ b/hurricane/src/hurricane/DRCError.cpp @@ -0,0 +1,94 @@ +// **************************************************************************************************** +// File: DRCError.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "DRCError.h" +#include "Cell.h" +#include "Slice.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// DRCError implementation +// **************************************************************************************************** + +DRCError::DRCError(Cell* cell, const Name& name, const Box& boundingBox) +// ********************************************************************* +: Inherit(cell), + _name(name), + _boundingBox(boundingBox) +{ + if (_name.IsEmpty()) + throw Error("Can't create " + _TName("DRCError") + " : empty name"); + + if (_boundingBox.IsEmpty()) + throw Error("Can't create " + _TName("DRCError") + " : empty bounding box"); +} + +DRCError* DRCError::Create(Cell* cell, const Name& name, const Box& boundingBox) +// ***************************************************************************** +{ + DRCError* drcError = new DRCError(cell, name, boundingBox); + + drcError->_PostCreate(); + + return drcError; +} + +void DRCError::Translate(const Unit& dx, const Unit& dy) +// ***************************************************** +{ + if ((dx != 0) || (dy != 0)) { + Invalidate(false); + _boundingBox.Translate(dx, dy); + } +} + +string DRCError::_GetString() const +// ******************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_name)); + s.insert(s.length() - 1, " " + GetString(_boundingBox)); + return s; +} + +Record* DRCError::_GetRecord() const +// *************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("BoundingBox", &_boundingBox)); + } + return record; +} + +//bool DRCError::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +//// **************************************************************************************** +//{ +// return GetBoundingBox().Intersect(Box(point).Inflate(aperture)); +//} +// +//void DRCError::_Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) +//// **************************************************************************************************** +//{ +// assert(!basicLayer); +// +// view->DrawRectangle(transformation.GetBox(GetBoundingBox())); +//} +// +//void DRCError::_Highlight(View* view, const Box& updateArea, const Transformation& transformation) +//// ********************************************************************************************** +//{ +// view->FillRectangle(transformation.GetBox(GetBoundingBox())); +//} +// + + +} // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/DRCError.h b/hurricane/src/hurricane/DRCError.h new file mode 100644 index 00000000..e36549a9 --- /dev/null +++ b/hurricane/src/hurricane/DRCError.h @@ -0,0 +1,72 @@ +// **************************************************************************************************** +// File: DRCError.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_DRCERROR +#define HURRICANE_DRCERROR + +#include "Marker.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// DRCError declaration +// **************************************************************************************************** + +class DRCError : public Marker { +// ***************************** + +// Types +// ***** + + public: typedef Marker Inherit; + +// Attributes +// ********** + + public: Name _name; + public: Box _boundingBox; + +// Constructors +// ************ + + protected: DRCError(Cell* cell, const Name& name, const Box& boundingBox); + + public: static DRCError* Create(Cell* cell, const Name& name, const Box& boundingBox); + +// Accessors +// ********* + + public: virtual Box GetBoundingBox() const {return _boundingBox;}; + public: const Name& GetName() const {return _name;}; + +// Updators +// ******** + + public: virtual void Translate(const Unit& dx, const Unit& dy); + +// Others +// ****** + + public: virtual string _GetTypeName() const {return _TName("DRCError");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + +// public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; +// public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation); +// public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation); +// +}; + + +} // End of Hurricane namespace. + +#endif // HURRICANE_DRCERROR + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/DataBase.cpp b/hurricane/src/hurricane/DataBase.cpp new file mode 100644 index 00000000..fb35e1b1 --- /dev/null +++ b/hurricane/src/hurricane/DataBase.cpp @@ -0,0 +1,102 @@ +// **************************************************************************************************** +// File: DataBase.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "DataBase.h" +#include "Technology.h" +#include "Library.h" +#include "Cell.h" +#include "Timer.h" +#include "Error.h" +#include "UpdateSession.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// DataBase implementation +// **************************************************************************************************** + +static DataBase* DATA_BASE = NULL; + +DataBase::DataBase() +// ***************** +: Inherit(), + _technology(NULL), + _rootLibrary(NULL) +{ + if (DATA_BASE) + throw Error("Can't create " + _TName("DataBase") + " : already exists"); +} + +DataBase* DataBase::Create() +// ************************* +{ + DataBase* dataBase = new DataBase(); + + dataBase->_PostCreate(); + + return dataBase; +} + +void DataBase::_PostCreate() +// ************************* +{ + Inherit::_PostCreate(); + + DATA_BASE = this; +} + +void DataBase::_PreDelete() +// ************************ +{ + OpenUpdateSession(); + Inherit::_PreDelete(); + + if (_rootLibrary) _rootLibrary->Delete(); + if (_technology) _technology->Delete(); + CloseUpdateSession (); + + DATA_BASE = NULL; +} + +string DataBase::_GetString() const +// ******************************** +{ + return Inherit::_GetString(); +} + +Record* DataBase::_GetRecord() const +// *************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Technology", _technology)); + record->Add(GetSlot("RootLibrary", _rootLibrary)); + record->Add(GetSlot("Precision", GetPrecision())); + record->Add(GetSlot("Resolution", GetValueString(1))); + record->Add(GetSlot("GridStep", GetValueString(GetGridStep()))); + } + return record; +} + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +DataBase* GetDataBase() +// ******************** +{ + return DATA_BASE; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/DataBase.h b/hurricane/src/hurricane/DataBase.h new file mode 100644 index 00000000..b652f0ef --- /dev/null +++ b/hurricane/src/hurricane/DataBase.h @@ -0,0 +1,89 @@ +// **************************************************************************************************** +// File: DataBase.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_DATA_BASE +#define HURRICANE_DATA_BASE + +#include "DBo.h" +#include "Unit.h" + +namespace Hurricane { + +class Library; +class Technology; + + + +// **************************************************************************************************** +// DataBase declaration +// **************************************************************************************************** + +class DataBase : public DBo { +// ************************ + +# if !defined(__DOXYGEN_PROCESSOR__) + +// Types +// ***** + + public: typedef DBo Inherit; + +// Attributes +// ********** + + private: Technology* _technology; + private: Library* _rootLibrary; + +// Constructors +// ************ + + protected: DataBase(); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("DataBase");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: void _SetTechnology(Technology* technology) {_technology = technology;}; + public: void _SetRootLibrary(Library* rootLibrary) {_rootLibrary = rootLibrary;}; + +# endif + + public: static DataBase* Create(); + +// Accessors +// ********* + + public: Technology* GetTechnology() const {return _technology;}; + public: Library* GetRootLibrary() const {return _rootLibrary;}; + +}; + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +DataBase* GetDataBase(); + + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::DataBase) + +#endif // HURRICANE_DATA_BASE + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/DeepNet.cpp b/hurricane/src/hurricane/DeepNet.cpp new file mode 100644 index 00000000..e573fad3 --- /dev/null +++ b/hurricane/src/hurricane/DeepNet.cpp @@ -0,0 +1,175 @@ + + +// -*- C++ -*- +// +// This file is part of the Coriolis Project. +// Copyright (C) Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie +// +// Main contributors : +// Christophe Alexandre +// Hugo Clément +// Jean-Paul Chaput +// Christian Masson +// +// The Coriolis Project is free software; you can redistribute it +// and/or modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// The Coriolis Project is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with the Coriolis Project; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA +// +// License-Tag +// Authors-Tag +// =================================================================== +// +// $Id: DeepNet.cpp,v 1.3 2007/06/27 21:13:25 jpc Exp $ +// +// x-----------------------------------------------------------------x +// | | +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Header : "./DeepNet.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + + + +# include "DeepNet.h" +# include "Cell.h" +# include "Instance.h" +# include "Plug.h" +# include "RoutingPad.h" +# include "Pin.h" +# include "Contact.h" +# include "Vertical.h" +# include "Horizontal.h" +# include "Pad.h" +# include "UpdateSession.h" +# include "Error.h" + + +namespace Hurricane { + +namespace { + + + using namespace std; + using namespace Hurricane; + + + + +# if !defined(__DOXYGEN_PROCESSOR__) + + +# endif + + +} // End of local namespace. + + +// x-----------------------------------------------------------------x +// | "::DeepNet" Class Definitions | +// x-----------------------------------------------------------------x + + +# if !defined(__DOXYGEN_PROCESSOR__) + + +// ------------------------------------------------------------------- +// Constructor : "DeepNet::DeepNet ()". + +DeepNet::DeepNet ( Occurrence& netOccurrence ) + : Net(netOccurrence.GetOwnerCell() + ,netOccurrence.GetName() + ) + , _netOccurrence(netOccurrence) +{ +} + + + + +// ------------------------------------------------------------------- +// Inspector Management : "DeepNet::_GetRecord ()". + +Record* DeepNet::_GetRecord () const +{ + Record* record = Net::_GetRecord(); + if (record) { + record->Add(GetSlot("_netOccurrence", &_netOccurrence)); + } + return record; +} + + +# endif + + +// ------------------------------------------------------------------- +// Constructor : "DeepNet::Create ()". + +DeepNet* DeepNet::Create ( HyperNet& hyperNet ) +{ + if ( !hyperNet.IsValid() ) + throw Error ( "Can't create " + _TName("DeepNet") + ": occurence is invalid." ); + + Occurrence rootNetOccurrence = GetHyperNetRootNetOccurrence ( hyperNet.GetNetOccurrence() ); + + if ( rootNetOccurrence.GetMasterCell()->IsFlattenLeaf() ) return NULL; + if ( rootNetOccurrence.GetPath().IsEmpty() ) return NULL; + + DeepNet* deepNet = new DeepNet ( rootNetOccurrence ); + deepNet->_PostCreate (); + + return deepNet; +} + + + + +// ------------------------------------------------------------------- +// Internal Modifier : "DeepNet::_CreateRoutingPads ()". + +size_t DeepNet::_CreateRoutingPads ( bool buildRings ) +{ + size_t nbRoutingPads = 0; + HyperNet hyperNet ( _netOccurrence ); + + RoutingPad* previousRP = NULL; + RoutingPad* currentRP = NULL; + for_each_occurrence ( plugOccurrence, hyperNet.GetLeafPlugOccurrences() ) { + nbRoutingPads++; + + currentRP = CreateRoutingPad ( this, plugOccurrence ); + if ( buildRings ) { + if ( previousRP ) { + currentRP->GetBodyHook()->Attach ( previousRP->GetBodyHook() ); + } + previousRP = currentRP; + } + + end_for + } + + return nbRoutingPads; +} + + +} // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/DeepNet.h b/hurricane/src/hurricane/DeepNet.h new file mode 100644 index 00000000..8a3c5bb0 --- /dev/null +++ b/hurricane/src/hurricane/DeepNet.h @@ -0,0 +1,108 @@ + + +// -*- C++ -*- +// +// This file is part of the Coriolis Project. +// Copyright (C) Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie +// +// Main contributors : +// Christophe Alexandre +// Hugo Clément +// Jean-Paul Chaput +// Christian Masson +// +// The Coriolis Project is free software; you can redistribute it +// and/or modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// The Coriolis Project is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with the Coriolis Project; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA +// +// License-Tag +// Authors-Tag +// =================================================================== +// +// $Id: DeepNet.h,v 1.3 2007/06/27 21:13:25 jpc Exp $ +// +// x-----------------------------------------------------------------x +// | | +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Header : "./DeepNet.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + + + +# ifndef __HURRICANE_DEEPNET__ +# define __HURRICANE_DEEPNET__ + +# include "Net.h" +# include "HyperNet.h" +# include "Occurrence.h" + + + + +namespace Hurricane { + + + class DeepNet : public Net { + +# if !defined(__DOXYGEN_PROCESSOR__) + + // Attributes. + protected: + Occurrence _netOccurrence; + + // Constructors. + protected: + DeepNet ( Occurrence& netOccurrence ); + + // Inspector Management. + public: + virtual Record* _GetRecord () const; + virtual string _GetTypeName() const { return "DeepNet"; }; + +# endif + + // Constructors. + public: + static DeepNet* Create ( HyperNet& hyperNet ); + + // Accessors. + public: + + // Predicates. + public: + virtual bool IsDeepNet () const { return true; }; + + // Internal Modifiers. + public: + size_t _CreateRoutingPads ( bool buildRings=false ); + +}; + + +} // End of Hurricane namespace. + + + + +# endif diff --git a/hurricane/src/hurricane/DisplaySlot.cpp b/hurricane/src/hurricane/DisplaySlot.cpp new file mode 100644 index 00000000..95adbaf4 --- /dev/null +++ b/hurricane/src/hurricane/DisplaySlot.cpp @@ -0,0 +1,199 @@ +// **************************************************************************************************** +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: DisplaySlot.cpp +// Author: C. Alexandre +// **************************************************************************************************** + +#include "Error.h" +#include "UserGo.h" +#include "Relation.h" +#include "Cell.h" +#include "UpdateSession.h" + +#include "DisplaySlot.h" + +namespace Hurricane { + +static Name DisplaySlotsCellRelationName("DisplaySlotsCellRelation"); + +static StandardRelation* GetDisplaySlotRelation(const Cell* cell) +{ + Property* property = cell->GetProperty(DisplaySlotsCellRelationName); + if (!property) + return NULL; + else + { + StandardRelation* relation = dynamic_cast(property); + if (!relation) + throw Error("Bad Property type: Must be a Standard Relation"); + return relation; + } +} + +// **************************************************************************************************** +// DisplaySlot implementation +// **************************************************************************************************** + +DisplaySlot::DisplaySlot(Cell* cell,const Name& name, unsigned short red1, unsigned short green1, unsigned short blue1, const string& pattern1, unsigned linewidth1, unsigned short red2, unsigned short green2, unsigned short blue2, const string& pattern2, unsigned linewidth2) +// *********************** + : Inherit() + , _cell(cell) + , _name(name) + , _quadTree() + //, _drawGC(NULL) + //, _fillGC(NULL) + , _isVisible(true) +{ + //_drawGC = gtk_gc_new(red1, green1, blue1, pattern1, linewidth1); + //_fillGC = gtk_gc_new(red2, green2, blue2, pattern2, linewidth2); +} + +DisplaySlot* DisplaySlot::Create(Cell* cell, const Name& name, unsigned short red1, unsigned short green1, unsigned short blue1, const string& pattern1, unsigned linewidth1, unsigned short red2, unsigned short green2, unsigned short blue2, const string& pattern2, unsigned linewidth2) +// ****************************************** +{ + DisplaySlot* displaySlot = new DisplaySlot(cell, name, red1, green1, blue1, pattern1, linewidth1, red2, green2, blue2, pattern2, linewidth2); + + displaySlot->_PostCreate(); + + return displaySlot; +} + +void DisplaySlot::_PostCreate() +// *********************** +{ + Inherit::_PostCreate(); + StandardRelation* relation = GetDisplaySlotRelation(_cell); + if (!relation) + relation = StandardRelation::Create(_cell, DisplaySlotsCellRelationName); + Put(relation); +} + +void DisplaySlot::Show() +// ********************* +{ + if (!_isVisible) { + _isVisible = true; + //for_each_view(view, _cell->GetViews()) + //{ + // view->Invalidate(); + // end_for; + //} + } +} + +void DisplaySlot::Hide() +// ********************* +{ + if (_isVisible) { + _isVisible = false; + //for_each_view(view, _cell->GetViews()) + //{ + // view->Invalidate(); + // end_for; + //} + } +} + +void DisplaySlot::Flush() +// ********************** +{ + OpenUpdateSession(); + vector govect; + _quadTree.GetGos().Fill(govect); + for (unsigned i = 0 ; i < govect.size() ; i++) + { + govect[i]->Delete(); + } + CloseUpdateSession(); +} + +//void DisplaySlot::_Draw(View* view, const Box& updateArea, const Transformation& transformation) +//// ********************************************************************************************* +//{ +// if (GetBoundingBox().Intersect(updateArea)) { +// for_each_go(go, _quadTree.GetGos()) +// { +// go->_Draw(view, NULL, updateArea, transformation); +// end_for; +// } +// } +//} +// +void DisplaySlot::_PreDelete() +// *************************** +{ + Inherit::_PreDelete(); + //gdk_gc_destroy(_drawGC); + //gdk_gc_destroy(_fillGC); +} + +UserGos DisplaySlot::GetUserGos() const +// ************************************ +{ + return _quadTree.GetGos().GetSubSet(); +} + +UserGos DisplaySlot::GetUserGosUnder(const Box& area) const +// ******************************************************** +{ + return _quadTree.GetGosUnder(area).GetSubSet(); +} + +string DisplaySlot::_GetString() const +// *********************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(GetName())); + return s; +} + +Record* DisplaySlot::_GetRecord() const +// ****************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Cell", _cell)); + record->Add(GetSlot("Name", _name)); + record->Add(GetSlot("QuadTree", &_quadTree)); + record->Add(GetSlot("Is Visible", _isVisible)); + } + return record; +} + +DisplaySlots GetDisplaySlots(const Cell* cell) +{ + if (!cell) + throw Error("Null pointer on cell while getting display slots"); + + StandardRelation* relation = GetDisplaySlotRelation(cell); + if (!relation) + return DisplaySlots(); + return relation->GetSlaveOwners().GetSubSet(); +} + +DisplaySlot* GetDisplaySlot(const Cell* cell,const Name& name) +{ + if (!cell) + throw Error("Null pointer on cell while getting display slots"); + + StandardRelation* relation = GetDisplaySlotRelation(cell); + if (!relation) + return NULL; + else + { + for_each_display_slot(displaySlot,relation->GetSlaveOwners().GetSubSet()) + { + if (displaySlot->GetName() == name) + return displaySlot; + end_for; + } + return NULL; + } +} + + +} // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/DisplaySlot.h b/hurricane/src/hurricane/DisplaySlot.h new file mode 100644 index 00000000..9f9e4bf9 --- /dev/null +++ b/hurricane/src/hurricane/DisplaySlot.h @@ -0,0 +1,94 @@ +// **************************************************************************************************** +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: DisplaySlot.h +// Author: C. Alexandre +// **************************************************************************************************** + +#ifndef HURRICANE_DISPLAY_SLOT +#define HURRICANE_DISPLAY_SLOT + +#include "QuadTree.h" +#include "UserGos.h" +#include "DisplaySlots.h" + +namespace Hurricane { + +// **************************************************************************************************** +// DisplaySlot declaration +// **************************************************************************************************** + +class DisplaySlot : public DBo { +// *************************** + +// Types +// ***** + + public: typedef DBo Inherit; + +// Attributes +// ********** + private: Cell* _cell; + private: Name _name; + private: QuadTree _quadTree; + //private: GdkGC* _drawGC; + //private: GdkGC* _fillGC; + private: bool _isVisible; + +// Constructors +// ************ + + protected: DisplaySlot(Cell* cell,const Name& name, unsigned short red1, unsigned short green1, unsigned short blue1, const string& pattern1, unsigned linewidth1, unsigned short red2, unsigned short green2, unsigned short blue2, const string& pattern2, unsigned linewidth2); + public: static DisplaySlot* Create(Cell* cell, const Name& name, unsigned short red1, unsigned short green1, unsigned short blue1, const string& pattern1 = "FFFFFFFFFFFFFFFF", unsigned linewidth1=0, unsigned short red2 = 0, unsigned short green2 = 0, unsigned short blue2 = 0, const string& pattern2 = "FFFFFFFFFFFFFFFF", unsigned linewidth2=0); + protected: virtual void _PostCreate(); + +// Destructor +// ********** + + protected: virtual void _PreDelete(); + +// Accessors +// ********* + + public: const Name& GetName() const {return _name;}; + public: const Box& GetBoundingBox() const {return _quadTree.GetBoundingBox();}; + public: UserGos GetUserGos() const; + public: UserGos GetUserGosUnder(const Box& area) const; + +// Predicates +// ********** + + public: bool IsVisible() const {return _isVisible;}; + public: void Show(); + public: void Hide(); + +// Updators +// ******** + public: void Flush(); + +// Others +// ****** + //public: GdkGC* _GetDrawGC() const { return _drawGC; } + //public: GdkGC* _GetFillGC() const { return _fillGC; } + public: QuadTree& _GetQuadTree() { return _quadTree; } + //public: virtual void _Draw(View* view, const Box& updateArea, const Transformation& transformation); + + public: virtual string _GetTypeName() const {return _TName("DisplaySlot");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + +}; + +DisplaySlots GetDisplaySlots(const Cell* cell); + +DisplaySlot* GetDisplaySlot(const Cell* cell, const Name& name); + + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_DISPLAY_SLOT diff --git a/hurricane/src/hurricane/DisplaySlots.h b/hurricane/src/hurricane/DisplaySlots.h new file mode 100644 index 00000000..99db0adb --- /dev/null +++ b/hurricane/src/hurricane/DisplaySlots.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: DisplaySlots.h +// Author: C. Alexandre +// **************************************************************************************************** + +#ifndef HURRICANE_DISPLAY_SLOTS +#define HURRICANE_DISPLAY_SLOTS + +#include "Collection.h" + +namespace Hurricane { + +class DisplaySlot; + + + +// **************************************************************************************************** +// DisplaySlots declaration +// **************************************************************************************************** + +typedef GenericCollection DisplaySlots; + + + +// **************************************************************************************************** +// DisplaySlotLocator declaration +// **************************************************************************************************** + +typedef GenericLocator DisplaySlotLocator; + + + +// **************************************************************************************************** +// DisplaySlotFilter declaration +// **************************************************************************************************** + +typedef GenericFilter DisplaySlotFilter; + + + +// **************************************************************************************************** +// for_each_view declaration +// **************************************************************************************************** + +#define for_each_display_slot(displaySlot, displaySlots)\ +/******************************************************/\ +{\ + DisplaySlotLocator _locator = displaySlots.GetLocator();\ + while (_locator.IsValid()) {\ + DisplaySlot* displaySlot = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_DISPLAY_SLOTS diff --git a/hurricane/src/hurricane/Entities.h b/hurricane/src/hurricane/Entities.h new file mode 100644 index 00000000..fedcd24d --- /dev/null +++ b/hurricane/src/hurricane/Entities.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Entities.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_ENTITIES +#define HURRICANE_ENTITIES + +#include "Collection.h" + +namespace Hurricane { + +class Entity; + + + +// **************************************************************************************************** +// Entities declaration +// **************************************************************************************************** + +typedef GenericCollection Entities; + + + +// **************************************************************************************************** +// EntityLocator declaration +// **************************************************************************************************** + +typedef GenericLocator EntityLocator; + + + +// **************************************************************************************************** +// EntityFilter declaration +// **************************************************************************************************** + +typedef GenericFilter EntityFilter; + + + +// **************************************************************************************************** +// for_each_entity declaration +// **************************************************************************************************** + +#define for_each_entity(entity, entities)\ +/****************************************/\ +{\ + EntityLocator _locator = entities.GetLocator();\ + while (_locator.IsValid()) {\ + Entity* entity = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_ENTITIES + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Entity.cpp b/hurricane/src/hurricane/Entity.cpp new file mode 100644 index 00000000..696406cd --- /dev/null +++ b/hurricane/src/hurricane/Entity.cpp @@ -0,0 +1,96 @@ +// **************************************************************************************************** +// File: Entity.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Entity.h" +#include "Quark.h" +#include "Cell.h" +#include "Instance.h" +#include "SharedPath.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Entity implementation +// **************************************************************************************************** + +Entity::Entity() +// ************* +: Inherit() +{ +} + +void Entity::_PreDelete() +// ********************** +{ +// trace << "entering Entity::_PreDelete: " << this << endl; +// trace_in(); + + vector slaveEntities; + SlaveEntityMap::iterator it; + SlaveEntityMap::iterator end; + GetCell()->_GetSlaveEntities(this,it,end); + for(; it != end ; it++) + slaveEntities.push_back(it->second); + for(; slaveEntities.size() ; slaveEntities.pop_back()) { + cerr << "Erasing " << slaveEntities.back() << endl; + slaveEntities.back()->Delete(); + } + + Quark* quark = _GetQuark(); + if (quark) quark->Delete(); + + stack sharedPathStack; + for_each_instance(instance, GetCell()->GetSlaveInstances()) { + SharedPath* sharedPath = instance->_GetSharedPath(NULL); + if (sharedPath) sharedPathStack.push(sharedPath); + end_for; + } + while (!sharedPathStack.empty()) { + SharedPath* sharedPath = sharedPathStack.top(); + sharedPathStack.pop(); + Quark* quark = _GetQuark(sharedPath); + if (quark) quark->Delete(); + Cell* cell = sharedPath->GetOwnerCell(); + for_each_instance(instance, cell->GetSlaveInstances()) { + SharedPath* sharedPath2 = instance->_GetSharedPath(sharedPath); + if (sharedPath2) sharedPathStack.push(sharedPath2); + end_for; + } + } + + Inherit::_PreDelete(); + +// trace << "exiting Entity::_PreDelete:" << endl; +// trace_out(); +} + +string Entity::_GetString() const +// ****************************** +{ + return Inherit::_GetString(); +} + +Record* Entity::_GetRecord() const +// ************************* +{ + Record* record = Inherit::_GetRecord(); + if (record) { + Occurrence occurrence = Occurrence(this); + if (occurrence.HasProperty()) + record->Add(GetSlot("Occurrence", occurrence)); + } + return record; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Entity.h b/hurricane/src/hurricane/Entity.h new file mode 100644 index 00000000..0480ce08 --- /dev/null +++ b/hurricane/src/hurricane/Entity.h @@ -0,0 +1,70 @@ +// **************************************************************************************************** +// File: Entity.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_ENTITY +#define HURRICANE_ENTITY + +#include "DBo.h" +#include "Entities.h" +#include "Box.h" + +namespace Hurricane { + +class Cell; +class Quark; +class SharedPath; + + + +// **************************************************************************************************** +// Entity declaration +// **************************************************************************************************** + +class Entity : public DBo { +// ********************** + +# if !defined(__DOXYGEN_PROCESSOR__) + +// Types +// ***** + + public: typedef DBo Inherit; + +// Constructors +// ************ + + protected: Entity(); + +// Others +// ****** + + protected: virtual void _PreDelete(); + + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: Quark* _GetQuark(SharedPath* sharedPath = NULL) const; + +# endif + +// Accessors +// ********* + + public: virtual Cell* GetCell() const = 0; + public: virtual Box GetBoundingBox() const = 0; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Entity) + +#endif // HURRICANE_ENTITY + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Error.cpp b/hurricane/src/hurricane/Error.cpp new file mode 100644 index 00000000..0f661335 --- /dev/null +++ b/hurricane/src/hurricane/Error.cpp @@ -0,0 +1,56 @@ +// **************************************************************************************************** +// File: Error.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Error.h" + + +namespace Hurricane { + + + +// **************************************************************************************************** +// Error implementation +// **************************************************************************************************** + +Error::Error(const string& reason, int code) +// ***************************************** +: Inherit(), + _reason(reason), + _code(code) +{ +} + +Error::Error(const Error& error) +// ***************************** +: Inherit(), + _reason(error._reason), + _code(error._code) +{ +} + +Error& Error::operator=(const Error& error) +// **************************************** +{ + _reason = error._reason; + _code = error._code; + return *this; +} + +string Error::_GetString() const +// ***************************** +{ + if (!_code) return "[ERROR] " + _reason; + + return "[ERROR:" + GetString(_code) + "] " + _reason; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Error.h b/hurricane/src/hurricane/Error.h new file mode 100644 index 00000000..b896a216 --- /dev/null +++ b/hurricane/src/hurricane/Error.h @@ -0,0 +1,75 @@ +// **************************************************************************************************** +// File: Error.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_ERROR +#define HURRICANE_ERROR + +#include "Exception.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Error declaration +// **************************************************************************************************** + +class Error : public Exception { +// *************************** + +// Types +// ***** + + public: typedef Exception Inherit; + +// Attributes +// ********** + + private: string _reason; + private: int _code; + +// Constructors +// ************ + + public: Error(const string& reason, int code = 0); + + public: Error(const Error& error); + +// Operators +// ********* + + public: Error& operator=(const Error& error); + +// Accessors +// ********* + + public: string GetReason() const {return _reason;}; + public: int GetCode() const {return _code;}; + +// Modifiers +// ********* + + public: void SetReason ( const string& reason ) { _reason = reason; }; + +// Others +// ****** + + public: virtual string _GetTypeName() const { return _TName("Error"); }; + public: virtual string _GetString() const; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Error) + +#endif // HURRICANE_ERROR + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Exception.cpp b/hurricane/src/hurricane/Exception.cpp new file mode 100644 index 00000000..93668bbf --- /dev/null +++ b/hurricane/src/hurricane/Exception.cpp @@ -0,0 +1,39 @@ +// **************************************************************************************************** +// File: Exception.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Exception.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Exception implementation +// **************************************************************************************************** + +Exception::Exception() +// ******************* +{ +} + +Exception::~Exception() +// ******************** +{ +} + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Exception.h b/hurricane/src/hurricane/Exception.h new file mode 100644 index 00000000..c9b92cab --- /dev/null +++ b/hurricane/src/hurricane/Exception.h @@ -0,0 +1,63 @@ +// **************************************************************************************************** +// File: Exception.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_EXCEPTION +#define HURRICANE_EXCEPTION + +#include "Commons.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Exception declaration +// **************************************************************************************************** + +class Exception : public NestedSlotAdapter { +// *************************************** + +// Constructors +// ************ + + protected: Exception(); + + private: Exception(const Exception& exception); // not implemented to forbid copy construction + +// Destructor +// ********** + + public: virtual ~Exception(); + +// Operators +// ********* + + private: Exception& operator=(const Exception& exception); // not implemented to forbid assignment + +// Accessors +// ********* + + public: string What() const { return _GetString(); }; + +// Others +// ****** + + public: virtual string _GetString() const = 0; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Exception) + + +#endif // HURRICANE_EXCEPTION + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Filter.h b/hurricane/src/hurricane/Filter.h new file mode 100644 index 00000000..1568d897 --- /dev/null +++ b/hurricane/src/hurricane/Filter.h @@ -0,0 +1,304 @@ +// **************************************************************************************************** +// File: Filter.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_FILTER +#define HURRICANE_FILTER + +#include "Commons.h" + +namespace Hurricane { + +template class GenericFilter; +template class NotFilter; + + + +// **************************************************************************************************** +// Filter declaration +// **************************************************************************************************** + +template class Filter : public NestedSlotAdapter { +// ********************************************************* + +// Constructors +// ************ + + public: Filter() {}; + + private: Filter(const Filter& filter); // not implemented to forbid copie + +// Destructor +// ********** + + public: virtual ~Filter() {}; + +// Operators +// ********* + + private: Filter& operator=(const Filter& filter); // not implemented to forbid assigment + + public: GenericFilter operator!() const + // ****************************************** + { + return NotFilter(*this); + }; + +// Accessors +// ********* + + public: virtual Filter* GetClone() const = 0; + +// Predicates +// ********** + + public: virtual bool Accept(Type type) const = 0; + +// Others +// ****** + + public: virtual string _GetTypeName() const { return _TName("Filter"); }; + public: virtual string _GetString() const = 0; + +}; + + + +// **************************************************************************************************** +// GenericFilter declaration +// **************************************************************************************************** + +template class GenericFilter : public Filter { +// *********************************************************** + +// Types +// ***** + + public: typedef Filter Inherit; + +// Attributes +// ********** + + private: Filter* _filter; + +// Constructors +// ************ + + public: GenericFilter() + // ******************** + : Inherit(), + _filter(NULL) + { + }; + + public: GenericFilter(const Filter& filter) + // ********************************************** + : Inherit(), + _filter(filter.GetClone()) + { + }; + + public: GenericFilter(const GenericFilter& genericFilter) + // ************************************************************ + : Inherit(), + _filter(genericFilter.GetClone()) + { + }; + + public: GenericFilter(Filter* filter) + // ***************************************************** + // CAUTION : filter will be deleted by the GenericFilter + // ***************************************************** + : Inherit(), + _filter(filter) + { + }; + +// Destructor +// ********** + + public: virtual ~GenericFilter() + // ***************************** + { + if (_filter) delete _filter; + }; + +// Operators +// ********* + + public: GenericFilter& operator=(const Filter& filter) + // ********************************************************* + { + if (_filter) delete _filter; + _filter = filter.GetClone(); + return *this; + }; + + public: GenericFilter& operator=(const GenericFilter& genericFilter) + // ***************************************************************** + { + if (_filter) delete _filter; + _filter = genericFilter.GetClone(); + return *this; + }; + + public: GenericFilter& operator=(Filter* filter) + // ***************************************************** + // CAUTION : filter will be deleted by the GenericFilter + // ***************************************************** + { + if (_filter) delete _filter; + _filter = filter; + return *this; + }; + +// Accessors +// ********* + + public: virtual Filter* GetClone() const + // ******************************************* + { + return (_filter) ? _filter->GetClone() : NULL; + }; + +// Predicates +// ********** + + public: virtual bool Accept(Type type) const + // ***************************************** + { + return (_filter) ? _filter->Accept(type) : false; + }; + +// Others +// ****** + + public: virtual string _GetTypeName() const + // ************************************** + { + return _TName("GenericFilter"); + } + + public: virtual string _GetString() const + // ************************************** + { + if (!_filter) + return "<" + _GetTypeName() + " unbound>"; + else + return "<" + _GetTypeName() + " " + GetString(_filter) + ">"; + }; + +}; + + + +// **************************************************************************************************** +// NotFilter declaration +// **************************************************************************************************** + +template class NotFilter : public Filter { +// ******************************************************* + +// Types +// ***** + + public: typedef Filter Inherit; + +// Attributes +// ********** + + private: GenericFilter _genericFilter; + +// Constructors +// ************ + + public: NotFilter() + // **************** + : Inherit(), + _genericFilter() + { + }; + + public: NotFilter(const Filter& filter) + // ****************************************** + : Inherit(), + _genericFilter(filter) + { + }; + + public: NotFilter(const NotFilter& notFilter) + // ************************************************ + : Inherit(), + _genericFilter(notFilter._genericFilter) + { + }; + +// Operators +// ********* + + public: NotFilter& operator=(const NotFilter& notFilter) + // *********************************************************** + { + _genericFilter = notFilter._genericFilter; + return *this; + }; + +// Accessors +// ********* + + public: virtual Filter* GetClone() const + // ******************************************* + { + return new NotFilter(*this); + }; + +// Predicates +// ********** + + public: virtual bool Accept(Type type) const + // ***************************************** + { + return !_genericFilter.Accept(type); + }; + +// Others +// ****** + + public: virtual string _GetTypeName() const + // ************************************** + { + return _TName("GenericNotFilter"); + } + + public: virtual string _GetString() const + // ************************************** + { + return "<" + _GetTypeName() + " " + GetString(_genericFilter) + ">"; + }; + +}; + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + + +template + class IsNestedSlotAdapter > { + public: + enum { True=1, False=0 }; + }; + + + +} // End of Hurricane namespace. + + +#endif // HURRICANE_FILTER + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Go.cpp b/hurricane/src/hurricane/Go.cpp new file mode 100644 index 00000000..3da41847 --- /dev/null +++ b/hurricane/src/hurricane/Go.cpp @@ -0,0 +1,90 @@ +// **************************************************************************************************** +// File: Go.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Go.h" +#include "QuadTree.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Go implementation +// **************************************************************************************************** + +static bool AUTO_MATERIALIZATION_IS_ENABLED = true; + +Go::Go() +// ***** +: Inherit(), + _quadTree(NULL), + _nextOfQuadTreeGoSet(NULL) +{ +} + +bool Go::AutoMaterializationIsDisabled() +// ************************************* +{ + return !AUTO_MATERIALIZATION_IS_ENABLED; +} + +void Go::EnableAutoMaterialization() +// ********************************* +{ + AUTO_MATERIALIZATION_IS_ENABLED = true; +} + +void Go::DisableAutoMaterialization() +// ********************************** +{ + AUTO_MATERIALIZATION_IS_ENABLED = false; +} + +void Go::_PostCreate() +// ******************* +{ + Inherit::_PostCreate(); + + if (!AutoMaterializationIsDisabled()) Materialize(); // materialized after entire post creation +} + +void Go::_PreDelete() +// ****************** +{ +// trace << "entering Go::_PreDelete: " << this << endl; +// trace_in(); + + Unmaterialize(); // unmaterialized before starting pre destruction + + Inherit::_PreDelete(); + +// trace << "exiting Go::_PreDelete:" << endl; +// trace_out(); +} + +string Go::_GetString() const +// ************************** +{ + return Inherit::_GetString(); +} + +Record* Go::_GetRecord() const +// ********************* +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("QuadTree", _quadTree)); + } + return record; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Go.h b/hurricane/src/hurricane/Go.h new file mode 100644 index 00000000..d84619fd --- /dev/null +++ b/hurricane/src/hurricane/Go.h @@ -0,0 +1,100 @@ +// **************************************************************************************************** +// File: Go.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_GO +#define HURRICANE_GO + +#include "Entity.h" +#include "Gos.h" +#include "Transformation.h" + +namespace Hurricane { + +//class View; +class BasicLayer; +class QuadTree; + + + +// **************************************************************************************************** +// Go declaration +// **************************************************************************************************** + +class Go : public Entity { +// ********************* + +// Friends +// ******* + + friend class QuadTree; + +// Types +// ***** + + public: typedef Entity Inherit; + +// Attributes +// ********** + + private: QuadTree* _quadTree; + private: Go* _nextOfQuadTreeGoSet; + +// Constructors +// ************ + + protected: Go(); + +// Predicates +// ********** + + public: static bool AutoMaterializationIsDisabled(); + + public: bool IsMaterialized() const {return (_quadTree != NULL);}; + +// Updators +// ******** + + public: static void EnableAutoMaterialization(); + public: static void DisableAutoMaterialization(); + + public: virtual void Materialize() = 0; + public: virtual void Unmaterialize() = 0; + + public: virtual void Invalidate(bool propagateFlag = true); + // implementation located on file UpdateSession.cpp to access local variables + + public: virtual void Translate(const Unit& dx, const Unit& dy) = 0; + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: Go* _GetNextOfQuadTreeGoSet() const {return _nextOfQuadTreeGoSet;}; + + public: void _SetNextOfQuadTreeGoSet(Go* go) {_nextOfQuadTreeGoSet = go;}; + + //public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const = 0; + //public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) = 0; + //public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation) = 0; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Go) + +#endif // HURRICANE_GO + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Gos.h b/hurricane/src/hurricane/Gos.h new file mode 100644 index 00000000..f57f666a --- /dev/null +++ b/hurricane/src/hurricane/Gos.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Gos.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_GOS +#define HURRICANE_GOS + +#include "Collection.h" + +namespace Hurricane { + +class Go; + + + +// **************************************************************************************************** +// Gos declaration +// **************************************************************************************************** + +typedef GenericCollection Gos; + + + +// **************************************************************************************************** +// GoLocator declaration +// **************************************************************************************************** + +typedef GenericLocator GoLocator; + + + +// **************************************************************************************************** +// GoFilter declaration +// **************************************************************************************************** + +typedef GenericFilter GoFilter; + + + +// **************************************************************************************************** +// for_each_go declaration +// **************************************************************************************************** + +#define for_each_go(go, gos)\ +/***************************/\ +{\ + GoLocator _locator = gos.GetLocator();\ + while (_locator.IsValid()) {\ + Go* go = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_GOS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Hook.cpp b/hurricane/src/hurricane/Hook.cpp new file mode 100644 index 00000000..c5f0a1f9 --- /dev/null +++ b/hurricane/src/hurricane/Hook.cpp @@ -0,0 +1,618 @@ +// **************************************************************************************************** +// File: Hook.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Hook.h" +#include "Component.h" +#include "Rubber.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Filters declaration & implementation +// **************************************************************************************************** + +class Hook_IsMasterFilter : public Filter { +// ********************************************* + + public: Hook_IsMasterFilter() {}; + + public: Hook_IsMasterFilter(const Hook_IsMasterFilter& filter) {}; + + public: Hook_IsMasterFilter& operator=(const Hook_IsMasterFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Hook_IsMasterFilter(*this);}; + + public: virtual bool Accept(Hook* hook) const {return hook->IsMaster();}; + + public: virtual string _GetString() const {return "<" + _TName("Hook::IsMasterFilter>");}; + +}; + + + +// **************************************************************************************************** +// Hook_Hooks implementation +// **************************************************************************************************** + +class Hook_Hooks : public Collection { +// **************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ***************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Hook* _hook; + private: Hook* _currentHook; + + public: Locator(const Hook* hook = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Hook* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Hook* _hook; + +// Constructors +// ************ + + public: Hook_Hooks(const Hook* hook = NULL); + public: Hook_Hooks(const Hook_Hooks& hooks); + +// Operators +// ********* + + public: Hook_Hooks& operator=(const Hook_Hooks& hooks); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Hook_SlaveHooks implementation +// **************************************************************************************************** + +class Hook_SlaveHooks : public Collection { +// ********************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ***************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Hook* _hook; + private: Hook* _currentHook; + + public: Locator(const Hook* hook = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Hook* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Hook* _hook; + +// Constructors +// ************ + + public: Hook_SlaveHooks(const Hook* hook = NULL); + public: Hook_SlaveHooks(const Hook_SlaveHooks& hooks); + +// Operators +// ********* + + public: Hook_SlaveHooks& operator=(const Hook_SlaveHooks& hooks); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Hook implementation +// **************************************************************************************************** + +Hook::Hook() +// ********* +: _nextHook(this) +{ +} + +Hook::~Hook() +// ********** +{ + if (_nextHook != this) + throw Error("Abnormal deletion of hook : always attached"); +} + +Hook* Hook::GetNextHook() const +// **************************** +{ + return _nextHook; +} + +Hook* Hook::GetPreviousHook() const +// ******************************** +{ + Hook* hook = (Hook*)this; + while (hook->_nextHook != this) hook = hook->_nextHook; + return hook; +} + +Hook* Hook::GetMasterHook() const +// ****************************** +{ + Hook* hook = (Hook*)this; + do { + if (hook->IsMaster()) return hook; + hook = hook->_nextHook; + } while (hook != this); + return NULL; +} + +Hook* Hook::GetNextMasterHook() const +// ********************************** +{ + return _nextHook->GetMasterHook(); +} + +Hook* Hook::GetPreviousMasterHook() const +// ************************************** +{ + Hook* previousMasterHook = NULL; + Hook* hook = (Hook*)this; + do { + if (hook->IsMaster()) previousMasterHook = hook; + hook = hook->_nextHook; + } while (hook != this); + return previousMasterHook; +} + +Hooks Hook::GetHooks() const +// ************************* +{ + return Hook_Hooks(this); +} + +Hooks Hook::GetSlaveHooks() const +// ****************************** +{ + return Hook_SlaveHooks(this); +} + +HookFilter Hook::GetIsMasterFilter() +// ********************************* +{ + return Hook_IsMasterFilter(); +} + +bool Hook::IsAttached() const +// ************************** +{ + if (!IsMaster()) + return (GetMasterHook() != NULL); + else + return (GetNextMasterHook() != this); +} + +Hook* Hook::Detach() +// ***************** +{ + Hook* previousHook = NULL; + Hook* hook = _nextHook; + while (hook != this) { + if (!IsMaster() || hook->IsMaster()) previousHook = hook; + hook = hook->_nextHook; + } + if (previousHook) { + Hook* nextHook = _nextHook; + _nextHook = previousHook->_nextHook; + previousHook->_nextHook = nextHook; + + // /* + if (IsMaster()) { + assert(previousHook->IsMaster()); + Component* component = GetComponent(); + Rubber* rubber = component->GetRubber(); + if (rubber) { + rubber->_SetHook(previousHook); + component->_SetRubber(NULL); + } + } + // */ + + } + return previousHook; +} + +Hook* Hook::Attach(Hook* hook) +// *************************** +{ + if (IsAttached()) + throw Error("Can't attach : already attached"); + + if (!hook) + throw Error("Can't attach : null hook"); + + if (!hook->IsMaster()) + throw Error("Can't attach : not a master hook"); + + if (hook == this) + throw Error("Can't attach : itself"); + + Hook* masterHook = hook->GetPreviousMasterHook(); + Hook* nextHook = masterHook->_nextHook; + masterHook->_nextHook = _nextHook; + _nextHook = nextHook; + + // /* + if (IsMaster()) { + Rubber* rubber = hook->GetComponent()->GetRubber(); + if (rubber) + GetComponent()->_SetRubber(rubber); + else + Rubber::_Create(this); + } + // */ + + return this; +} + +void Hook::_SetNextHook(Hook* hook) +{ + if (IsMaster()) + { + Rubber* rubber = hook->GetComponent()->GetRubber(); + if (rubber) + rubber->_Delete(); + } + _nextHook = hook; +} + +Hook* Hook::Merge(Hook* hook) +// ************************** +{ + if (!IsMaster()) + throw Error("Can't merge : not a master"); + + if (!hook) + throw Error("Can't merge : null hook"); + + if (!hook->IsMaster()) + throw Error("Can't merge : not a master hook"); + + if (hook == this) + throw Error("Can't merge : itself"); + + Hook* masterHook = hook->GetPreviousMasterHook(); + Hook* nextHook = masterHook->_nextHook; + masterHook->_nextHook = _nextHook; + _nextHook = nextHook; + + Rubber* rubber = GetComponent()->GetRubber(); + if (rubber) rubber->_Delete(); + rubber = hook->GetComponent()->GetRubber(); + if (rubber) rubber->_Delete(); + Rubber::_Create(this); + + return this; +} + +Record* Hook::_GetRecord() const +// *********************** +{ + Record* record = NULL; + if (_nextHook != this) { + record = new Record(GetString(this)); + record->Add(GetSlot("Component", GetComponent())); + record->Add(GetSlot("NextHook", _nextHook)); + } + return record; +} + + + +// **************************************************************************************************** +// Hook_Hooks implementation +// **************************************************************************************************** + +Hook_Hooks::Hook_Hooks(const Hook* hook) +// ************************************* +: Inherit(), + _hook(hook) +{ +} + +Hook_Hooks::Hook_Hooks(const Hook_Hooks& hooks) +// ******************************************** +: Inherit(), + _hook(hooks._hook) +{ +} + +Hook_Hooks& Hook_Hooks::operator=(const Hook_Hooks& hooks) +// ******************************************************* +{ + _hook = hooks._hook; + return *this; +} + +Collection* Hook_Hooks::GetClone() const +// ******************************************** +{ + return new Hook_Hooks(*this); +} + +Locator* Hook_Hooks::GetLocator() const +// ******************************************* +{ + return new Locator(_hook); +} + +string Hook_Hooks::_GetString() const +// ********************************** +{ + string s = "<" + _TName("Hook::Hooks"); + if (_hook) s += " " + GetString(_hook); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Hook_Hooks::Locator implementation +// **************************************************************************************************** + +Hook_Hooks::Locator::Locator(const Hook* hook) +// ******************************************* +: Inherit(), + _hook(hook), + _currentHook((Hook*)hook) +{ +} + +Hook_Hooks::Locator::Locator(const Locator& locator) +// ************************************************* +: Inherit(), + _hook(locator._hook), + _currentHook(locator._currentHook) +{ +} + +Hook_Hooks::Locator& Hook_Hooks::Locator::operator=(const Locator& locator) +// ************************************************************************ +{ + _hook = locator._hook; + _currentHook = locator._currentHook; + return *this; +} + +Hook* Hook_Hooks::Locator::GetElement() const +// ****************************************** +{ + return _currentHook; +} + +Locator* Hook_Hooks::Locator::GetClone() const +// ************************************************** +{ + return new Locator(*this); +} + +bool Hook_Hooks::Locator::IsValid() const +// ************************************** +{ + return (_currentHook != NULL); +} + +void Hook_Hooks::Locator::Progress() +// ********************************* +{ + if (_currentHook) { + _currentHook = _currentHook->GetNextHook(); + if (_currentHook == _hook) _currentHook = NULL; + } +} + +string Hook_Hooks::Locator::_GetString() const +// ******************************************* +{ + string s = "<" + _TName("Hook::Hooks::Locator"); + if (_hook) s += " " + GetString(_hook); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Hook_SlaveHooks implementation +// **************************************************************************************************** + +Hook_SlaveHooks::Hook_SlaveHooks(const Hook* hook) +// *********************************************** +: Inherit(), + _hook(hook) +{ +} + +Hook_SlaveHooks::Hook_SlaveHooks(const Hook_SlaveHooks& slaveHooks) +// **************************************************************** +: Inherit(), + _hook(slaveHooks._hook) +{ +} + +Hook_SlaveHooks& Hook_SlaveHooks::operator=(const Hook_SlaveHooks& slaveHooks) +// *************************************************************************** +{ + _hook = slaveHooks._hook; + return *this; +} + +Collection* Hook_SlaveHooks::GetClone() const +// ************************************************* +{ + return new Hook_SlaveHooks(*this); +} + +Locator* Hook_SlaveHooks::GetLocator() const +// ************************************************ +{ + return new Locator(_hook); +} + +string Hook_SlaveHooks::_GetString() const +// *************************************** +{ + string s = "<" + _TName("Hook::SlaveHooks"); + if (_hook) s += " " + GetString(_hook); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Hook_SlaveHooks::Locator implementation +// **************************************************************************************************** + +Hook_SlaveHooks::Locator::Locator(const Hook* hook) +// ************************************************ +: Inherit(), + _hook(hook), + _currentHook(NULL) +{ + if (_hook && _hook->IsMaster()) { + _currentHook = _hook->GetPreviousMasterHook(); + if (_currentHook) { + _currentHook = _currentHook->GetNextHook(); + if (_currentHook == _hook) _currentHook = NULL; + } + assert(!_currentHook || !_currentHook->IsMaster()); + } +} + +Hook_SlaveHooks::Locator::Locator(const Locator& locator) +// ****************************************************** +: Inherit(), + _hook(locator._hook), + _currentHook(locator._currentHook) +{ +} + +Hook_SlaveHooks::Locator& Hook_SlaveHooks::Locator::operator=(const Locator& locator) +// ********************************************************************************** +{ + _hook = locator._hook; + _currentHook = locator._currentHook; + return *this; +} + +Hook* Hook_SlaveHooks::Locator::GetElement() const +// *********************************************** +{ + return _currentHook; +} + +Locator* Hook_SlaveHooks::Locator::GetClone() const +// ******************************************************* +{ + return new Locator(*this); +} + +bool Hook_SlaveHooks::Locator::IsValid() const +// ******************************************* +{ + return (_currentHook != NULL); +} + +void Hook_SlaveHooks::Locator::Progress() +// ************************************** +{ + if (_currentHook) { + _currentHook = _currentHook->GetNextHook(); + if (_currentHook == _hook) _currentHook = NULL; + assert(!_currentHook || !_currentHook->IsMaster()); + } +} + +string Hook_SlaveHooks::Locator::_GetString() const +// ************************************************ +{ + string s = "<" + _TName("Hook::SlaveHooks::Locator"); + if (_hook) s += " " + GetString(_hook); + s += ">"; + return s; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Hook.h b/hurricane/src/hurricane/Hook.h new file mode 100644 index 00000000..6aecb4f3 --- /dev/null +++ b/hurricane/src/hurricane/Hook.h @@ -0,0 +1,101 @@ +// **************************************************************************************************** +// File: Hook.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_HOOK +#define HURRICANE_HOOK + +#include "Hooks.h" + +namespace Hurricane { + +class Component; + + + +// **************************************************************************************************** +// Hook declaration +// **************************************************************************************************** + +class Hook : public NestedSlotAdapter { +// ********************************** + +// Attributes +// ********** + + private: Hook* _nextHook; + +// Constructors +// ************ + + protected: Hook(); + + private: Hook(const Hook& hook); // not implemented to forbid copy construction + +// Destructor +// ********** + + protected: virtual ~Hook(); + +// Operators +// ********* + + private: Hook& operator=(const Hook& hook); // not implemented to forbid assignment + +// Accessors +// ********* + + public: virtual Component* GetComponent() const = 0; + + public: Hook* GetNextHook() const; + public: Hook* GetPreviousHook() const; + + public: Hook* GetMasterHook() const; + public: Hook* GetNextMasterHook() const; + public: Hook* GetPreviousMasterHook() const; + + public: Hooks GetHooks() const; + public: Hooks GetSlaveHooks() const; + +// Filters +// ******* + + public: static HookFilter GetIsMasterFilter(); + +// Predicates +// ********** + + public: virtual bool IsMaster() const = 0; + + public: bool IsAttached() const; + +// Updators +// ******** + + public: Hook* Detach(); + public: Hook* Attach(Hook* hook); + public: Hook* Merge(Hook* hook); + public: void _SetNextHook(Hook* hook); + +// Others +// ****** + + public: virtual string _GetString() const = 0; + public: virtual Record* _GetRecord() const; + +}; + + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Hook) + +#endif // HURRICANE_HOOK + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Hooks.h b/hurricane/src/hurricane/Hooks.h new file mode 100644 index 00000000..ac50c5c7 --- /dev/null +++ b/hurricane/src/hurricane/Hooks.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Hooks.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_HOOKS +#define HURRICANE_HOOKS + +#include "Collection.h" + +namespace Hurricane { + +class Hook; + + + +// **************************************************************************************************** +// Hooks declaration +// **************************************************************************************************** + +typedef GenericCollection Hooks; + + + +// **************************************************************************************************** +// HookLocator declaration +// **************************************************************************************************** + +typedef GenericLocator HookLocator; + + + +// **************************************************************************************************** +// HookFilter declaration +// **************************************************************************************************** + +typedef GenericFilter HookFilter; + + + +// **************************************************************************************************** +// for_each_hook declaration +// **************************************************************************************************** + +#define for_each_hook(hook, hooks)\ +/*********************************/\ +{\ + HookLocator _locator = hooks.GetLocator();\ + while (_locator.IsValid()) {\ + Hook* hook = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_HOOKS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Horizontal.cpp b/hurricane/src/hurricane/Horizontal.cpp new file mode 100644 index 00000000..6618f054 --- /dev/null +++ b/hurricane/src/hurricane/Horizontal.cpp @@ -0,0 +1,174 @@ +// **************************************************************************************************** +// File: Horizontal.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Horizontal.h" +#include "Net.h" +#include "BasicLayer.h" +#include "CompositeLayer.h" +#include "Plug.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Horizontal implementation +// **************************************************************************************************** + +Horizontal::Horizontal(Net* net, Component* source, Component* target, Layer* layer, const Unit& y, const Unit& width, const Unit& dxSource, const Unit& dxTarget) +// **************************************************************************************************** +: Inherit(net, source, target, layer, width), + _y(y), + _dxSource(dxSource), + _dxTarget(dxTarget) +{ +} + +Horizontal* Horizontal::Create(Net* net, Layer* layer, const Unit& y, const Unit& width, const Unit& dxSource, const Unit& dxTarget) +// **************************************************************************************************** +{ + if (!net) + throw Error("Can't create " + _TName("Horizontal") + " : null net"); + + Horizontal* horizontal = new Horizontal(net, NULL, NULL, layer, y, width, dxSource, dxTarget); + + horizontal->_PostCreate(); + + return horizontal; +} + +Horizontal* Horizontal::Create(Component* source, Component* target, Layer* layer, const Unit& y, const Unit& width, const Unit& dxSource, const Unit& dxTarget) +// **************************************************************************************************** +{ + if (!source) + throw Error("Can't create " + _TName("Horizontal") + " : null source"); + + if (!target) + throw Error("Can't create " + _TName("Horizontal") + " : null target"); + + Horizontal* horizontal = + new Horizontal(source->GetNet(), source, target, layer, y, width, dxSource, dxTarget); + + horizontal->_PostCreate(); + + return horizontal; +} + +Box Horizontal::GetBoundingBox() const +// *********************************** +{ + Unit size = GetHalfWidth() + _GetSize(); + Unit extention = _GetExtention(); + + return Box(GetSourceX(), _y, GetTargetX(), _y).Inflate(extention, size); +} + +Box Horizontal::GetBoundingBox(BasicLayer* basicLayer) const +// ********************************************************* +{ + if (!GetLayer()->Contains(basicLayer)) return Box(); + + Unit size = GetHalfWidth() + _GetSize(basicLayer); + Unit extention = _GetExtention(basicLayer); + + return Box(GetSourceX(), _y, GetTargetX(), _y).Inflate(extention, size); +} + +Unit Horizontal::GetSourceX() const +// ******************************** +{ + Component* source = GetSource(); + return (source) ? source->GetX() + _dxSource : _dxSource; +} + +Unit Horizontal::GetTargetX() const +// ******************************** +{ + Component* target = GetTarget(); + return (target) ? target->GetX() + _dxTarget : _dxTarget; +} + +Unit Horizontal::GetLength() const +// ******************************* +{ + return abs(GetSourceX() - GetTargetX()); +} + +Point Horizontal::GetCenter() const +// ******************************* +{ + return Point ( (GetSourceX()+GetTargetX())/2, GetY() ); +} + +void Horizontal::Translate(const Unit& dx, const Unit& dy) +// ******************************************************* +{ + if (dy != 0) { + Invalidate(true); + _y += dy; + } +} + +void Horizontal::SetY(const Unit& y) +// ********************************* +{ + if (y != _y) { + Invalidate(true); + _y = y; + } +} + +void Horizontal::SetDxSource(const Unit& dxSource) +// *********************************************** +{ + if (dxSource != _dxSource) { + Invalidate(false); + _dxSource = dxSource; + } +} + +void Horizontal::SetDxTarget(const Unit& dxTarget) +// *********************************************** +{ + if (dxTarget != _dxTarget) { + Invalidate(false); + _dxTarget = dxTarget; + } +} + +void Horizontal::Translate(const Unit& dy) +// *************************************** +{ + if (dy != 0) { + Invalidate(true); + _y += dy; + } +} + +string Horizontal::_GetString() const +// ********************************** +{ + return Inherit::_GetString(); +} + +Record* Horizontal::_GetRecord() const +// ***************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Y", &_y)); + record->Add(GetSlot("DxSource", &_dxSource)); + record->Add(GetSlot("DxTarget", &_dxTarget)); + } + return record; +} + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Horizontal.h b/hurricane/src/hurricane/Horizontal.h new file mode 100644 index 00000000..f8c8e0cc --- /dev/null +++ b/hurricane/src/hurricane/Horizontal.h @@ -0,0 +1,88 @@ +// **************************************************************************************************** +// File: Horizontal.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_HORIZONTAL +#define HURRICANE_HORIZONTAL + +#include "Segment.h" +#include "Horizontals.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Horizontal declaration +// **************************************************************************************************** + +class Horizontal : public Segment { +// ****************************** + +// Types +// ***** + + public: typedef Segment Inherit; + +// Attributes +// ********** + + private: Unit _y; + private: Unit _dxSource; + private: Unit _dxTarget; + +// Constructors +// ************ + + protected: Horizontal(Net* net, Component* source, Component* target, Layer* layer, const Unit& y, const Unit& width = 0, const Unit& dxSource = 0, const Unit& dxTarget = 0); + + public: static Horizontal* Create(Net* net, Layer* layer, const Unit& y, const Unit& width = 0, const Unit& dxSource = 0, const Unit& dxTarget = 0); + public: static Horizontal* Create(Component* source, Component* target, Layer* layer, const Unit& y, const Unit& width = 0, const Unit& dxSource = 0, const Unit& dxTarget = 0); + +// Accessors +// ********* + + public: virtual Unit GetY() const {return _y;}; + public: virtual Point GetCenter() const; + public: virtual Box GetBoundingBox() const; + public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const; + public: virtual Unit GetSourceX() const; + public: virtual Unit GetSourceY() const {return GetY();}; + public: virtual Unit GetTargetX() const; + public: virtual Unit GetTargetY() const {return GetY();}; + public: virtual Unit GetLength() const; + public: const Unit& GetDxSource() const {return _dxSource;}; + public: const Unit& GetDxTarget() const {return _dxTarget;}; + +// Updators +// ******** + + public: virtual void Translate(const Unit& dx, const Unit& dy); + + public: void SetY(const Unit& y); + public: void SetDxSource(const Unit& dxSource); + public: void SetDxTarget(const Unit& dxSource); + public: void Translate(const Unit& dy); + +// Others +// ****** + + public: virtual string _GetTypeName() const {return _TName("Horizontal");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Horizontal) + +#endif // HURRICANE_HORIZONTAL + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Horizontals.h b/hurricane/src/hurricane/Horizontals.h new file mode 100644 index 00000000..8a65cfea --- /dev/null +++ b/hurricane/src/hurricane/Horizontals.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Horizontals.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_HORIZONTALS +#define HURRICANE_HORIZONTALS + +#include "Collection.h" + +namespace Hurricane { + +class Horizontal; + + + +// **************************************************************************************************** +// Horizontals declaration +// **************************************************************************************************** + +typedef GenericCollection Horizontals; + + + +// **************************************************************************************************** +// HorizontalLocator declaration +// **************************************************************************************************** + +typedef GenericLocator HorizontalLocator; + + + +// **************************************************************************************************** +// HorizontalFilter declaration +// **************************************************************************************************** + +typedef GenericFilter HorizontalFilter; + + + +// **************************************************************************************************** +// for_each_horizontal declaration +// **************************************************************************************************** + +#define for_each_horizontal(horizontal, horizontals)\ +/***************************************************/\ +{\ + HorizontalLocator _locator = horizontals.GetLocator();\ + while (_locator.IsValid()) {\ + Horizontal* horizontal = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_HORIZONTALS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Hurricane.h b/hurricane/src/hurricane/Hurricane.h new file mode 100644 index 00000000..f0c77dab --- /dev/null +++ b/hurricane/src/hurricane/Hurricane.h @@ -0,0 +1,65 @@ +// **************************************************************************************************** +// File: Hurricane.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment BULL-LIP6 + +#ifndef HURRICANE_ALL +#define HURRICANE_ALL + +#include "Error.h" +#include "Warning.h" +#include "Interruption.h" + +#include "Tag.h" + +#include "Timer.h" + +#include "Region.h" + +#include "Property.h" +#include "Relation.h" +#include "Selector.h" +#include "UpdateSession.h" + +#include "DataBase.h" +#include "Technology.h" +#include "Layer.h" +#include "BasicLayer.h" +#include "CompositeLayer.h" +#include "Library.h" +#include "Cell.h" +#include "Instance.h" +#include "Marker.h" +#include "DRCError.h" +#include "Reference.h" +#include "Net.h" +#include "Rubber.h" +#include "Component.h" +#include "Plug.h" +#include "Pin.h" +#include "Contact.h" +#include "Vertical.h" +#include "Horizontal.h" +#include "Pad.h" +#include "MainView.h" +#include "MapView.h" + +#include "Symbol.h" +#include "Primitive.h" + +#include "Path.h" +#include "SharedPath.h" +#include "Occurrence.h" +#include "Quark.h" + +#include "HyperNet.h" +#include "DisplaySlot.h" +#include "UserGo.h" + +#endif // HURRICANE_ALL + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/HyperNet.cpp b/hurricane/src/hurricane/HyperNet.cpp new file mode 100644 index 00000000..31d9d012 --- /dev/null +++ b/hurricane/src/hurricane/HyperNet.cpp @@ -0,0 +1,1003 @@ +// **************************************************************************************************** +// File: HyperNet.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment BULL-LIP6 + +#include "HyperNet.h" +#include "Cell.h" +#include "Net.h" +#include "Instance.h" +#include "Rubber.h" +#include "Plug.h" +#include "BasicLayer.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// HyperNet_NetOccurrences definition +// **************************************************************************************************** + +class HyperNet_NetOccurrences : public Collection { +// ******************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const HyperNet* _hyperNet; + private: bool _doExtraction; + private: bool _allowInterruption; + private: set _netOccurrenceSet; + private: stack _netOccurrenceStack; + + public: Locator(); + public: Locator(const HyperNet* hyperNet, bool doExtraction = false, bool allowInterruption = false); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Occurrence GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const HyperNet* _hyperNet; + private: bool _doExtraction; + private: bool _allowInterruption; + +// Constructors +// ************ + + public: HyperNet_NetOccurrences(); + public: HyperNet_NetOccurrences(const HyperNet* hyperNet, bool doExtraction = false, bool allowInterruption = false); + public: HyperNet_NetOccurrences(const HyperNet_NetOccurrences& netOccurrences); + +// Operators +// ********* + + public: HyperNet_NetOccurrences& operator=(const HyperNet_NetOccurrences& netOccurrences); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + +// **************************************************************************************************** +// HyperNet_NetOccurrencesUnder definition +// **************************************************************************************************** + +class HyperNet_NetOccurrencesUnder : public Collection { +// *************************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const HyperNet* _hyperNet; + private: Box _area; + private: bool _doExtraction; + private: bool _allowInterruption; + private: set _netOccurrenceSet; + private: stack _netOccurrenceStack; + + public: Locator(); + public: Locator(const HyperNet* hyperNet, Box area, + bool doExtraction = false, bool allowInterruption = false); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Occurrence GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const HyperNet* _hyperNet; + private: Box _area; + private: bool _doExtraction; + private: bool _allowInterruption; + +// Constructors +// ************ + + public: HyperNet_NetOccurrencesUnder(); + public: HyperNet_NetOccurrencesUnder(const HyperNet* hyperNet, + Box area, + bool doExtraction = false, + bool allowInterruption = false); + public: HyperNet_NetOccurrencesUnder(const HyperNet_NetOccurrencesUnder& netOccurrences); + +// Operators +// ********* + + public: HyperNet_NetOccurrencesUnder& operator=(const HyperNet_NetOccurrencesUnder& netOccurrences); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + +// **************************************************************************************************** +// HyperNet_LeafPlugOccurrences definition +// **************************************************************************************************** + +class HyperNet_LeafPlugOccurrences : public Collection { +// ***************************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: bool _doExtraction; + private: bool _allowInterruption; + private: OccurrenceLocator _netOccurrenceLocator; + private: Occurrence _plugOccurrence; + + public: Locator(); + public: Locator(const HyperNet* hyperNet, bool doExtraction = false, bool allowInterruption = false); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Occurrence GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const HyperNet* _hyperNet; + private: bool _doExtraction; + private: bool _allowInterruption; + +// Constructors +// ************ + + public: HyperNet_LeafPlugOccurrences(); + public: HyperNet_LeafPlugOccurrences(const HyperNet* hyperNet, bool doExtraction = false, bool allowInterruption = false); + public: HyperNet_LeafPlugOccurrences(const HyperNet_LeafPlugOccurrences& netOccurrences); + +// Operators +// ********* + + public: HyperNet_LeafPlugOccurrences& operator=(const HyperNet_LeafPlugOccurrences& netOccurrences); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// HyperNet implementation +// **************************************************************************************************** + +HyperNet::HyperNet(const Occurrence& occurrence) +// ******************************************* +: _netOccurrence() +{ + if (occurrence.IsValid()) { + Entity* entity = occurrence.GetEntity(); + if (is_a(entity)) + _netOccurrence = occurrence; + else { + if (is_a(entity)) { + Rubber* rubber = (Rubber*)entity; + _netOccurrence = Occurrence(rubber->GetNet(), occurrence.GetPath()); + } + else { + if (is_a(entity)) { + Component* component = (Component*)entity; + _netOccurrence = Occurrence(component->GetNet(), occurrence.GetPath()); + } + else + throw Error("Can't create " + _TName("HyperNet") + " : bad occurrence entity type"); + } + } + } +} + +Occurrences HyperNet::GetNetOccurrences(bool doExtraction, bool allowInterruption) const +// *********************************************************************************** +{ + return HyperNet_NetOccurrences(this, doExtraction, allowInterruption); +} + +Occurrences HyperNet::GetNetOccurrencesUnder(Box area, bool doExtraction, bool allowInterruption) const +// ************************************************************************************************** +{ + return HyperNet_NetOccurrencesUnder(this, area, doExtraction, allowInterruption); +} + +Occurrences HyperNet::GetLeafPlugOccurrences(bool doExtraction, bool allowInterruption) const +// ******************************************************************************************** +{ + return HyperNet_LeafPlugOccurrences(this, doExtraction, allowInterruption); +} + +string HyperNet::_GetString() const +// ******************************** +{ + string s = "<" + _TName("HyperNet"); + if (IsValid()) s += " " + GetString(_netOccurrence); + s += ">"; + return s; +} + +Record* HyperNet::_GetRecord() const +// *************************** +{ + Record* record = new Record(GetString(this)); + if (record) { + record->Add(GetSlot("NetOccurrence", &_netOccurrence)); + } + return record; +} + +Occurrence GetHyperNetRootNetOccurrence(const Occurrence& netoccurrence) +// ********************************************************************* +{ + if (!netoccurrence.IsValid()) + throw Error("GetHyperNetRootNetOccurrence : invalid occurrence"); + + Net* net = dynamic_cast(netoccurrence.GetEntity()); + if (!net) + throw Error("GetHyperNetRootNetOccurrence : not a net occurrence"); + + if (!net->IsExternal()) + return netoccurrence; + + Path path = netoccurrence.GetPath(); + + if (path.IsEmpty()) + return netoccurrence; + + Instance* instance = path.GetTailInstance(); + + Plug* plug = instance->GetPlug(net); + if (!plug) + throw Error("GetHyperNetRootNetOccurrence : no plug for external net !"); + + if(!plug->IsConnected()) + return netoccurrence; + + return GetHyperNetRootNetOccurrence(Occurrence(plug->GetNet(), path.GetHeadPath())); +} + + +bool IsHyperNetRootNetOccurrence(Occurrence netoccurrence) +// ******************************************************* +{ + Net* net=dynamic_cast(netoccurrence.GetEntity()); + if (!net) return false; + if (!net->IsExternal()) return true; + if (netoccurrence.GetPath().IsEmpty()) return true; + if (net->IsGlobal()) return false; + if (!netoccurrence.GetPath().GetTailInstance()->GetPlug(net)->IsConnected()) + return true; + return false; +} + + + +// **************************************************************************************************** +// HyperNet_NetOccurrences implementation +// **************************************************************************************************** + +HyperNet_NetOccurrences::HyperNet_NetOccurrences() +// ********************************************* +: Inherit(), + _hyperNet(NULL), + _doExtraction(false), + _allowInterruption(false) +{ +} + +HyperNet_NetOccurrences::HyperNet_NetOccurrences(const HyperNet* hyperNet, bool doExtraction, bool allowInterruption) +// **************************************************************************************************** +: Inherit(), + _hyperNet(hyperNet), + _doExtraction(doExtraction), + _allowInterruption(allowInterruption) +{ +} + +HyperNet_NetOccurrences::HyperNet_NetOccurrences(const HyperNet_NetOccurrences& netOccurrences) +// **************************************************************************************** +: Inherit(), + _hyperNet(netOccurrences._hyperNet), + _doExtraction(netOccurrences._doExtraction), + _allowInterruption(netOccurrences._allowInterruption) +{ +} + +HyperNet_NetOccurrences& HyperNet_NetOccurrences::operator=(const HyperNet_NetOccurrences& netOccurrences) +// *************************************************************************************************** +{ + _hyperNet = netOccurrences._hyperNet; + _doExtraction = netOccurrences._doExtraction; + _allowInterruption = netOccurrences._allowInterruption; + return *this; +} + +Collection* HyperNet_NetOccurrences::GetClone() const +// ************************************************************ +{ + return new HyperNet_NetOccurrences(*this); +} + +Locator* HyperNet_NetOccurrences::GetLocator() const +// *********************************************************** +{ + return new Locator(_hyperNet, _doExtraction, _allowInterruption); +} + +string HyperNet_NetOccurrences::_GetString() const +// ********************************************** +{ + string s = "<" + _TName("HyperNet::NetOccurrences"); + if (_hyperNet) { + s += " " + GetString(_hyperNet); + if (_doExtraction) { + s += " DO_EXTRACTION"; + if (_allowInterruption) s += " ALLOW_INTERRUPTION"; + } + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// HyperNet_NetOccurrences::Locator implementation +// **************************************************************************************************** + +HyperNet_NetOccurrences::Locator::Locator() +// *************************************** +: Inherit(), + _hyperNet(NULL), + _doExtraction(false), + _allowInterruption(false), + _netOccurrenceSet(), + _netOccurrenceStack() +{ +} + +HyperNet_NetOccurrences::Locator::Locator(const HyperNet* hyperNet, bool doExtraction, bool allowInterruption) +// **************************************************************************************************** +: Inherit(), + _hyperNet(hyperNet), + _doExtraction(doExtraction), + _allowInterruption(allowInterruption), + _netOccurrenceSet(), + _netOccurrenceStack() +{ + if (_hyperNet) { + Occurrence netOccurrence = _hyperNet->GetNetOccurrence(); + if (netOccurrence.IsValid()) { + _netOccurrenceSet.insert(netOccurrence); + _netOccurrenceStack.push(netOccurrence); + } + } +} + +HyperNet_NetOccurrences::Locator::Locator(const Locator& locator) +// ************************************************************* +: Inherit(), + _hyperNet(locator._hyperNet), + _doExtraction(locator._doExtraction), + _allowInterruption(locator._allowInterruption), + _netOccurrenceSet(locator._netOccurrenceSet), + _netOccurrenceStack(locator._netOccurrenceStack) +{ +} + +HyperNet_NetOccurrences::Locator& HyperNet_NetOccurrences::Locator::operator=(const Locator& locator) +// ************************************************************************************************ +{ + _hyperNet = locator._hyperNet; + _doExtraction = locator._doExtraction; + _allowInterruption = locator._allowInterruption; + _netOccurrenceSet = locator._netOccurrenceSet; + _netOccurrenceStack = locator._netOccurrenceStack; + return *this; +} + +Occurrence HyperNet_NetOccurrences::Locator::GetElement() const +// ********************************************************** +{ + return (!_netOccurrenceStack.empty()) ? _netOccurrenceStack.top() : Occurrence(); +} + +Locator* HyperNet_NetOccurrences::Locator::GetClone() const +// ****************************************************************** +{ + return new Locator(*this); +} + +bool HyperNet_NetOccurrences::Locator::IsValid() const +// ************************************************** +{ + return !_netOccurrenceStack.empty(); +} + +static bool IsConnex(const Occurrence& componentOccurrence1, const Occurrence& componentOccurrence2) +// ********************************************************************************************* +{ + Component* component1 = (Component*)componentOccurrence1.GetEntity(); + Component* component2 = (Component*)componentOccurrence2.GetEntity(); + Layer* layer1 = component1->GetLayer(); + Layer* layer2 = component2->GetLayer(); + if (layer1->GetExtractMask() & layer2->GetExtractMask()) { + Transformation transformation1 = componentOccurrence1.GetPath().GetTransformation(); + Transformation transformation2 = componentOccurrence2.GetPath().GetTransformation(); + for_each_basic_layer(basicLayer1, layer1->GetBasicLayers()) { + Box box1 = transformation1.GetBox(component1->GetBoundingBox(basicLayer1)); + for_each_basic_layer(basicLayer2, layer2->GetBasicLayers()) { + if (basicLayer1->GetExtractMask() & basicLayer2->GetExtractMask()) { + Box box2 = transformation2.GetBox(component2->GetBoundingBox(basicLayer2)); + if (box1.Intersect(box2)) return true; + } + end_for; + } + end_for; + } + } + return false; +} + +void HyperNet_NetOccurrences::Locator::Progress() +// ********************************************* +{ + if (!_netOccurrenceStack.empty()) { + Occurrence netOccurrence = _netOccurrenceStack.top(); + _netOccurrenceStack.pop(); + Net* net = (Net*)netOccurrence.GetEntity(); + Path path = netOccurrence.GetPath(); + + if (_doExtraction) { + Cell* cell = netOccurrence.GetOwnerCell(); + for_each_component(component, net->GetComponents()) { + if (!is_a(component)) { + //if (_allowInterruption && !((i++) % 200)) gtk_check_for_interruption(); + Occurrence occurrence = Occurrence(component, path); + Box area = occurrence.GetBoundingBox(); + for_each_occurrence(occurrence2, cell->GetOccurrencesUnder(area)) { + if (is_a(occurrence2.GetEntity())) { + Component* component2 = (Component*)occurrence2.GetEntity(); + if (IsConnex(occurrence, occurrence2)) { + Occurrence net2Occurrence = + Occurrence(component2->GetNet(), occurrence2.GetPath()); + if (_netOccurrenceSet.find(net2Occurrence) == _netOccurrenceSet.end()) { + _netOccurrenceSet.insert(net2Occurrence); + _netOccurrenceStack.push(net2Occurrence); + } + } + } + end_for; + } + } + end_for; + } + } + + for_each_plug(plug, net->GetPlugs()) { + Occurrence occurrence = Occurrence(plug->GetMasterNet(), Path(path, plug->GetInstance())); + if (_netOccurrenceSet.find(occurrence) == _netOccurrenceSet.end()) { + _netOccurrenceSet.insert(occurrence); + _netOccurrenceStack.push(occurrence); + } + end_for; + } + + if (net->IsExternal()) { + Instance* instance = path.GetTailInstance(); + if (instance) { + Plug* plug = instance->GetPlug(net); + if (plug) { + Net* net = plug->GetNet(); + if (net) { + Occurrence occurrence = Occurrence(net, path.GetHeadPath()); + if (_netOccurrenceSet.find(occurrence) == _netOccurrenceSet.end()) { + _netOccurrenceSet.insert(occurrence); + _netOccurrenceStack.push(occurrence); + } + } + } + } + } + } +} + +string HyperNet_NetOccurrences::Locator::_GetString() const +// ******************************************************* +{ + string s = "<" + _TName("HyperNet::NetOccurrences::Locator"); + if (_hyperNet) { + s += " " + GetString(_hyperNet); + if (_doExtraction) { + s += " DO_EXTRACTION"; + if (_allowInterruption) s += " ALLOW_INTERRUPTION"; + } + } + s += ">"; + return s; +} + +// **************************************************************************************************** +// HyperNet_NetOccurrencesUnder implementation +// **************************************************************************************************** + +HyperNet_NetOccurrencesUnder::HyperNet_NetOccurrencesUnder() +// ******************************************************* +: Inherit(), + _hyperNet(NULL), + _area(), + _doExtraction(false), + _allowInterruption(false) +{ +} + +HyperNet_NetOccurrencesUnder::HyperNet_NetOccurrencesUnder(const HyperNet* hyperNet, + Box area, bool doExtraction, + bool allowInterruption) +// *********************************************************************************** +: Inherit(), + _hyperNet(hyperNet), + _area(area), + _doExtraction(doExtraction), + _allowInterruption(allowInterruption) +{ +} + +HyperNet_NetOccurrencesUnder::HyperNet_NetOccurrencesUnder(const HyperNet_NetOccurrencesUnder& netOccurrences) +// ******************************************************************************************************* +: Inherit(), + _hyperNet(netOccurrences._hyperNet), + _area(netOccurrences._area), + _doExtraction(netOccurrences._doExtraction), + _allowInterruption(netOccurrences._allowInterruption) +{ +} + +HyperNet_NetOccurrencesUnder& HyperNet_NetOccurrencesUnder::operator=(const HyperNet_NetOccurrencesUnder& netOccurrences) +// ****************************************************************************************************************** +{ + _hyperNet = netOccurrences._hyperNet; + _area = netOccurrences._area; + _doExtraction = netOccurrences._doExtraction; + _allowInterruption = netOccurrences._allowInterruption; + return *this; +} + +Collection* HyperNet_NetOccurrencesUnder::GetClone() const +// ***************************************************************** +{ + return new HyperNet_NetOccurrencesUnder(*this); +} + +Locator* HyperNet_NetOccurrencesUnder::GetLocator() const +// **************************************************************** +{ + return new Locator(_hyperNet, _area, _doExtraction, _allowInterruption); +} + +string HyperNet_NetOccurrencesUnder::_GetString() const +// *************************************************** +{ + string s = "<" + _TName("HyperNet::NetOccurrences"); + if (_hyperNet) { + s += " " + GetString(_hyperNet); + if (_doExtraction) { + s += " DO_EXTRACTION"; + if (_allowInterruption) s += " ALLOW_INTERRUPTION"; + } + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// HyperNet_NetOccurrencesUnder::Locator implementation +// **************************************************************************************************** + +HyperNet_NetOccurrencesUnder::Locator::Locator() +// ******************************************** +: Inherit(), + _hyperNet(NULL), + _area(), + _doExtraction(false), + _allowInterruption(false), + _netOccurrenceSet(), + _netOccurrenceStack() +{ +} + +HyperNet_NetOccurrencesUnder::Locator::Locator(const HyperNet* hyperNet, Box area, + bool doExtraction, bool allowInterruption) +// ************************************************************************************* +: Inherit(), + _hyperNet(hyperNet), + _area(area), + _doExtraction(doExtraction), + _allowInterruption(allowInterruption), + _netOccurrenceSet(), + _netOccurrenceStack() +{ + if (_hyperNet) { + Occurrence netOccurrence = _hyperNet->GetNetOccurrence(); + if (netOccurrence.IsValid()) { + _netOccurrenceSet.insert(netOccurrence); + _netOccurrenceStack.push(netOccurrence); + } + } +} + +HyperNet_NetOccurrencesUnder::Locator::Locator(const Locator& locator) +// ****************************************************************** +: Inherit(), + _hyperNet(locator._hyperNet), + _area(locator._area), + _doExtraction(locator._doExtraction), + _allowInterruption(locator._allowInterruption), + _netOccurrenceSet(locator._netOccurrenceSet), + _netOccurrenceStack(locator._netOccurrenceStack) +{ +} + +HyperNet_NetOccurrencesUnder::Locator& HyperNet_NetOccurrencesUnder::Locator::operator=(const Locator& locator) +// ********************************************************************************************************** +{ + _hyperNet = locator._hyperNet; + _area = locator._area; + _doExtraction = locator._doExtraction; + _allowInterruption = locator._allowInterruption; + _netOccurrenceSet = locator._netOccurrenceSet; + _netOccurrenceStack = locator._netOccurrenceStack; + return *this; +} + +Occurrence HyperNet_NetOccurrencesUnder::Locator::GetElement() const +// *************************************************************** +{ + return (!_netOccurrenceStack.empty()) ? _netOccurrenceStack.top() : Occurrence(); +} + +Locator* HyperNet_NetOccurrencesUnder::Locator::GetClone() const +// *********************************************************************** +{ + return new Locator(*this); +} + +bool HyperNet_NetOccurrencesUnder::Locator::IsValid() const +// ******************************************************* +{ + return !_netOccurrenceStack.empty(); +} + +void HyperNet_NetOccurrencesUnder::Locator::Progress() +// ************************************************** +{ + if (!_netOccurrenceStack.empty()) { + Occurrence netOccurrence = _netOccurrenceStack.top(); + _netOccurrenceStack.pop(); + Net* net = (Net*)netOccurrence.GetEntity(); + Path path = netOccurrence.GetPath(); + + if (_doExtraction) { + Cell* cell = netOccurrence.GetOwnerCell(); + for_each_component(component, net->GetComponents()) { + Occurrence occurrence = Occurrence(component, path); + Box area = occurrence.GetBoundingBox(); + if (! area.Intersect (_area)) { + // Outside useful area + } else if (is_a(component)) { + // Will be processed below + } else if (is_a(component)) { + // Don't go through the Rubbers (go only trough connecting layers) + } else { + //if (_allowInterruption && !((i++) % 200)) gtk_check_for_interruption(); + Box under = area.GetIntersection (_area); + for_each_occurrence(occurrence2, cell->GetOccurrencesUnder(under)) { + if (is_a(occurrence2.GetEntity())) { + Component* component2 = (Component*)occurrence2.GetEntity(); + if (IsConnex(occurrence, occurrence2)) { + Occurrence net2Occurrence = + Occurrence(component2->GetNet(), occurrence2.GetPath()); + if (_netOccurrenceSet.find(net2Occurrence) == _netOccurrenceSet.end()) { + _netOccurrenceSet.insert(net2Occurrence); + _netOccurrenceStack.push(net2Occurrence); + } + } + } + end_for; + } + } + end_for; + } + } + + for_each_plug(plug, net->GetPlugs()) { + Occurrence occurrence = Occurrence(plug->GetMasterNet(), Path(path, plug->GetInstance())); + if (_netOccurrenceSet.find(occurrence) == _netOccurrenceSet.end()) { + _netOccurrenceSet.insert(occurrence); + _netOccurrenceStack.push(occurrence); + } + end_for; + } + + if (net->IsExternal()) { + Instance* instance = path.GetTailInstance(); + if (instance) { + Plug* plug = instance->GetPlug(net); + if (plug) { + Net* net = plug->GetNet(); + if (net) { + Occurrence occurrence = Occurrence(net, path.GetHeadPath()); + if (_netOccurrenceSet.find(occurrence) == _netOccurrenceSet.end()) { + _netOccurrenceSet.insert(occurrence); + _netOccurrenceStack.push(occurrence); + } + } + } + } + } + } +} + +string HyperNet_NetOccurrencesUnder::Locator::_GetString() const +// *********************************************************** +{ + string s = "<" + _TName("HyperNet::NetOccurrences::Locator"); + if (_hyperNet) { + s += " " + GetString(_hyperNet); + if (_doExtraction) { + s += " DO_EXTRACTION"; + if (_allowInterruption) s += " ALLOW_INTERRUPTION"; + } + } + s += ">"; + return s; +} + +// **************************************************************************************************** +// HyperNet_LeafPlugOccurrences implementation +// **************************************************************************************************** + +HyperNet_LeafPlugOccurrences::HyperNet_LeafPlugOccurrences() +// ********************************************* +: Inherit(), + _hyperNet(NULL), + _doExtraction(false), + _allowInterruption(false) +{ +} + +HyperNet_LeafPlugOccurrences::HyperNet_LeafPlugOccurrences(const HyperNet* hyperNet, bool doExtraction, bool allowInterruption) +// **************************************************************************************************** +: Inherit(), + _hyperNet(hyperNet), + _doExtraction(doExtraction), + _allowInterruption(allowInterruption) +{ +} + +HyperNet_LeafPlugOccurrences::HyperNet_LeafPlugOccurrences(const HyperNet_LeafPlugOccurrences& netOccurrences) +// **************************************************************************************** +: Inherit(), + _hyperNet(netOccurrences._hyperNet), + _doExtraction(netOccurrences._doExtraction), + _allowInterruption(netOccurrences._allowInterruption) +{ +} + +HyperNet_LeafPlugOccurrences& HyperNet_LeafPlugOccurrences::operator=(const HyperNet_LeafPlugOccurrences& netOccurrences) +// *************************************************************************************************** +{ + _hyperNet = netOccurrences._hyperNet; + _doExtraction = netOccurrences._doExtraction; + _allowInterruption = netOccurrences._allowInterruption; + return *this; +} + +Collection* HyperNet_LeafPlugOccurrences::GetClone() const +// ************************************************************ +{ + return new HyperNet_LeafPlugOccurrences(*this); +} + +Locator* HyperNet_LeafPlugOccurrences::GetLocator() const +// *********************************************************** +{ + return new Locator(_hyperNet, _doExtraction, _allowInterruption); +} + +string HyperNet_LeafPlugOccurrences::_GetString() const +// ********************************************** +{ + string s = "<" + _TName("HyperNet::LeafPlugOccurrences"); + if (_hyperNet) { + s += " " + GetString(_hyperNet); + if (_doExtraction) { + s += " DO_EXTRACTION"; + if (_allowInterruption) s += " ALLOW_INTERRUPTION"; + } + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// HyperNet_LeafPlugOccurrences::Locator implementation +// **************************************************************************************************** + +HyperNet_LeafPlugOccurrences::Locator::Locator() +// *************************************** +: Inherit(), + _netOccurrenceLocator(), + _plugOccurrence() + +{ +} + +HyperNet_LeafPlugOccurrences::Locator::Locator(const HyperNet* hyperNet, bool doExtraction, bool allowInterruption) +// **************************************************************************************************** +: Inherit(), + _netOccurrenceLocator(), + _plugOccurrence() +{ + if (hyperNet) { + _netOccurrenceLocator = hyperNet->GetNetOccurrences(doExtraction,allowInterruption).GetLocator(); + Progress(); + } +} + +HyperNet_LeafPlugOccurrences::Locator::Locator(const Locator& locator) +// ************************************************************* +: Inherit(), + _netOccurrenceLocator(), + _plugOccurrence() +{ +} + +HyperNet_LeafPlugOccurrences::Locator& HyperNet_LeafPlugOccurrences::Locator::operator=(const Locator& locator) +// ************************************************************************************************ +{ + _netOccurrenceLocator = locator._netOccurrenceLocator; + _plugOccurrence = locator._plugOccurrence; + return *this; +} + +Occurrence HyperNet_LeafPlugOccurrences::Locator::GetElement() const +// ********************************************************** +{ + return _plugOccurrence; +} + +Locator* HyperNet_LeafPlugOccurrences::Locator::GetClone() const +// ****************************************************************** +{ + return new Locator(*this); +} + +bool HyperNet_LeafPlugOccurrences::Locator::IsValid() const +// ************************************************** +{ + return _plugOccurrence.IsValid(); +} + + +void HyperNet_LeafPlugOccurrences::Locator::Progress() +// ********************************************* +{ + _plugOccurrence = Occurrence(); + while(_netOccurrenceLocator.IsValid() && !_plugOccurrence.IsValid()) + { + Occurrence netOccurrence = _netOccurrenceLocator.GetElement(); + _netOccurrenceLocator.Progress(); + Net* net = (Net*)netOccurrence.GetEntity(); + Path path = netOccurrence.GetPath(); + if (!path.IsEmpty() && net->GetCell()->IsLeaf()) + { + Instance *instance = path.GetTailInstance(); + Plug *plug=instance->GetPlug(net); + if (plug) + _plugOccurrence=Occurrence(plug,path.GetHeadPath()); + } + } +} + +string HyperNet_LeafPlugOccurrences::Locator::_GetString() const +// ******************************************************* +{ + string s = "<" + _TName("HyperNet::LeafPlugOccurrences::Locator"); + s += " " + GetString(_netOccurrenceLocator); + s += ">"; + return s; +} + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/HyperNet.h b/hurricane/src/hurricane/HyperNet.h new file mode 100644 index 00000000..48ec72b4 --- /dev/null +++ b/hurricane/src/hurricane/HyperNet.h @@ -0,0 +1,87 @@ +// **************************************************************************************************** +// File: HyperNet.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment BULL-LIP6 + +#ifndef HURRICANE_HYPER_NET +#define HURRICANE_HYPER_NET + +#include "Occurrences.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// HyperNet declaration +// **************************************************************************************************** + +class HyperNet { +// *********** + +// Attributes +// ********** + + private: Occurrence _netOccurrence; + +// Constructors +// ************ + + public: HyperNet(const Occurrence& occurrence); + + private: HyperNet(const HyperNet& hyperNet); // not implemented to forbid copy construction + +// Operators +// ********* + + private: HyperNet& operator=(const HyperNet& hyperNet); // not implemented to forbid assignment + +// Accessors +// ********* + + public: const Occurrence& GetNetOccurrence() const {return _netOccurrence;}; + public: Cell* GetCell() const {return _netOccurrence.GetOwnerCell();}; + public: Occurrences GetNetOccurrences(bool doExtraction = false, bool allowInterruption = false) const; + public: Occurrences GetNetOccurrencesUnder(Box area, bool doExtraction = false, + bool allowInterruption = false) const; + public: Occurrences GetLeafPlugOccurrences(bool doExtraction = false , bool allowInterruption = false) const; + +// Predicates +// ********** + + public: bool IsValid() const {return _netOccurrence.IsValid();}; + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("HyperNet"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + +}; + +Occurrence GetHyperNetRootNetOccurrence(const Occurrence& netoccurrence); + +bool IsHyperNetRootNetOccurrence(Occurrence netoccurrence); + + + +} // End of Hurricane namespace. + + +PointerIOStreamSupport(Hurricane::HyperNet) + + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +#endif // HURRICANE_HYPER_NET + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Instance.cpp b/hurricane/src/hurricane/Instance.cpp new file mode 100644 index 00000000..29f983b9 --- /dev/null +++ b/hurricane/src/hurricane/Instance.cpp @@ -0,0 +1,708 @@ +// **************************************************************************************************** +// File: Instance.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment BULL-LIP6 + +#include "Instance.h" +#include "Cell.h" +#include "Net.h" +#include "Plug.h" +#include "SharedPath.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Filters declaration & implementation +// **************************************************************************************************** + +class Instance_IsUnderFilter : public Filter { +// **************************************************** + + public: Box _area; + + public: Instance_IsUnderFilter(const Box& area) + // ******************************************** + : _area(area) + { + }; + + public: Instance_IsUnderFilter(const Instance_IsUnderFilter& filter) + // ***************************************************************** + : _area(filter._area) + { + }; + + public: Instance_IsUnderFilter& operator=(const Instance_IsUnderFilter& filter) + // **************************************************************************** + { + _area = filter._area; + return *this; + }; + + public: virtual Filter* GetClone() const + // ************************************************ + { + return new Instance_IsUnderFilter(*this); + }; + + public: virtual bool Accept(Instance* instance) const + // ************************************************** + { + return _area.Intersect(instance->GetBoundingBox()); + }; + + public: virtual string _GetString() const + // ************************************** + { + return "<" + _TName("Instance::IsUnderFilter") + " " + GetString(_area) + ">"; + }; + +}; + +class Instance_IsTerminalFilter : public Filter { +// ******************************************************* + + public: Instance_IsTerminalFilter() {}; + + public: Instance_IsTerminalFilter(const Instance_IsTerminalFilter& filter) {}; + + public: Instance_IsTerminalFilter& operator=(const Instance_IsTerminalFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Instance_IsTerminalFilter(*this);}; + + public: virtual bool Accept(Instance* instance) const {return instance->IsTerminal();}; + + public: virtual string _GetString() const {return "<" + _TName("Instance::IsTerminalFilter") + ">";}; + +}; + +class Instance_IsLeafFilter : public Filter { +// ******************************************************* + + public: Instance_IsLeafFilter() {}; + + public: Instance_IsLeafFilter(const Instance_IsLeafFilter& filter) {}; + + public: Instance_IsLeafFilter& operator=(const Instance_IsLeafFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Instance_IsLeafFilter(*this);}; + + public: virtual bool Accept(Instance* instance) const {return instance->IsLeaf();}; + + public: virtual string _GetString() const {return "<" + _TName("Instance::IsLeafFilter") + ">";}; + +}; + +class Instance_IsUnplacedFilter : public Filter { +// ******************************************************* + + public: Instance_IsUnplacedFilter() {}; + + public: Instance_IsUnplacedFilter(const Instance_IsUnplacedFilter& filter) {}; + + public: Instance_IsUnplacedFilter& operator=(const Instance_IsUnplacedFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Instance_IsUnplacedFilter(*this);}; + + public: virtual bool Accept(Instance* instance) const {return instance->IsUnplaced();}; + + public: virtual string _GetString() const {return "<" + _TName("Net::IsUnplacedFilter>");}; + +}; + +class Instance_IsPlacedFilter : public Filter { +// ***************************************************** + + public: Instance_IsPlacedFilter() {}; + + public: Instance_IsPlacedFilter(const Instance_IsPlacedFilter& filter) {}; + + public: Instance_IsPlacedFilter& operator=(const Instance_IsPlacedFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Instance_IsPlacedFilter(*this);}; + + public: virtual bool Accept(Instance* instance) const {return instance->IsPlaced();}; + + public: virtual string _GetString() const {return "<" + _TName("Net::IsPlacedFilter>");}; + +}; + +class Instance_IsFixedFilter : public Filter { +// ***************************************************** + + public: Instance_IsFixedFilter() {}; + + public: Instance_IsFixedFilter(const Instance_IsFixedFilter& filter) {}; + + public: Instance_IsFixedFilter& operator=(const Instance_IsFixedFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Instance_IsFixedFilter(*this);}; + + public: virtual bool Accept(Instance* instance) const {return instance->IsFixed();}; + + public: virtual string _GetString() const {return "<" + _TName("Net::IsFixedFilter>");}; + +}; + +// **************************************************************************************************** +// Instance implementation +// **************************************************************************************************** + +Instance::Instance(Cell* cell, const Name& name, Cell* masterCell, const Transformation& transformation, const PlacementStatus& placementstatus, bool secureFlag) +// **************************************************************************************************** +: Inherit(), + _cell(cell), + _name(name), + _masterCell(masterCell), + _transformation(transformation), + _placementStatus(placementstatus), + _plugMap(), + _sharedPathMap(), + _nextOfCellInstanceMap(NULL), + _nextOfCellSlaveInstanceSet(NULL) +{ + if (!_cell) + throw Error("Can't create " + _TName("Instance") + " : null cell"); + + if (name.IsEmpty()) + throw Error("Can't create " + _TName("Instance") + " : empty name"); + + if (_cell->GetInstance(_name)) + throw Error("Can't create " + _TName("Instance") + " : already exists"); + + if (!_masterCell) + throw Error("Can't create " + _TName("Instance") + " : null master cell"); + + if (secureFlag && _cell->IsCalledBy(_masterCell)) + throw Error("Can't create " + _TName("Instance") + " : cyclic construction"); +} + +Instance* Instance::Create(Cell* cell, const Name& name, Cell* masterCell, bool secureFlag) +// **************************************************************************************** +{ + Instance* instance = + new Instance(cell, name, masterCell, Transformation(), PlacementStatus(), secureFlag); + + instance->_PostCreate(); + + return instance; +} + +Instance* Instance::Create(Cell* cell, const Name& name, Cell* masterCell, const Transformation& transformation, const PlacementStatus& placementstatus, bool secureFlag) +// **************************************************************************************************** +{ + Instance* instance = + new Instance(cell, name, masterCell, transformation, placementstatus, secureFlag); + + instance->_PostCreate(); + + return instance; +} + +Box Instance::GetBoundingBox() const +// ********************************* +{ + return _transformation.GetBox(_masterCell->GetBoundingBox()); +} + +Plugs Instance::GetConnectedPlugs() const +// ************************************** +{ + return GetPlugs().GetSubSet(Plug::GetIsConnectedFilter()); +} + +Plugs Instance::GetUnconnectedPlugs() const +// **************************************** +{ + return GetPlugs().GetSubSet(Plug::GetIsUnconnectedFilter()); +} + +Path Instance::GetPath(const Path& tailPath) const +// *********************************************** +{ + return Path((Instance*)this, tailPath); +} + +Box Instance::GetAbutmentBox() const +// ********************************* +{ + return _transformation.GetBox(_masterCell->GetAbutmentBox()); +} + +bool Instance::IsTerminal() const +// ****************************** +{ + return GetMasterCell()->IsTerminal(); +} + +bool Instance::IsLeaf() const +// ************************** +{ + return GetMasterCell()->IsLeaf(); +} + +InstanceFilter Instance::GetIsUnderFilter(const Box& area) +// ******************************************************* +{ + return Instance_IsUnderFilter(area); +} + +InstanceFilter Instance::GetIsTerminalFilter() +// ******************************************* +{ + return Instance_IsTerminalFilter(); +} + +InstanceFilter Instance::GetIsLeafFilter() +// ******************************************* +{ + return Instance_IsLeafFilter(); +} + +InstanceFilter Instance::GetIsUnplacedFilter() +// ******************************************* +{ + return Instance_IsUnplacedFilter(); +} + +InstanceFilter Instance::GetIsPlacedFilter() +// ***************************************** +{ + return Instance_IsPlacedFilter(); +} + +InstanceFilter Instance::GetIsFixedFilter() +// **************************************** +{ + return Instance_IsFixedFilter(); +} + +InstanceFilter Instance::GetIsNotUnplacedFilter() +// ********************************************** +{ + return !Instance_IsUnplacedFilter(); +} + +void Instance::Materialize() +// ************************* +{ + if (!IsMaterialized()) { + Box boundingBox = GetBoundingBox(); + if (!boundingBox.IsEmpty()) { + QuadTree* quadTree = _cell->_GetQuadTree(); + quadTree->Insert(this); + _cell->_Fit(quadTree->GetBoundingBox()); + } + } +} + +void Instance::Unmaterialize() +// *************************** +{ + if (IsMaterialized()) { + _cell->_Unfit(GetBoundingBox()); + _cell->_GetQuadTree()->Remove(this); + } +} + +void Instance::Invalidate(bool propagateFlag) +// ****************************************** +{ + Inherit::Invalidate(false); + + if (propagateFlag) { + for_each_plug(plug, GetConnectedPlugs()) { + plug->Invalidate(true); + end_for; + } + } +} + +void Instance::Translate(const Unit& dx, const Unit& dy) +// ***************************************************** +{ + if ((dx != 0) || (dy !=0)) { + Point translation = _transformation.GetTranslation(); + Unit x = translation.GetX() + dx; + Unit y = translation.GetY() + dy; + Transformation::Orientation orientation = _transformation.GetOrientation(); + SetTransformation(Transformation(x, y, orientation)); + } +} + +void Instance::SetName(const Name& name) +// ************************************* +{ + if (name != _name) { + if (name.IsEmpty()) + throw Error("Can't change instance name : empty name"); + + if (_cell->GetInstance(name)) + throw Error("Can't change instance name : already exists"); + + _cell->_GetInstanceMap()._Remove(this); + _name = name; + _cell->_GetInstanceMap()._Insert(this); + } +} + +void Instance::SetTransformation(const Transformation& transformation) +// ******************************************************************* +{ + if (transformation != _transformation) { + Invalidate(true); + _transformation = transformation; + } +} + +void Instance::SetPlacementStatus(const PlacementStatus& placementstatus) +// ********************************************************************** +{ +// if (placementstatus != _placementStatus) { +// Invalidate(true); + _placementStatus = placementstatus; +// } +} + +void Instance::SetMasterCell(Cell* masterCell, bool secureFlag) +// ************************************************************ +{ + if (masterCell != _masterCell) { + + if (!masterCell) + throw Error("Can't set master : null master cell"); + + if (secureFlag && _cell->IsCalledBy(masterCell)) + throw Error("Can't set master : cyclic construction"); + + list connectedPlugList; + list masterNetList; + for_each_plug(plug, GetConnectedPlugs()) { + Net* masterNet = masterCell->GetNet(plug->GetMasterNet()->GetName()); + if (!masterNet || !masterNet->IsExternal()) + throw Error("Can't set master (bad master net matching)"); + connectedPlugList.push_back(plug); + masterNetList.push_back(masterNet); + end_for; + } + + for_each_shared_path(sharedPath, _GetSharedPathes()) { + if (!sharedPath->GetTailSharedPath()) + // if the tail is empty the SharedPath isn't impacted by the change + delete sharedPath; + end_for; + } + + Invalidate(true); + + for_each_plug(plug, GetUnconnectedPlugs()) { + plug->_Delete(); + end_for; + } + + while (!connectedPlugList.empty() && !masterNetList.empty()) { + Plug* plug = connectedPlugList.front(); + Net* masterNet = masterNetList.front(); + _plugMap._Remove(plug); + plug->_SetMasterNet(masterNet); + _plugMap._Insert(plug); + connectedPlugList.pop_front(); + masterNetList.pop_front(); + } + + _masterCell->_GetSlaveInstanceSet()._Remove(this); + _masterCell = masterCell; + _masterCell->_GetSlaveInstanceSet()._Insert(this); + + for_each_net(externalNet, _masterCell->GetExternalNets()) { + if (!GetPlug(externalNet)) Plug::_Create(this, externalNet); + end_for; + } + } +} + +void Instance::_PostCreate() +// ************************* +{ + _cell->_GetInstanceMap()._Insert(this); + _masterCell->_GetSlaveInstanceSet()._Insert(this); + + for_each_net(externalNet, _masterCell->GetExternalNets()) { + Plug::_Create(this, externalNet); + end_for; + } + + Inherit::_PostCreate(); +} + +void Instance::_PreDelete() +// ************************ +{ + for_each_shared_path(sharedPath, _GetSharedPathes()) delete sharedPath; end_for; + + Inherit::_PreDelete(); + + for_each_plug(plug, GetPlugs()) plug->_Delete(); end_for; + + _masterCell->_GetSlaveInstanceSet()._Remove(this); + _cell->_GetInstanceMap()._Remove(this); +} + +string Instance::_GetString() const +// ******************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_name)); + s.insert(s.length() - 1, " " + GetString(_masterCell->GetName())); + return s; +} + +Record* Instance::_GetRecord() const +// *************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Cell", _cell)); + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("MasterCell", _masterCell)); + record->Add(GetSlot("Transformation", &_transformation)); + record->Add(GetSlot("PlacementStatus", _placementStatus)); + record->Add(GetSlot("XCenter", GetValue(GetAbutmentBox().GetXCenter()))); + record->Add(GetSlot("YCenter", GetValue(GetAbutmentBox().GetYCenter()))); + record->Add(GetSlot("Plugs", &_plugMap)); + record->Add(GetSlot("SharedPathes", &_sharedPathMap)); + } + return record; +} + +//void Instance::_DrawPhantoms(View* view, const Box& updateArea, const Transformation& transformation) +//// ************************************************************************************************** +//{ +// Symbol* symbol = _masterCell->GetSymbol(); +// if (!symbol) { +// Box masterArea = updateArea; +// Transformation masterTransformation = _transformation; +// _transformation.GetInvert().ApplyOn(masterArea); +// transformation.ApplyOn(masterTransformation); +// _masterCell->_DrawPhantoms(view, masterArea, masterTransformation); +// } +//} +// +//void Instance::_DrawBoundaries(View* view, const Box& updateArea, const Transformation& transformation) +//// **************************************************************************************************** +//{ +// Box masterArea = updateArea; +// Transformation masterTransformation = _transformation; +// _transformation.GetInvert().ApplyOn(masterArea); +// transformation.ApplyOn(masterTransformation); +// Symbol* symbol = _masterCell->GetSymbol(); +// if (!symbol) +// _masterCell->_DrawBoundaries(view, masterArea, masterTransformation); +// else +// _masterCell->GetSymbol()->_Draw(view, masterArea, masterTransformation); +//} +// +//void Instance::_DrawRubbers(View* view, const Box& updateArea, const Transformation& transformation) +//// ************************************************************************************************* +//{ +// Box masterArea = updateArea; +// Transformation masterTransformation = _transformation; +// _transformation.GetInvert().ApplyOn(masterArea); +// transformation.ApplyOn(masterTransformation); +// _masterCell->_DrawRubbers(view, masterArea, masterTransformation); +//} +// +//void Instance::_DrawMarkers(View* view, const Box& updateArea, const Transformation& transformation) +//// ************************************************************************************************* +//{ +// Box masterArea = updateArea; +// Transformation masterTransformation = _transformation; +// _transformation.GetInvert().ApplyOn(masterArea); +// transformation.ApplyOn(masterTransformation); +// _masterCell->_DrawMarkers(view, masterArea, masterTransformation); +//} +// +//void Instance::_DrawDisplaySlots(View* view, const Box& area, const Box& updateArea, const Transformation& transformation) +//// *********************************************************************************************************************** +//{ +// Box masterArea = updateArea; +// Transformation masterTransformation = _transformation; +// _transformation.GetInvert().ApplyOn(masterArea); +// transformation.ApplyOn(masterTransformation); +// _masterCell->_DrawDisplaySlots(view, area, masterArea, masterTransformation); +//} +// +//bool Instance::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +//// **************************************************************************************** +//{ +// Symbol* symbol = _masterCell->GetSymbol(); +// if (!symbol) +// return (view->PhantomsAreVisible() || view->BoundariesAreVisible()) && +// GetAbutmentBox().Intersect(Box(point).Inflate(aperture)); +// else { +// Point masterPoint = point; +// _transformation.GetInvert().ApplyOn(masterPoint); +// return (view->BoundariesAreVisible() && symbol->_IsInterceptedBy(view, masterPoint, aperture)); +// } +//} +// +//void Instance::_Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) +//// **************************************************************************************************** +//{ +// Symbol* symbol = _masterCell->GetSymbol(); +// if (!symbol) { +// Box masterArea = updateArea; +// Transformation masterTransformation = _transformation; +// _transformation.GetInvert().ApplyOn(masterArea); +// transformation.ApplyOn(masterTransformation); +// _masterCell->_DrawContent(view, basicLayer, masterArea, masterTransformation); +// } +//} +// +//void Instance::_Highlight(View* view, const Box& updateArea, const Transformation& transformation) +//// *********************************************************************************************** +//{ +// Symbol* symbol = _masterCell->GetSymbol(); +// if (!symbol) { +// Box abutmentBox = transformation.GetBox(GetAbutmentBox()); +// view->FillRectangle(abutmentBox); +// view->DrawRectangle(abutmentBox); +// +// if ( view->GetScale() > 1 ) +// { +// if ( view->IsTextVisible() ) +// { +// string text = GetString ( _name ) + " (" +// + GetString ( GetValue ( abutmentBox.GetXCenter () ) ) + "," +// + GetString ( GetValue ( abutmentBox.GetYCenter () ) ) + ")"; +// view->DrawString ( text, abutmentBox.GetXMin(), abutmentBox.GetYMax() ); +// } +// } +// } +// else { +// Box masterArea = updateArea; +// Transformation masterTransformation = _transformation; +// _transformation.GetInvert().ApplyOn(masterArea); +// transformation.ApplyOn(masterTransformation); +// symbol->_Highlight(view, masterArea, masterTransformation); +// } +//} +// + +// **************************************************************************************************** +// Instance::PlugMap implementation +// **************************************************************************************************** + +Instance::PlugMap::PlugMap() +// ************************* +: Inherit() +{ +} + +const Net* Instance::PlugMap::_GetKey(Plug* plug) const +// **************************************************** +{ + return plug->GetMasterNet(); +} + +unsigned Instance::PlugMap::_GetHashValue(const Net* masterNet) const +// ****************************************************************** +{ + return ( (unsigned int)( (unsigned long)masterNet ) ) / 8; +} + +Plug* Instance::PlugMap::_GetNextElement(Plug* plug) const +// ******************************************************* +{ + return plug->_GetNextOfInstancePlugMap(); +} + +void Instance::PlugMap::_SetNextElement(Plug* plug, Plug* nextPlug) const +// ********************************************************************** +{ + plug->_SetNextOfInstancePlugMap(nextPlug); +} + + + +// **************************************************************************************************** +// Instance::SharedPathMap implementation +// **************************************************************************************************** + +Instance::SharedPathMap::SharedPathMap() +// ************************************* +: Inherit() +{ +} + +const SharedPath* Instance::SharedPathMap::_GetKey(SharedPath* sharedPath) const +// ***************************************************************************** +{ + return sharedPath->GetTailSharedPath(); +} + +unsigned Instance::SharedPathMap::_GetHashValue(const SharedPath* tailSharedPath) const +// ************************************************************************************ +{ + return ( (unsigned int)( (unsigned long)tailSharedPath ) ) / 8; +} + +SharedPath* Instance::SharedPathMap::_GetNextElement(SharedPath* sharedPath) const +// ******************************************************************************* +{ + return sharedPath->_GetNextOfInstanceSharedPathMap(); +} + +void Instance::SharedPathMap::_SetNextElement(SharedPath* sharedPath, SharedPath* nextSharedPath) const +// **************************************************************************************************** +{ + sharedPath->_SetNextOfInstanceSharedPathMap(nextSharedPath); +}; + +// **************************************************************************************************** +// Instance::PlacementStatus implementation +// **************************************************************************************************** + +Instance::PlacementStatus::PlacementStatus(const Code& code) +// ********************************************************* +: _code(code) +{ +} + +Instance::PlacementStatus::PlacementStatus(const PlacementStatus& placementstatus) +// ******************************************************************************* +: _code(placementstatus._code) +{ +} + +Instance::PlacementStatus& Instance::PlacementStatus::operator=(const PlacementStatus& placementstatus) +// **************************************************************************************************** +{ + _code = placementstatus._code; + return *this; +} + +string Instance::PlacementStatus::_GetString() const +// ************************************************* +{ + return GetString(&_code); +} + +Record* Instance::PlacementStatus::_GetRecord() const +// ******************************************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Code", &_code)); + return record; +} + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Instance.h b/hurricane/src/hurricane/Instance.h new file mode 100644 index 00000000..b55ab417 --- /dev/null +++ b/hurricane/src/hurricane/Instance.h @@ -0,0 +1,231 @@ +// **************************************************************************************************** +// File: Instance.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment BULL-LIP6 + +#ifndef HURRICANE_INSTANCE +#define HURRICANE_INSTANCE + +#include "Go.h" +#include "Instances.h" +#include "Transformation.h" +#include "Plug.h" +#include "Path.h" +#include "SharedPath.h" +#include "IntrusiveMap.h" + +namespace Hurricane { + +class Net; +//class View; +class BasicLayer; + +// **************************************************************************************************** +// Instance declaration +// **************************************************************************************************** + +class Instance : public Go { +// *********************** + +// Types +// ***** + + public: typedef Go Inherit; + + public: class PlacementStatus { + // ************************** + + public: enum Code {UNPLACED=0, PLACED=1, FIXED=2}; + + private: Code _code; + + public: PlacementStatus(const Code& code = UNPLACED); + public: PlacementStatus(const PlacementStatus& placementstatus); + + public: PlacementStatus& operator=(const PlacementStatus& placementstatus); + + public: operator const Code&() const {return _code;}; + + public: const Code& GetCode() const {return _code;}; + + public: string _GetTypeName() const { return _TName("Instance::PlacementStatus"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + }; + + public: class PlugMap : public IntrusiveMap { + // ********************************************************** + + public: typedef IntrusiveMap Inherit; + + public: PlugMap(); + + public: virtual const Net* _GetKey(Plug* plug) const; + public: virtual unsigned _GetHashValue(const Net* masterNet) const; + public: virtual Plug* _GetNextElement(Plug* plug) const; + public: virtual void _SetNextElement(Plug* plug, Plug* nextPlug) const; + + }; + + public: class SharedPathMap : public IntrusiveMap { + // ***************************************************************************** + + public: typedef IntrusiveMap Inherit; + + public: SharedPathMap(); + + public: virtual const SharedPath* _GetKey(SharedPath* sharedPath) const; + public: virtual unsigned _GetHashValue(const SharedPath* tailSharedPath) const; + public: virtual SharedPath* _GetNextElement(SharedPath* sharedPath) const; + public: virtual void _SetNextElement(SharedPath* sharedPath, SharedPath* nextSharedPath) const; + + }; + +// Attributes +// ********** + + private: Cell* _cell; + private: Name _name; + private: Cell* _masterCell; + private: Transformation _transformation; + private: PlacementStatus _placementStatus; + private: PlugMap _plugMap; + private: SharedPathMap _sharedPathMap; + private: Instance* _nextOfCellInstanceMap; + private: Instance* _nextOfCellSlaveInstanceSet; + +// Constructors +// ************ + + protected: Instance(Cell* cell, const Name& name, Cell* masterCell, const Transformation& transformation, const PlacementStatus& placementstatus, bool secureFlag); + + public: static Instance* Create(Cell* cell, const Name& name, Cell* masterCell, bool secureFlag = true); + public: static Instance* Create(Cell* cell, const Name& name, Cell* masterCell, const Transformation& transformation, const PlacementStatus& placementstatus, bool secureFlag = true); + +// Accessors +// ********* + + public: virtual Cell* GetCell() const {return _cell;}; + public: virtual Box GetBoundingBox() const; + public: const Name& GetName() const {return _name;}; + public: Cell* GetMasterCell() const {return _masterCell;}; + public: const Transformation& GetTransformation() const {return _transformation;}; + public: const PlacementStatus& GetPlacementStatus() const {return _placementStatus;}; + public: Plug* GetPlug(const Net* masterNet) const {return _plugMap.GetElement(masterNet);}; + public: Plugs GetPlugs() const {return _plugMap.GetElements();}; + public: Plugs GetConnectedPlugs() const; + public: Plugs GetUnconnectedPlugs() const; + public: Path GetPath(const Path& tailPath = Path()) const; + public: Box GetAbutmentBox() const; + +// Predicates +// ********** + + public: bool IsUnplaced() const {return _placementStatus == PlacementStatus::UNPLACED;}; + public: bool IsPlaced() const {return _placementStatus == PlacementStatus::PLACED;}; + public: bool IsFixed() const {return _placementStatus == PlacementStatus::FIXED;}; + public: bool IsTerminal() const; + public: bool IsLeaf() const; + +// Filters +// ******* + + public: static InstanceFilter GetIsUnderFilter(const Box& area); + public: static InstanceFilter GetIsTerminalFilter(); + public: static InstanceFilter GetIsLeafFilter(); + public: static InstanceFilter GetIsUnplacedFilter(); + public: static InstanceFilter GetIsPlacedFilter(); + public: static InstanceFilter GetIsFixedFilter(); + public: static InstanceFilter GetIsNotUnplacedFilter(); + +// Updators +// ******** + + public: virtual void Materialize(); + public: virtual void Unmaterialize(); + public: virtual void Invalidate(bool propagateFlag = true); + public: virtual void Translate(const Unit& dx, const Unit& dy); + + public: void SetName(const Name& name); + public: void SetTransformation(const Transformation& transformation); + public: void SetPlacementStatus(const PlacementStatus& placementstatus); + public: void SetMasterCell(Cell* masterCell, bool secureFlag = true); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("Instance");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: PlugMap& _GetPlugMap() {return _plugMap;}; + public: SharedPath* _GetSharedPath(const SharedPath* tailSharedPath) const {return _sharedPathMap.GetElement(tailSharedPath);} + public: SharedPathes _GetSharedPathes() const {return _sharedPathMap.GetElements();}; + public: SharedPathMap& _GetSharedPathMap() {return _sharedPathMap;}; + public: Instance* _GetNextOfCellInstanceMap() const {return _nextOfCellInstanceMap;}; + public: Instance* _GetNextOfCellSlaveInstanceSet() const {return _nextOfCellSlaveInstanceSet;}; + + public: void _SetNextOfCellInstanceMap(Instance* instance) {_nextOfCellInstanceMap = instance;}; + public: void _SetNextOfCellSlaveInstanceSet(Instance* instance) {_nextOfCellSlaveInstanceSet = instance;}; + + //public: void _DrawPhantoms(View* view, const Box& updateArea, const Transformation& transformation); + //public: void _DrawBoundaries(View* view, const Box& updateArea, const Transformation& transformation); + //public: void _DrawRubbers(View* view, const Box& updateArea, const Transformation& transformation); + //public: void _DrawMarkers(View* view, const Box& updateArea, const Transformation& transformation); + //public: void _DrawDisplaySlots(View* view, const Box& area, const Box& updateArea, const Transformation& transformation); + + //public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; + //public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation); + //public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName + ( const Instance::PlacementStatus::Code* object ) + { return ">"; } + +template<> + inline string ProxyString + ( const Instance::PlacementStatus::Code* object ) + { + switch ( *object ) { + case Instance::PlacementStatus::UNPLACED: return "PLACED"; + case Instance::PlacementStatus::PLACED: return "PLACED"; + case Instance::PlacementStatus::FIXED: return "FIXED"; + } + return "ABNORMAL"; + } + +template<> + inline Record* ProxyRecord + ( const Instance::PlacementStatus::Code* object ) + { + Record* record = new Record(GetString(object)); + record->Add(GetSlot("Code", (unsigned int*)object)); + return record; + } + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Instance) + +#endif // HURRICANE_INSTANCE + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Instances.h b/hurricane/src/hurricane/Instances.h new file mode 100644 index 00000000..e74f6023 --- /dev/null +++ b/hurricane/src/hurricane/Instances.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Instances.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_INSTANCES +#define HURRICANE_INSTANCES + +#include "Collection.h" + +namespace Hurricane { + +class Instance; + + + +// **************************************************************************************************** +// Instances declaration +// **************************************************************************************************** + +typedef GenericCollection Instances; + + + +// **************************************************************************************************** +// InstanceLocator declaration +// **************************************************************************************************** + +typedef GenericLocator InstanceLocator; + + + +// **************************************************************************************************** +// InstanceFilter declaration +// **************************************************************************************************** + +typedef GenericFilter InstanceFilter; + + + +// **************************************************************************************************** +// for_each_instance declaration +// **************************************************************************************************** + +#define for_each_instance(instance, instances)\ +/*********************************************/\ +{\ + InstanceLocator _locator = instances.GetLocator();\ + while (_locator.IsValid()) {\ + Instance* instance = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_INSTANCES + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Interruption.cpp b/hurricane/src/hurricane/Interruption.cpp new file mode 100644 index 00000000..755a9ac9 --- /dev/null +++ b/hurricane/src/hurricane/Interruption.cpp @@ -0,0 +1,55 @@ +// **************************************************************************************************** +// File: Interruption.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Interruption.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Interruption implementation +// **************************************************************************************************** + +Interruption::Interruption(const string& reason, int code) +// ******************************************************* +: Inherit(), + _reason(reason), + _code(code) +{ +} + +Interruption::Interruption(const Interruption& interruption) +// ********************************************************* +: Inherit(), + _reason(interruption._reason), + _code(interruption._code) +{ +} + +Interruption& Interruption::operator=(const Interruption& interruption) +// ******************************************************************** +{ + _reason = interruption._reason; + _code = interruption._code; + return *this; +} + +string Interruption::_GetString() const +// ************************************ +{ + if (!_code) return "[INTERRUPTION] " + _reason; + + return "[INTERRUPTION:" + GetString(_code) + "] " + _reason; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Interruption.h b/hurricane/src/hurricane/Interruption.h new file mode 100644 index 00000000..8032bcc6 --- /dev/null +++ b/hurricane/src/hurricane/Interruption.h @@ -0,0 +1,71 @@ +// **************************************************************************************************** +// File: Interruption.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_INTERRUPTION +#define HURRICANE_INTERRUPTION + +#include "Exception.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Interruption declaration +// **************************************************************************************************** + +class Interruption : public Exception { +// ********************************** + +// Types +// ***** + + public: typedef Exception Inherit; + +// Attributes +// ********** + + private: string _reason; + private: int _code; + +// Constructors +// ************ + + public: Interruption(const string& reason, int code = 0); + + public: Interruption(const Interruption& interruption); + +// Operators +// ********* + + public: Interruption& operator=(const Interruption& interruption); + +// Accessors +// ********* + + public: string GetReason() const {return _reason;}; + public: int GetCode() const {return _code;}; + +// Others +// ****** + + public: virtual string _GetTypeName() const { return _TName("Interruption"); }; + public: virtual string _GetString() const; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Interruption) + + +#endif // HURRICANE_INTERRUPTION + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Interval.cpp b/hurricane/src/hurricane/Interval.cpp new file mode 100644 index 00000000..3ca73bc2 --- /dev/null +++ b/hurricane/src/hurricane/Interval.cpp @@ -0,0 +1,232 @@ +// **************************************************************************************************** +// File: Interval.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Interval.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Interval implementation +// **************************************************************************************************** + +Interval::Interval(bool makeEmpty) +// ******************************* +: _vMin(1), + _vMax(-1) +{ + if (!makeEmpty) { + _vMin = UNIT_MIN; + _vMax = UNIT_MAX; + } +} + +Interval::Interval(const Unit& value) +// ********************************** +: _vMin(value), + _vMax(value) +{ +} + +Interval::Interval(const Unit& v1, const Unit& v2) +// *********************************************** +: _vMin(min(v1, v2)), + _vMax(max(v1, v2)) +{ +} + +Interval::Interval(const Interval& interval) +// ***************************************** +: _vMin(interval._vMin), + _vMax(interval._vMax) +{ +} + +Interval& Interval::operator=(const Interval& interval) +// **************************************************** +{ + _vMin = interval._vMin; + _vMax = interval._vMax; + return *this; +} + +bool Interval::operator==(const Interval& interval) const +// ****************************************************** +{ + return !IsEmpty() && !interval.IsEmpty() && (_vMin == interval._vMin) && (_vMax == interval._vMax); +} + +bool Interval::operator!=(const Interval& interval) const +// ****************************************************** +{ + return IsEmpty() || interval.IsEmpty() || (_vMin != interval._vMin) || (_vMax != interval._vMax); +} + +Interval Interval::GetUnion(const Interval& interval) const +// ******************************************************** +{ + if (IsEmpty() && interval.IsEmpty()) return Interval(); + return Interval(min(_vMin, interval._vMin), max(_vMax, interval._vMax)); +} + +Interval Interval::GetIntersection(const Interval& interval) const +// *************************************************************** +{ + if (!Intersect(interval)) return Interval(); + return Interval(max(_vMin, interval._vMin), min(_vMax, interval._vMax)); +} + +bool Interval::IsEmpty() const +// *************************** +{ + return (_vMax < _vMin); +} + +bool Interval::IsPonctual() const +// ****************************** +{ + return (_vMax == _vMin); +} + +bool Interval::Contains(const Unit& v) const +// ***************************************** +{ + return !IsEmpty() && (_vMin <= v) && (v <= _vMax); +} + +bool Interval::Contains(const Interval& interval) const +// **************************************************** +{ + return !IsEmpty() && !interval.IsEmpty() && (_vMin <= interval._vMin) && (interval._vMax <= _vMax); +} + +bool Interval::Intersect(const Interval& interval) const +// ***************************************************** +{ + return !IsEmpty() && !interval.IsEmpty() && !((_vMax < interval._vMin) || (interval._vMax < _vMin)); +} + +bool Interval::Inferior(const Interval& interval, bool strict) const +// ***************************************************************** +{ + if (_vMax < interval._vMin) return true; + return !strict && (_vMax == interval._vMin); +} + +bool Interval::Superior(const Interval& interval, bool strict) const +// ***************************************************************** +{ + if (_vMin > interval._vMax) return true; + return !strict && (_vMin == interval._vMax); +} + +bool Interval::IsConstrainedBy(const Interval& interval) const +// *********************************************************** +{ + return (!IsEmpty() && + !interval.IsEmpty() && + ((_vMin == interval.GetVMin()) || (_vMax == interval.GetVMax()))); +} + +Interval& Interval::MakeEmpty() +// **************************** +{ + _vMin = 1; + _vMax = -1; + return *this; +} + +Interval& Interval::Inflate(const Unit& dv) +// **************************************** +{ + return Inflate(dv, dv); +} + +Interval& Interval::Inflate(const Unit& dvMin, const Unit& dvMax) +// ************************************************************** +{ + if (!IsEmpty()) { + _vMin -= dvMin; + _vMax += dvMax; + } + return *this; +} + +Interval& Interval::Merge(const Unit& v) +// ************************************* +{ + if (IsEmpty()) { + _vMin = v; + _vMax = v; + } + else { + _vMin = min(_vMin, v); + _vMax = max(_vMax, v); + } + return *this; +} + +Interval& Interval::Merge(const Interval& interval) +// ************************************************ +{ + if (!interval.IsEmpty()) { + _vMin = min(_vMin, interval._vMin); + _vMax = max(_vMax, interval._vMax); + } + return *this; +} + +Interval& Interval::Intersection(const Unit& vMin, const Unit& vMax) +// ***************************************************************** +{ + return Intersection(Interval(vMin,vMax)); +} + +Interval& Interval::Intersection(const Interval& interval) +// ******************************************************* +{ + if (!Intersect(interval)) MakeEmpty(); + else { + _vMin = max(_vMin, interval._vMin); + _vMax = min(_vMax, interval._vMax); + } + + return *this; +} + +Interval& Interval::Translate(const Unit& dv) +// ****************************************** +{ + if (!IsEmpty()) { + _vMin += dv; + _vMax += dv; + } + return *this; +} + +string Interval::_GetString() const +// ******************************** +{ + return "<" + _TName("Interval") + " " + GetValueString(_vMin) + " " + GetValueString(_vMax) + ">"; +} + +Record* Interval::_GetRecord() const +// *************************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("VMin", &_vMin)); + record->Add(GetSlot("VMin", &_vMax)); + return record; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Interval.h b/hurricane/src/hurricane/Interval.h new file mode 100644 index 00000000..6450da3b --- /dev/null +++ b/hurricane/src/hurricane/Interval.h @@ -0,0 +1,103 @@ +// **************************************************************************************************** +// File: Interval.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_INTERVAL +#define HURRICANE_INTERVAL + +#include "Unit.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Interval declaration +// **************************************************************************************************** + +class Interval { +// *********** + +// Attributes +// ********** + + private: Unit _vMin; + private: Unit _vMax; + +// Constructors +// ************ + + public: Interval(bool makeEmpty=true); + public: Interval(const Unit& v); + public: Interval(const Unit& v1, const Unit& v2); + public: Interval(const Interval& interval); + +// Operators +// ********* + + public: Interval& operator=(const Interval& interval); + + public: bool operator==(const Interval& interval) const; + public: bool operator!=(const Interval& interval) const; + +// Accessors +// ********* + + public: const Unit& GetVMin() const {return _vMin;}; + public: const Unit& GetVMax() const {return _vMax;}; + public: Unit& GetVMin() {return _vMin;}; + public: Unit& GetVMax() {return _vMax;}; + public: Unit GetCenter() const {return ((_vMin + _vMax) / 2);}; + public: Unit GetSize() const {return (_vMax - _vMin);}; + public: Unit GetHalfSize() const {return (GetSize() / 2);}; + public: Interval GetUnion(const Interval& interval) const; + public: Interval GetIntersection(const Interval& interval) const; + +// Predicates +// ********** + + public: bool IsEmpty() const; + public: bool IsPonctual() const; + public: bool Contains(const Unit& v) const; + public: bool Contains(const Interval& interval) const; + public: bool Intersect(const Interval& interval) const; + public: bool Inferior(const Interval& interval, bool strict=true) const; + public: bool Superior(const Interval& interval, bool strict=true) const; + public: bool IsConstrainedBy(const Interval& interval) const; + +// Updators +// ******** + + public: Interval& MakeEmpty(); + public: Interval& Inflate(const Unit& dv); + public: Interval& Inflate(const Unit& dvMin, const Unit& dvMax); + public: Interval& Merge(const Unit& v); + public: Interval& Merge(const Interval& interval); + public: Interval& Intersection(const Unit& vMin, const Unit& vMax); + public: Interval& Intersection(const Interval& interval); + public: Interval& Translate(const Unit& dv); + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("Interval"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + +}; + + + +} // End of Hurricane namespace. + + +ValueIOStreamSupport(Hurricane::Interval) + + +#endif // HURRICANE_INTERVAL + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Intervals.h b/hurricane/src/hurricane/Intervals.h new file mode 100644 index 00000000..095c82dd --- /dev/null +++ b/hurricane/src/hurricane/Intervals.h @@ -0,0 +1,61 @@ +// **************************************************************************************************** +// File: Intervals.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_INTERVALS +#define HURRICANE_INTERVALS + +#include "Collection.h" +#include "Interval.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Intervals declaration +// **************************************************************************************************** + +typedef GenericCollection Intervals; + + + +// **************************************************************************************************** +// IntervalLocator declaration +// **************************************************************************************************** + +typedef GenericLocator IntervalLocator; + + + +// **************************************************************************************************** +// IntervalFilter declaration +// **************************************************************************************************** + +typedef GenericFilter IntervalFilter; + + + +// **************************************************************************************************** +// for_each_interval declaration +// **************************************************************************************************** + +#define for_each_interval(interval, intervals)\ +/*********************************************/\ +{\ + IntervalLocator _locator = intervals.GetLocator();\ + while (_locator.IsValid()) {\ + Interval interval = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_INTERVALS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/IntrusiveMap.h b/hurricane/src/hurricane/IntrusiveMap.h new file mode 100644 index 00000000..534a08f6 --- /dev/null +++ b/hurricane/src/hurricane/IntrusiveMap.h @@ -0,0 +1,449 @@ +// **************************************************************************************************** +// File: IntrusiveMap.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_INTRUSIVE_MAP +#define HURRICANE_INTRUSIVE_MAP + +#include + +#include "Collection.h" +#include "Error.h" // AD + +namespace Hurricane { + + + +// **************************************************************************************************** +// IntrusiveMap declaration +// **************************************************************************************************** + +template class IntrusiveMap { +// ************************************************** + +// Types +// ***** + + class Elements : public Collection { + // ***************************************** + + // Types + // ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ******************************************************** + + // Types + // ***** + + public: typedef Hurricane::Locator Inherit; + + // Attributes + // ********** + + private: const IntrusiveMap* _map; + private: unsigned _index; + private: Element* _element; + + // Constructors + // ************ + + public: Locator(const IntrusiveMap* map = NULL) + // ******************************************** + : Inherit(), + _map(map), + _index(0), + _element(NULL) + { + if (_map) { + unsigned length = _map->_GetLength(); + do { + _element = _map->_GetArray()[_index++]; + } while (!_element && (_index < length)); + } + }; + + public: Locator(const Locator& locator) + // ************************************ + : Inherit(), + _map(locator._map), + _index(locator._index), + _element(locator._element) + { + }; + + // Operators + // ********* + + public: Locator& operator=(const Locator& locator) + // *********************************************** + { + _map = locator._map; + _index = locator._index; + _element = locator._element; + return *this; + }; + + // Accessors + // ********* + + public: virtual Element* GetElement() const + // **************************************** + { + return _element; + }; + + public: virtual Hurricane::Locator* GetClone() const + // *********************************************************** + { + return new Locator(*this); + }; + + // Predicates + // ********** + + public: virtual bool IsValid() const + // ********************************* + { + return (_element != NULL); + }; + + // Updators + // ******** + + public: virtual void Progress() + // **************************** + { + if (_element) { + _element = _map->_GetNextElement(_element); + if (!_element) { + unsigned length = _map->_GetLength(); + if (_index < length) { + do { + _element = _map->_GetArray()[_index++]; + } while (!_element && (_index < length)); + } + } + } + }; + + // Others + // ****** + + public: virtual string _GetString() const + // ************************************** + { + string s = "<" + _TName("IntrusiveMap::Elements::Locator"); + if (_map) s += " " + GetString(_map); + s += ">"; + return s; + }; + + }; + + // Attributes + // ********** + + private: const IntrusiveMap* _map; + + // Constructors + // ************ + + public: Elements(const IntrusiveMap* map = NULL) + // ********************************************* + : Inherit(), + _map(map) + { + }; + + public: Elements(const Elements& elements) + // *************************************** + : Inherit(), + _map(elements._map) + { + }; + + // Operators + // ********* + + public: Elements& operator=(const Elements& elements) + // ************************************************** + { + _map = elements._map; + return *this; + }; + + // Accessors + // ********* + + public: virtual Collection* GetClone() const + // *************************************************** + { + return new Elements(*this); + }; + + public: virtual Hurricane::Locator* GetLocator() const + // ************************************************************* + { + return new Locator(_map); + }; + + // Others + // ****** + + public: virtual string _GetString() const + // ************************************** + { + string s = "<" + _TName("IntrusiveMap::Elements"); + if (_map) s += " " + GetString(_map); + s += ">"; + return s; + }; + + }; + +// Attributes +// ********** + + private: unsigned _size; + private: unsigned _length; + private: Element** _array; + +// Constructors +// ************ + + public: IntrusiveMap() + // ******************* + : _size(0), + _length(1), + _array(new Element*[1]) + { + _array[0] = NULL; + }; + + private: IntrusiveMap(const IntrusiveMap& map); // not implemented to forbid copy + +// Destructor +// ********** + + public: virtual ~IntrusiveMap() + // **************************** + { + for (unsigned index = 0; index < _length; index++) { + Element* element = _array[index]; + while (element) { + _array[index] = _GetNextElement(element); + _SetNextElement(element, NULL); + element = _array[index]; + } + _array[index] = NULL; + } + delete[] _array; + }; + +// Operators +// ********* + + private: IntrusiveMap& operator=(const IntrusiveMap& map); // not implemented to forbid assignment + +// Accessors +// ********* + + public: Element* GetElement(Key key) const + // *************************************** + { + unsigned index = (_GetHashValue(key) / 8) % _length; + Element* element = _array[index]; + while (element && (_GetKey(element) != key)) element = _GetNextElement(element); + return element; + }; + + public: Elements GetElements() const + // ********************************* + { + return Elements(this); + }; + +// Predicates +// ********** + + public: bool IsEmpty() const + // ************************* + { + return (_size == 0); + }; + +// Overridables +// ************ + + public: virtual Key _GetKey(Element* element) const = 0; + + public: virtual unsigned _GetHashValue(Key key) const = 0; + + // public: virtual Element* _GetNextElement(Element* element) const = 0; // AD + public: virtual Element* _GetNextElement(Element* element) const + // ************************************************************* + { + throw Error(_TName("IntrusiveMap") + "::_GetNextElement(...) : should be overrided"); + return NULL; + }; + + // public: virtual void _SetNextElement(Element* element, Element* nextElement) const = 0; // AD + public: virtual void _SetNextElement(Element* element, Element* nextElement) const + // ******************************************************************************* + { + throw Error(_TName("IntrusiveMap") + "::_SetNextElement(...) : should be overrided"); + }; + +// Others +// ****** + + public: string _GetTypeName() const + // ******************************** + { + return _TName("IntrusiveMap"); + } + + public: string _GetString() const + // ****************************** + { + if (IsEmpty()) + return "<" + _GetTypeName() + " empty>"; + else + return "<" + _GetTypeName() + " " + GetString(_size) + ">"; + }; + + public: Record* _GetRecord() const + // ************************* + { + Record* record = NULL; + if (!IsEmpty()) { + record = new Record(GetString(this)); + unsigned n = 1; + for (unsigned index = 0; index < _length; index++) { + /**/ + n = 1; + /**/ + Element* element = _array[index]; + while (element) { + // record->Add(GetSlot(GetString(n++), element)); + record->Add(GetSlot(GetString(index) + ":" + GetString(n++), element)); + /**/ + element = _GetNextElement(element); + } + } + } + return record; + }; + + public: unsigned _GetSize() const + // ****************************** + { + return _size; + }; + + public: unsigned _GetLength() const + // ******************************** + { + return _length; + }; + + public: Element** _GetArray() const + // ******************************** + { + return _array; + }; + + public: bool _Contains(Element* element) const + // ******************************************* + { + unsigned index = (_GetHashValue(_GetKey(element)) / 8) % _length; + Element* currentElement = _array[index]; + while (currentElement && (currentElement != element)) + currentElement = _GetNextElement(currentElement); + return (currentElement != NULL); + }; + + public: void _Insert(Element* element) + // *********************************** + { + if (!_Contains(element)) { + unsigned index = (_GetHashValue(_GetKey(element)) / 8) % _length; + _SetNextElement(element, _array[index]); + _array[index] = element; + _size++; + _Resize(); + } + }; + + public: void _Remove(Element* element) + // *********************************** + { + if (_Contains(element)) { + unsigned index = (_GetHashValue(_GetKey(element)) / 8) % _length; + Element* currentElement = _array[index]; + if (currentElement) { + if (currentElement == element) { + _array[index] = _GetNextElement(element); + _SetNextElement(element, NULL); + _size--; + } + else { + while (_GetNextElement(currentElement) && (_GetNextElement(currentElement) != element)) + currentElement = _GetNextElement(currentElement); + if (currentElement && (_GetNextElement(currentElement) == element)) { + _SetNextElement(currentElement, _GetNextElement(element)); + _SetNextElement(element, NULL); + _size--; + } + } + } + } + }; + + public: void _Resize() + // ******************* + { + unsigned newLength = _length; + double ratio = (double)_size / (double)_length; + if (ratio < 3) + newLength = max(_size / 8, (unsigned)1); + else if (10 < ratio) + newLength = min(_size / 5, (unsigned)512); + + if (newLength != _length) { + // cerr << "Resizing: " << this << " " << _length << " " << newLength << endl; + unsigned oldLength = _length; + Element** oldArray = _array; + _length = newLength; + _array = new Element*[_length]; + memset(_array, 0, _length * sizeof(Element*)); + for (unsigned index = 0; index < oldLength; index++) { + Element* element = oldArray[index]; + while (element) { + Element* nextElement = _GetNextElement(element); + unsigned newIndex = (_GetHashValue(_GetKey(element)) / 8) % _length; + _SetNextElement(element, _array[newIndex]); + _array[newIndex] = element; + element = nextElement; + } + } + delete[] oldArray; + } + }; + +}; + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_INTRUSIVE_MAP + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/IntrusiveSet.h b/hurricane/src/hurricane/IntrusiveSet.h new file mode 100644 index 00000000..10193c7d --- /dev/null +++ b/hurricane/src/hurricane/IntrusiveSet.h @@ -0,0 +1,470 @@ +// **************************************************************************************************** +// File: IntrusiveSet.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_INTRUSIVE_SET +#define HURRICANE_INTRUSIVE_SET + +#include + +#include "Collection.h" +#include "Error.h" // AD + +namespace Hurricane { + + + +// **************************************************************************************************** +// IntrusiveSet declaration +// **************************************************************************************************** + +template class IntrusiveSet : public NestedSlotAdapter { +// ****************************************************************** + +// Types +// ***** + + class Elements : public Collection { + // ***************************************** + + // Types + // ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ******************************************************** + + // Types + // ***** + + public: typedef Hurricane::Locator Inherit; + + // Attributes + // ********** + + private: const IntrusiveSet* _set; + private: unsigned _index; + private: Element* _element; + + // Constructors + // ************ + + public: Locator(const IntrusiveSet* set = NULL) + // ******************************************** + : Inherit(), + _set(set), + _index(0), + _element(NULL) + { + if (_set) { + unsigned length = _set->_GetLength(); + do { + _element = _set->_GetArray()[_index++]; + } while (!_element && (_index < length)); + } + }; + + public: Locator(const Locator& locator) + // ************************************ + : Inherit(), + _set(locator._set), + _index(locator._index), + _element(locator._element) + { + }; + + // Operators + // ********* + + public: Locator& operator=(const Locator& locator) + // *********************************************** + { + _set = locator._set; + _index = locator._index; + _element = locator._element; + return *this; + }; + + // Accessors + // ********* + + public: virtual Element* GetElement() const + // **************************************** + { + return _element; + }; + + public: virtual Hurricane::Locator* GetClone() const + // *********************************************************** + { + return new Locator(_set); + }; + + // Predicates + // ********** + + public: virtual bool IsValid() const + // ********************************* + { + return (_element != NULL); + }; + + // Updators + // ******** + + public: virtual void Progress() + // **************************** + { + if (_element) { + _element = _set->_GetNextElement(_element); + if (!_element) { + unsigned length = _set->_GetLength(); + if (_index < length) { + do { + _element = _set->_GetArray()[_index++]; + } while (!_element && (_index < length)); + } + } + } + }; + + // Others + // ****** + + public: virtual string _GetTypeName() const + // **************************************** + { + return _TName("IntrusiveSet::Elements::Locator"); + }; + + public: virtual string _GetString() const + // ************************************** + { + string s = "<" + _GetTypeName(); + if (_set) s += " " + GetString(_set); + s += ">"; + return s; + }; + + }; + + // Attributes + // ********** + + private: const IntrusiveSet* _set; + + // Constructors + // ************ + + public: Elements(const IntrusiveSet* set = NULL) + // ********************************************* + : Inherit(), + _set(set) + { + }; + + public: Elements(const Elements& elements) + // *************************************** + : Inherit(), + _set(elements._set) + { + }; + + // Operators + // ********* + + public: Elements& operator=(const Elements& elements) + // ************************************************** + { + _set = elements._set; + return *this; + }; + + // Accessors + // ********* + + public: virtual Collection* GetClone() const + // *************************************************** + { + return new Elements(*this); + }; + + public: virtual Hurricane::Locator* GetLocator() const + // ************************************************************* + { + return new Locator(_set); + }; + + // Others + // ****** + + public: virtual string _GetTypeName() const + // ************************************** + { + return _TName("IntrusiveSet::Elements"); + }; + + public: virtual string _GetString() const + // ************************************** + { + string s = "<" + _GetTypeName(); + if (_set) s += " " + GetString(_set); + s += ">"; + return s; + }; + + }; + +// Attributes +// ********** + + private: unsigned _size; + private: unsigned _length; + private: Element** _array; + +// Constructors +// ************ + + public: IntrusiveSet() + // ******************* + : _size(0), + _length(1), + _array(new Element*[1]) + { + _array[0] = NULL; + }; + + private: IntrusiveSet(const IntrusiveSet& set); // not implemented to forbid copy + +// Destructor +// ********** + + public: virtual ~IntrusiveSet() + // **************************** + { + for (unsigned index = 0; index < _length; index++) { + Element* element = _array[index]; + while (element) { + _array[index] = _GetNextElement(element); + _SetNextElement(element, NULL); + element = _array[index]; + } + _array[index] = NULL; + } + delete[] _array; + }; + +// Operators +// ********* + + private: IntrusiveSet& operator=(const IntrusiveSet& set); // not implemented to forbid assignment + +// Accessors +// ********* + + public: Elements GetElements() const + // ********************************* + { + return Elements(this); + }; + +// Predicates +// ********** + + public: bool IsEmpty() const + // ************************* + { + return (_size == 0); + }; + +// Overridables +// ************ + + public: virtual unsigned _GetHashValue(Element* element) const = 0; + + // public: virtual Element* _GetNextElement(Element* element) const = 0; // AD + public: virtual Element* _GetNextElement(Element* element) const + // ************************************************************* + { + throw Error(_TName("IntrusiveSet") + "::_GetNextElement(...) : should be overrided"); + return NULL; + }; + + // public: virtual void _SetNextElement(Element* element, Element* nextElement) const = 0; // AD + public: virtual void _SetNextElement(Element* element, Element* nextElement) const + // ******************************************************************************* + { + throw Error(_TName("IntrusiveSet") + "::_SetNextElement(...) : should be overrided"); + }; + +// Others +// ****** + + public: virtual string _GetTypeName() const + // ************************************** + { + return _TName("InstrusiveSet"); + }; + + public: string _GetString() const + // ****************************** + { + if (IsEmpty()) + return "<" + _GetTypeName() + " empty>"; + else + return "<" + _GetTypeName() + " " + GetString(_size) + ">"; + }; + + public: Record* _GetRecord() const + // ************************* + { + Record* record = NULL; + if (!IsEmpty()) { + record = new Record(GetString(this)); + unsigned n = 1; + for (unsigned index = 0; index < _length; index++) { + /**/ + n = 1; + /**/ + Element* element = _array[index]; + while (element) { + // record->Add(GetSlot(GetString(n++), element)); + record->Add(GetSlot(GetString(index) + ":" + GetString(n++), element)); + /**/ + element = _GetNextElement(element); + } + } + } + return record; + }; + + public: unsigned _GetSize() const + // ****************************** + { + return _size; + }; + + public: unsigned _GetLength() const + // ******************************** + { + return _length; + }; + + public: Element** _GetArray() const + // ******************************** + { + return _array; + }; + + public: bool _Contains(Element* element) const + // ******************************************* + { + unsigned index = (_GetHashValue(element) / 8) % _length; + Element* currentElement = _array[index]; + while (currentElement && (currentElement != element)) + currentElement = _GetNextElement(currentElement); + return (currentElement != NULL); + }; + + public: void _Insert(Element* element) + // *********************************** + { + if (!_Contains(element)) { + unsigned index = (_GetHashValue(element) / 8) % _length; + _SetNextElement(element, _array[index]); + _array[index] = element; + _size++; + _Resize(); + } + }; + + public: void _Remove(Element* element) + // *********************************** + { + if (_Contains(element)) { + unsigned index = (_GetHashValue(element) / 8) % _length; + Element* currentElement = _array[index]; + if (currentElement) { + if (currentElement == element) { + _array[index] = _GetNextElement(element); + _SetNextElement(element, NULL); + _size--; + } + else { + while (_GetNextElement(currentElement) && (_GetNextElement(currentElement) != element)) + currentElement = _GetNextElement(currentElement); + if (currentElement && (_GetNextElement(currentElement) == element)) { + _SetNextElement(currentElement, _GetNextElement(element)); + _SetNextElement(element, NULL); + _size--; + } + } + } + } + }; + + public: void _Resize() + // ******************* + { + unsigned newLength = _length; + double ratio = (double)_size / (double)_length; + if (ratio < 3) + newLength = max(_size / 8, (unsigned)1); + else if (10 < ratio) + newLength = min(_size / 5, (unsigned)512); + + if (newLength != _length) { + // cerr << "Resizing: " << this << " " << _length << " " << newLength << endl; + unsigned oldLength = _length; + Element** oldArray = _array; + _length = newLength; + _array = new Element*[_length]; + memset(_array, 0, _length * sizeof(Element*)); + for (unsigned index = 0; index < oldLength; index++) { + Element* element = oldArray[index]; + while (element) { + Element* nextElement = _GetNextElement(element); + unsigned newIndex = (_GetHashValue(element) / 8) % _length; + _SetNextElement(element, _array[newIndex]); + _array[newIndex] = element; + element = nextElement; + } + } + delete[] oldArray; + } + }; + + public: void _Clear() + // ****************** + { + for (unsigned index = 0; index < _length; index++) { + Element* element = _array[index]; + while (element) { + _array[index] = _GetNextElement(element); + _SetNextElement(element, NULL); + element = _array[index]; + } + _array[index] = NULL; + } + delete[] _array; + + _size = 0; + _length = 1; + _array = new Element*[1]; + _array[0] = NULL; + }; + +}; + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_INTRUSIVE_SET + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Layer.cpp b/hurricane/src/hurricane/Layer.cpp new file mode 100644 index 00000000..848959f8 --- /dev/null +++ b/hurricane/src/hurricane/Layer.cpp @@ -0,0 +1,133 @@ +// **************************************************************************************************** +// File: Layer.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Layer.h" +#include "Technology.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Layer implementation +// **************************************************************************************************** + +Layer::Layer(Technology* technology, const Name& name, const Unit& minimalSize, const Unit& minimalSpacing, const Unit& pitch) +// **************************************************************************************************** +: Inherit(), + _technology(technology), + _name(name), + _mask(0), + _extractMask(0), + _minimalSize(minimalSize), + _minimalSpacing(minimalSpacing), + _pitch(pitch), + _nextOfTechnologyLayerMap(NULL) +{ + if (!_technology) + throw Error("Can't create " + _TName("Layer") + " : null technology"); + + if (_name.IsEmpty()) + throw Error("Can't create " + _TName("Layer") + " : empty name"); + + if (_technology->GetLayer(_name)) + throw Error("Can't create " + _TName("Layer") + " " + GetString(_name) + " : already exists"); +} + +bool Layer::Contains(Layer* layer) const +// ************************************* +{ + return (layer && ((_mask & layer->GetMask()) == layer->GetMask())); +} + +bool Layer::Intersect(Layer* layer) const +// ************************************** +{ + return ((_mask & layer->GetMask()) != 0); +} + +void Layer::SetName(const Name& name) +// ********************************** +{ + if (name != _name) { + if (name.IsEmpty()) + throw Error("Can't change layer name : empty name"); + + if (_technology->GetLayer(name)) + throw Error("Can't change layer name : already exists"); + + _technology->_GetLayerMap()._Remove(this); + _name = name; + _technology->_GetLayerMap()._Insert(this); + } +} + +void Layer::SetMinimalSize(const Unit& minimalSize) +// ************************************************ +{ + _minimalSize = minimalSize; +} + +void Layer::SetMinimalSpacing(const Unit& minimalSpacing) +// ****************************************************** +{ + _minimalSpacing = minimalSpacing; +} + +void Layer::SetPitch(const Unit& pitch) +// ************************************ +{ + _pitch = pitch; +} + +void Layer::_PostCreate() +// ********************** +{ + _technology->_GetLayerMap()._Insert(this); + _technology->_GetLayerList().push_back(this); + + Inherit::_PostCreate(); +} + +void Layer::_PreDelete() +// ********************* +{ + Inherit::_PreDelete(); + + _technology->_GetLayerList().remove(this); + _technology->_GetLayerMap()._Remove(this); +} + +string Layer::_GetString() const +// ***************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_name)); + return s; +} + +Record* Layer::_GetRecord() const +// ************************ +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Technology", _technology)); + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("Mask", &_mask)); + record->Add(GetSlot("ExtractMask", &_extractMask)); + record->Add(GetSlot("MinimalSize", &_minimalSize)); + record->Add(GetSlot("MinimalSpacing", &_minimalSpacing)); + record->Add(GetSlot("Pitch", &_pitch)); + } + return record; +} + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Layer.h b/hurricane/src/hurricane/Layer.h new file mode 100644 index 00000000..ee171d00 --- /dev/null +++ b/hurricane/src/hurricane/Layer.h @@ -0,0 +1,106 @@ +// **************************************************************************************************** +// File: Layer.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_LAYER +#define HURRICANE_LAYER + +#include "DBo.h" +#include "Layers.h" +#include "Unit.h" +#include "BasicLayers.h" + +namespace Hurricane { + +class Technology; + + + +// **************************************************************************************************** +// Layer declaration +// **************************************************************************************************** + +class Layer : public DBo { +// ********************* + +// Types +// ***** + + public: typedef DBo Inherit; + + public: typedef unsigned long long Mask; + +// Attributes +// ********** + + private: Technology* _technology; + private: Name _name; + private: Mask _mask; + private: Mask _extractMask; + private: Unit _minimalSize; + private: Unit _minimalSpacing; + private: Unit _pitch; + private: Layer* _nextOfTechnologyLayerMap; + +// Constructors +// ************ + + protected: Layer(Technology* technology, const Name& name, const Unit& minimalSize = 0, const Unit& minimalSpacing = 0, const Unit& pitch = 0); + +// Accessors +// ********* + + public: Technology* GetTechnology() const {return _technology;}; + public: const Name& GetName() const {return _name;}; + public: const Mask& GetMask() const {return _mask;}; + public: const Mask& GetExtractMask() const {return _extractMask;}; + public: const Unit& GetMinimalSize() const {return _minimalSize;}; + public: const Unit& GetMinimalSpacing() const {return _minimalSpacing;}; + public: Unit GetPitch() const {return (_pitch==0?(_minimalSize + _minimalSpacing):_pitch);}; + public: virtual BasicLayers GetBasicLayers() const = 0; + +// Predicates +// ********** + + public: bool Contains(Layer* layer) const; + public: bool Intersect(Layer* layer) const; + +// Updators +// ******** + + public: void SetName(const Name& name); + public: void SetMinimalSize(const Unit& minimalSize); + public: void SetMinimalSpacing(const Unit& minimalSpacing); + public: void SetPitch(const Unit& pitch); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: virtual BasicLayer* _GetSymbolicBasicLayer() = 0; + public: Layer* _GetNextOfTechnologyLayerMap() const {return _nextOfTechnologyLayerMap;}; + + public: void _SetMask(const Mask& mask) {_mask = mask;}; + public: void _SetExtractMask(const Mask& extractMask) {_extractMask = extractMask;}; + public: void _SetNextOfTechnologyLayerMap(Layer* layer) {_nextOfTechnologyLayerMap = layer;}; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Layer) + +#endif // HURRICANE_LAYER + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Layers.h b/hurricane/src/hurricane/Layers.h new file mode 100644 index 00000000..c4cd4a04 --- /dev/null +++ b/hurricane/src/hurricane/Layers.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Layers.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_LAYERS +#define HURRICANE_LAYERS + +#include "Collection.h" + +namespace Hurricane { + +class Layer; + + + +// **************************************************************************************************** +// Layers declaration +// **************************************************************************************************** + +typedef GenericCollection Layers; + + + +// **************************************************************************************************** +// LayerLocator declaration +// **************************************************************************************************** + +typedef GenericLocator LayerLocator; + + + +// **************************************************************************************************** +// LayerFilter declaration +// **************************************************************************************************** + +typedef GenericFilter LayerFilter; + + + +// **************************************************************************************************** +// for_each_layer declaration +// **************************************************************************************************** + +#define for_each_layer(layer, layers)\ +/************************************/\ +{\ + LayerLocator _locator = layers.GetLocator();\ + while (_locator.IsValid()) {\ + Layer* layer = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_LAYERS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Libraries.h b/hurricane/src/hurricane/Libraries.h new file mode 100644 index 00000000..33e92532 --- /dev/null +++ b/hurricane/src/hurricane/Libraries.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Libraries.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_LIBRARIES +#define HURRICANE_LIBRARIES + +#include "Collection.h" + +namespace Hurricane { + +class Library; + + + +// **************************************************************************************************** +// Libraries declaration +// **************************************************************************************************** + +typedef GenericCollection Libraries; + + + +// **************************************************************************************************** +// LibraryLocator declaration +// **************************************************************************************************** + +typedef GenericLocator LibraryLocator; + + + +// **************************************************************************************************** +// LibraryFilter declaration +// **************************************************************************************************** + +typedef GenericFilter LibraryFilter; + + + +// **************************************************************************************************** +// for_each_library declaration +// **************************************************************************************************** + +#define for_each_library(library, libraries)\ +/*******************************************/\ +{\ + LibraryLocator _locator = libraries.GetLocator();\ + while (_locator.IsValid()) {\ + Library* library = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_LIBRARIES + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Library.cpp b/hurricane/src/hurricane/Library.cpp new file mode 100644 index 00000000..622c65dc --- /dev/null +++ b/hurricane/src/hurricane/Library.cpp @@ -0,0 +1,209 @@ +// **************************************************************************************************** +// File: Library.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Library.h" +#include "DataBase.h" +#include "Cell.h" +#include "Technology.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Library implementation +// **************************************************************************************************** + +Library::Library(DataBase* dataBase, Library* library, const Name& name) +// ********************************************************************* +: Inherit(), + _dataBase(dataBase), + _library(library), + _name(name), + _libraryMap(), + _cellMap(), + _nextOfLibraryLibraryMap(NULL) +{ + if (!_dataBase) + throw Error("Can't create " + _TName("Library") + " : null data base"); + + if (name.IsEmpty()) + throw Error("Can't create " + _TName("Library") + " : empty name"); + + if (!_library) { + if (_dataBase->GetRootLibrary()) + throw Error("Can't create " + _TName("Library") + " : root library already exists"); + } + else { + if (_library->GetLibrary(_name)) + throw Error("Can't create " + _TName("Library") + " : already exists"); + } +} + +Library* Library::Create(DataBase* dataBase, const Name& name) +// *********************************************************** +{ + Library* library = new Library(dataBase, NULL, name); + + library->_PostCreate(); + + return library; +} + +Library* Library::Create(Library* library, const Name& name) +// ********************************************************* +{ + if (!library) + throw Error("Can't create " + _TName("Library") + " : null library"); + + library = new Library(library->GetDataBase(), library, name); + + library->_PostCreate(); + + return library; +} + +void Library::SetName(const Name& name) +// ************************************ +{ + if (name != _name) { + if (name.IsEmpty()) + throw Error("Can't change library name : empty name"); + + if (_library && _library->GetLibrary(name)) + throw Error("Can't change library name : already exists"); + + if (_library) _library->_GetLibraryMap()._Remove(this); + _name = name; + if (_library) _library->_GetLibraryMap()._Insert(this); + } +} + +void Library::_PostCreate() +// ************************ +{ + if (!_library) + _dataBase->_SetRootLibrary(this); + else + _library->_GetLibraryMap()._Insert(this); + + Inherit::_PostCreate(); +} + +void Library::_PreDelete() +// *********************** +{ + Inherit::_PreDelete(); + + for_each_cell(cell, GetCells()) cell->Delete(); end_for; + for_each_library(library, GetLibraries()) library->Delete(); end_for; + + if (!_library) + _dataBase->_SetRootLibrary(NULL); + else + _library->_GetLibraryMap()._Remove(this); +} + +string Library::_GetString() const +// ******************************* +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " "); + s.insert(s.length() - 1, GetString(_name)); + return s; +} + +Record* Library::_GetRecord() const +// ************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("DataBase", _dataBase)); + record->Add(GetSlot("Library", _library)); + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("Libraries", &_libraryMap)); + record->Add(GetSlot("Cells", &_cellMap)); + } + return record; +} + +// **************************************************************************************************** +// Library::LibraryMap implementation +// **************************************************************************************************** + +Library::LibraryMap::LibraryMap() +// ****************************** +: Inherit() +{ +} + +Name Library::LibraryMap::_GetKey(Library* library) const +// ****************************************************** +{ + return library->GetName(); +} + +unsigned Library::LibraryMap::_GetHashValue(Name name) const +// ********************************************************* +{ + return ( (unsigned int)( (unsigned long)name._GetSharedName() ) ) / 8; +} + +Library* Library::LibraryMap::_GetNextElement(Library* library) const +// ****************************************************************** +{ + return library->_GetNextOfLibraryLibraryMap(); +} + +void Library::LibraryMap::_SetNextElement(Library* library, Library* nextLibrary) const +// ************************************************************************************ +{ + library->_SetNextOfLibraryLibraryMap(nextLibrary); +}; + + + +// **************************************************************************************************** +// Library::CellMap implementation +// **************************************************************************************************** + +Library::CellMap::CellMap() +// ************************ +: Inherit() +{ +} + +Name Library::CellMap::_GetKey(Cell* cell) const +// ********************************************* +{ + return cell->GetName(); +} + +unsigned Library::CellMap::_GetHashValue(Name name) const +// ****************************************************** +{ + return ( (unsigned int)( (unsigned long)name._GetSharedName() ) ) / 8; +} + +Cell* Library::CellMap::_GetNextElement(Cell* cell) const +// ****************************************************** +{ + return cell->_GetNextOfLibraryCellMap(); +} + +void Library::CellMap::_SetNextElement(Cell* cell, Cell* nextCell) const +// ********************************************************************* +{ + cell->_SetNextOfLibraryCellMap(nextCell); +}; + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Library.h b/hurricane/src/hurricane/Library.h new file mode 100644 index 00000000..5e915857 --- /dev/null +++ b/hurricane/src/hurricane/Library.h @@ -0,0 +1,123 @@ +// **************************************************************************************************** +// File: Library.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_LIBRARY +#define HURRICANE_LIBRARY + +#include "DBo.h" +#include "Libraries.h" +#include "Cell.h" +#include "IntrusiveMap.h" + +namespace Hurricane { + +class DataBase; + + + +// **************************************************************************************************** +// Library declaration +// **************************************************************************************************** + +class Library : public DBo { +// *********************** + +// Types +// ***** + + public: typedef DBo Inherit; + + public: class LibraryMap : public IntrusiveMap { + // ********************************************************** + + public: typedef IntrusiveMap Inherit; + + public: LibraryMap(); + + public: virtual Name _GetKey(Library* library) const; + public: virtual unsigned _GetHashValue(Name name) const; + public: virtual Library* _GetNextElement(Library* library) const; + public: virtual void _SetNextElement(Library* library, Library* nextLibrary) const; + + }; + + public: class CellMap : public IntrusiveMap { + // **************************************************** + + public: typedef IntrusiveMap Inherit; + + public: CellMap(); + + public: virtual Name _GetKey(Cell* cell) const; + public: virtual unsigned _GetHashValue(Name name) const; + public: virtual Cell* _GetNextElement(Cell* cell) const; + public: virtual void _SetNextElement(Cell* cell, Cell* nextCell) const; + + }; + +// Attributes +// ********** + + private: DataBase* _dataBase; + private: Library* _library; + private: Name _name; + private: LibraryMap _libraryMap; + private: CellMap _cellMap; + private: Library* _nextOfLibraryLibraryMap; + +// Constructors +// ************ + + protected: Library(DataBase* dataBase, Library* library, const Name& name); + + public: static Library* Create(DataBase* dataBase, const Name& name); + public: static Library* Create(Library* library, const Name& name); + +// Accessors +// ********* + + public: DataBase* GetDataBase() const {return _dataBase;}; + public: Library* GetLibrary() const {return _library;}; + public: const Name& GetName() const {return _name;}; + public: Library* GetLibrary(const Name& name) const {return _libraryMap.GetElement(name);}; + public: Libraries GetLibraries() const {return _libraryMap.GetElements();}; + public: Cell* GetCell(const Name& name) const {return _cellMap.GetElement(name);}; + public: Cells GetCells() const {return _cellMap.GetElements();}; + +// Updators +// ******** + + public: void SetName(const Name& name); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("Library");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: LibraryMap& _GetLibraryMap() {return _libraryMap;}; + public: CellMap& _GetCellMap() {return _cellMap;}; + public: Library* _GetNextOfLibraryLibraryMap() const {return _nextOfLibraryLibraryMap;}; + + public: void _SetNextOfLibraryLibraryMap(Library* library) {_nextOfLibraryLibraryMap = library;}; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Library) + +#endif // HURRICANE_LIBRARY + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/ListCollection.h b/hurricane/src/hurricane/ListCollection.h new file mode 100644 index 00000000..ef6f7a13 --- /dev/null +++ b/hurricane/src/hurricane/ListCollection.h @@ -0,0 +1,205 @@ +// **************************************************************************************************** +// File: ListCollection.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_LIST_COLLECTION +#define HURRICANE_LIST_COLLECTION + +#include "Commons.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// ListCollection declaration +// **************************************************************************************************** + +template class ListCollection : public Collection { +// ********************************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: typedef list ElementList; + + public: class Locator : public Hurricane::Locator { + // ******************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const ElementList* _elementList; + private: typename ElementList::const_iterator _iterator; // AD + + public: Locator(const ElementList* elementList) + // ******************************************** + : Inherit(), + _elementList(elementList), + _iterator() + { + if (_elementList) _iterator = _elementList->begin(); + }; + + public: virtual Element GetElement() const + // *************************************** + { + return (IsValid()) ? *_iterator : Element(); + }; + + public: virtual Hurricane::Locator* GetClone() const + // ********************************************************** + { + return new Locator(_elementList); + }; + + public: virtual bool IsValid() const + // ********************************* + { + return (_elementList && (_iterator != _elementList->end())); + }; + + public: virtual void Progress() + // **************************** + { + ++_iterator; + }; + + }; + +// Attributes +// ********** + + private: const ElementList* _elementList; + +// Constructors +// ************ + + public: ListCollection(const ElementList* elementList = NULL) + // ********************************************************** + : Inherit(), + _elementList(elementList) + { + }; + + public: ListCollection(const ElementList& elementList) + // *************************************************** + : Inherit(), + _elementList(&elementList) + { + }; + + public: ListCollection(const ListCollection& listCollection) + // ********************************************************* + : Inherit(), + _elementList(listCollection._elementList) + { + }; + +// Operators +// ********* + + public: ListCollection& operator=(const ListCollection& listCollection) + // ******************************************************************** + { + _elementList = listCollection._elementList; + return *this; + }; + +// Accessors +// ********* + + public: virtual Collection* GetClone() const + // ************************************************** + { + return new ListCollection(*this); + } + + public: virtual Hurricane::Locator* GetLocator() const + // ************************************************************ + { + // return (_elementList) ? new Locator(_elementList) : NULL; + // V3 + return (_elementList) ? new Locator(_elementList) : NULL; + } + + public: virtual unsigned GetSize() const + // ************************************* + { + return (_elementList) ? _elementList->size() : 0; + }; + +// Others +// ****** + + public: virtual string _GetTypeName() const + // ************************************** + { + return _TName("ListCollection"); + }; + + public: virtual string _GetString() const + // ************************************** + { + if (!_elementList) + return "<" + _GetTypeName() + " unbound>"; + else { + if (_elementList->empty()) + return "<" + _GetTypeName() + " empty>"; + else + return "<" + _GetTypeName() + " " + GetString(_elementList->size()) + ">"; + } + }; + + public: Record* _GetRecord() const + // ************************* + { + Record* record = NULL; + if (!_elementList->empty()) { + record = new Record(_GetString()); + unsigned n = 1; + typename list::const_iterator iterator = _elementList->begin(); // AD + while (iterator != _elementList->end()) { + string slotName = GetString(n++); + Element slotObject = *iterator; + record->Add(GetSlot(slotName, slotObject)); + ++iterator; + } + } + return record; + } + +}; + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +template + inline GenericCollection GetCollection(const list& elementList) +// ********************************************************************************* +{ + return ListCollection(elementList); +} + +template + inline GenericCollection GetCollection(const list* elementList) +// ********************************************************************************* +{ + return ListCollection(elementList); +} + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_LIST_COLLECTION + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Locator.h b/hurricane/src/hurricane/Locator.h new file mode 100644 index 00000000..7dc73683 --- /dev/null +++ b/hurricane/src/hurricane/Locator.h @@ -0,0 +1,267 @@ +// **************************************************************************************************** +// File: Locator.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment BULL-LIP6 + +#ifndef HURRICANE_LOCATOR +#define HURRICANE_LOCATOR + +#include "Commons.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Locator declaration +// **************************************************************************************************** + +template class Locator : public NestedSlotAdapter { +// ********************************************************** + +// Constructors +// ************ + + protected: Locator() + // ***************** + { + }; + + private: Locator(const Locator& locator); + // ******************************************* + // not implemented to forbid copy construction + // ******************************************* + +// Destructor +// ********** + + public: virtual ~Locator() + // *********************** + { + }; + +// Operators +// ********* + + private: Locator& operator=(const Locator& locator); + // ************************************************* + // not implemented to forbid assignment + // ************************************************* + +// Accessors +// ********* + + public: virtual Type GetElement() const = 0; + public: virtual Locator* GetClone() const = 0; + + public: virtual Locator* GetLocator() // 21-10-2003 + // **************************************** + { + return ( this ); + } + +// Predicates +// ********** + + public: virtual bool IsValid() const = 0; + +// Updators +// ******** + + public: virtual void Progress() = 0; + +// Others +// ****** + + public: virtual string _GetTypeName() const + // ************************************** + { + return _TName("Locator"); + }; + + public: virtual string _GetString() const + // ************************************** + { + if (!IsValid()) + return "<" + _GetTypeName() + " invalid>"; + else + return "<" + _GetTypeName() + " " + GetString(GetElement()) + ">"; + }; + +}; + + + +// **************************************************************************************************** +// GenericLocator declaration +// **************************************************************************************************** + +template class GenericLocator : public Locator { +// ************************************************************* + +// Types +// ***** + + public: typedef Locator Inherit; + +// Attributes +// ********** + + private: Locator* _locator; + +// Constructors +// ************ + + public: GenericLocator() + // ********************* + : Inherit(), + _locator(NULL) + { + }; + + public: GenericLocator(const Locator& locator) + // ************************************************* + : Inherit(), + _locator(locator.GetClone()) + { + }; + + public: GenericLocator(const GenericLocator& genericLocator) + // ********************************************************* + : Inherit(), + _locator(genericLocator.GetClone()) + { + }; + + public: GenericLocator(Locator* locator) + // ******************************************************* + // CAUTION : locator will be deleted by the GenericLocator + // ******************************************************* + : Inherit(), + _locator(locator) + { + }; + +// Destructor +// ********** + + public: virtual ~GenericLocator() + // ****************************** + { + if (_locator) delete _locator; + }; + +// Operators +// ********* + + public: GenericLocator& operator=(const Locator& locator) + // ************************************************************ + { + if (_locator) delete _locator; + _locator = locator.GetClone(); + return *this; + }; + + public: GenericLocator& operator=(const GenericLocator& genericLocator) + // ******************************************************************** + { + if (_locator) delete _locator; + _locator = genericLocator.GetClone(); + return *this; + }; + + public: GenericLocator& operator=(Locator* locator) + // ******************************************************* + // CAUTION : locator will be deleted by the GenericLocator + // ******************************************************* + { + if (_locator) delete _locator; + _locator = locator; + return *this; + }; + +// Accessors +// ********* + + public: virtual Type GetElement() const + // ************************************ + { + return ((_locator) ? _locator->GetElement() : Type()); + }; + + public: virtual Locator* GetClone() const + // ******************************************** + { + return ((_locator) ? _locator->GetClone() : NULL); + }; + + public: virtual Locator* GetLocator() // 21-10-2003 + // **************************************** + { + return ( _locator->GetLocator () ); + } + + +// Predicates +// ********** + + public: virtual bool IsValid() const + // ********************************* + { + return (_locator && _locator->IsValid()); + }; + +// Updators +// ******** + + public: virtual void Progress() + // **************************** + { + if (_locator) _locator->Progress(); + }; + +// Others +// ****** + + public: virtual string _GetTypeName() const + // ************************************** + { + return _TName("GenericLocator"); + }; + + public: virtual string _GetString() const + // ************************************** + { + if (!_locator) + return "<" + _GetTypeName() + " unbound>"; + else + return "<" + _GetTypeName() + " " + GetString(_locator) + ">"; + }; + +}; + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + + +template + class IsNestedSlotAdapter > { + public: + enum { True=1, False=0 }; + }; + + + +} // End of Hurricane namespace. + + +#endif // HURRICANE_LOCATOR + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/MapCollection.h b/hurricane/src/hurricane/MapCollection.h new file mode 100644 index 00000000..ae378062 --- /dev/null +++ b/hurricane/src/hurricane/MapCollection.h @@ -0,0 +1,203 @@ +// **************************************************************************************************** +// File: MapCollection.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_MAP_COLLECTION +#define HURRICANE_MAP_COLLECTION + +#include "Commons.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// MapCollection declaration +// **************************************************************************************************** + +template > + class MapCollection : public Collection { +// ************************************************ + +// Types +// ***** + + public: typedef Collection Inherit; + + public: typedef map ElementMap; + + public: class Locator : public Hurricane::Locator { + // ******************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const ElementMap* _elementMap; + private: typename ElementMap::const_iterator _iterator; // AD + + public: Locator(const ElementMap* elementMap) + // ****************************************** + : Inherit(), + _elementMap(elementMap), + _iterator() + { + if (_elementMap) _iterator = _elementMap->begin(); + }; + + public: virtual Element GetElement() const + // *************************************** + { + return (IsValid()) ? (*_iterator).second : Element(); + }; + + public: virtual Hurricane::Locator* GetClone() const + // ********************************************************** + { + return new Locator(_elementMap); + }; + + public: virtual bool IsValid() const + // ********************************* + { + return (_elementMap && (_iterator != _elementMap->end())); + }; + + public: virtual void Progress() + // **************************** + { + ++_iterator; + }; + + }; + +// Attributes +// ********** + + private: const ElementMap* _elementMap; + +// Constructors +// ************ + + public: MapCollection(const ElementMap* elementMap = NULL) + // ******************************************************* + : Inherit(), + _elementMap(elementMap) + { + }; + + public: MapCollection(const ElementMap& elementMap) + // ************************************************ + : Inherit(), + _elementMap(&elementMap) + { + }; + + public: MapCollection(const MapCollection& mapCollection) + // ****************************************************** + : Inherit(), + _elementMap(mapCollection._elementMap) + { + }; + +// Operators +// ********* + + public: MapCollection& operator=(const MapCollection& mapCollection) + // ***************************************************************** + { + _elementMap = mapCollection._elementMap; + return *this; + }; + +// Accessors +// ********* + + public: virtual Collection* GetClone() const + // ************************************************** + { + return new MapCollection(*this); + } + + public: virtual Hurricane::Locator* GetLocator() const + // ************************************************************ + { + // return (_elementMap) ? new Locator(_elementMap) : NULL; + // V3 + return (_elementMap) ? new Locator(_elementMap) : NULL; + } + + public: virtual unsigned GetSize() const + // ************************************* + { + return (_elementMap) ? _elementMap->size() : 0; + }; + +// Others +// ****** + + public: virtual string _GetTypeName() const + // ************************************** + { + return _TName("MapCollection"); + }; + + public: virtual string _GetString() const + // ************************************** + { + if (!_elementMap) + return "<" + _GetTypeName() + " unbound>"; + else { + if (_elementMap->empty()) + return "<" + _GetTypeName() + " empty>"; + else + return "<" + _GetTypeName() + " " + GetString(_elementMap->size()) + ">"; + } + }; + + Record* _GetRecord() const + // ******************** + { + Record* record = NULL; + if (!_elementMap->empty()) { + record = new Record(_GetString()); + typename map::const_iterator iterator = _elementMap->begin(); // AD + while (iterator != _elementMap->end()) { + record->Add(GetSlot(GetString((*iterator).first), (*iterator).second)); + ++iterator; + } + } + return record; + } + +}; + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +template + inline GenericCollection GetCollection(const map& elementMap) +// ********************************************************************************************* +{ + return MapCollection(elementMap); +} + +template + inline GenericCollection GetCollection(const map* elementMap) +// ********************************************************************************************* +{ + return MapCollection(elementMap); +} + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_MAP_COLLECTION + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Marker.cpp b/hurricane/src/hurricane/Marker.cpp new file mode 100644 index 00000000..6440e9ab --- /dev/null +++ b/hurricane/src/hurricane/Marker.cpp @@ -0,0 +1,91 @@ +// **************************************************************************************************** +// File: Marker.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Marker.h" +#include "Cell.h" +#include "Slice.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Marker implementation +// **************************************************************************************************** + +Marker::Marker(Cell* cell) +// *********************** +: Inherit(), + _cell(cell), + _nextOfCellMarkerSet(NULL) +{ + if (!_cell) + throw Error("Can't create " + _TName("Marker") + " : null cell"); +} + +void Marker::Materialize() +// *********************** +{ + if (!IsMaterialized()) { + Cell* cell = GetCell(); + QuadTree* quadTree = cell->_GetQuadTree(); + quadTree->Insert(this); + cell->_Fit(quadTree->GetBoundingBox()); + } +} + +void Marker::Unmaterialize() +// ************************* +{ + if (IsMaterialized()) { + Cell* cell = GetCell(); + cell->_Unfit(GetBoundingBox()); + cell->_GetQuadTree()->Remove(this); + } +} + +void Marker::_PostCreate() +// *********************** +{ + _cell->_GetMarkerSet()._Insert(this); + + Inherit::_PostCreate(); +} + +void Marker::_PreDelete() +// ********************** +{ + Inherit::_PreDelete(); + + _cell->_GetMarkerSet()._Remove(this); +} + +string Marker::_GetString() const +// ****************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_cell->GetName())); + return s; +} + +Record* Marker::_GetRecord() const +// ************************* +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Cell", _cell)); + } + return record; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Marker.h b/hurricane/src/hurricane/Marker.h new file mode 100644 index 00000000..82e753a6 --- /dev/null +++ b/hurricane/src/hurricane/Marker.h @@ -0,0 +1,75 @@ +// **************************************************************************************************** +// File: Marker.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_MARKER +#define HURRICANE_MARKER + +#include "Go.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Marker declaration +// **************************************************************************************************** + +class Marker : public Go { +// ********************* + +// Types +// ***** + + public: typedef Go Inherit; + +// Attributes +// ********** + + private: Cell* _cell; + private: Marker* _nextOfCellMarkerSet; + +// Constructors +// ************ + + protected: Marker(Cell* cell); + +// Accessors +// ********* + + public: virtual Cell* GetCell() const {return _cell;}; + public: virtual Box GetBoundingBox() const = 0; + +// Updators +// ******** + + public: virtual void Materialize(); + public: virtual void Unmaterialize(); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: Marker* _GetNextOfCellMarkerSet() const {return _nextOfCellMarkerSet;}; + + public: void _SetNextOfCellMarkerSet(Marker* marker) {_nextOfCellMarkerSet = marker;}; + +}; + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_MARKER + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Markers.h b/hurricane/src/hurricane/Markers.h new file mode 100644 index 00000000..4fdd6143 --- /dev/null +++ b/hurricane/src/hurricane/Markers.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Markers.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_MARKERS +#define HURRICANE_MARKERS + +#include "Collection.h" + +namespace Hurricane { + +class Marker; + + + +// **************************************************************************************************** +// Markers declaration +// **************************************************************************************************** + +typedef GenericCollection Markers; + + + +// **************************************************************************************************** +// MarkerLocator declaration +// **************************************************************************************************** + +typedef GenericLocator MarkerLocator; + + + +// **************************************************************************************************** +// MarkerFilter declaration +// **************************************************************************************************** + +typedef GenericFilter MarkerFilter; + + + +// **************************************************************************************************** +// for_each_marker declaration +// **************************************************************************************************** + +#define for_each_marker(marker, markers)\ +/***************************************/\ +{\ + MarkerLocator _locator = markers.GetLocator();\ + while (_locator.IsValid()) {\ + Marker* marker = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_MARKERS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/MultisetCollection.h b/hurricane/src/hurricane/MultisetCollection.h new file mode 100644 index 00000000..78c2ebe1 --- /dev/null +++ b/hurricane/src/hurricane/MultisetCollection.h @@ -0,0 +1,203 @@ +// **************************************************************************************************** +// File: MultisetCollection.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_MULTISET_COLLECTION +#define HURRICANE_MULTISET_COLLECTION + +#include "Commons.h" + +#include "Tabulation.h" +#include "Record.h" +#include "Slot.h" + + +namespace Hurricane { + + + +// **************************************************************************************************** +// MultisetCollection declaration +// **************************************************************************************************** + +template > + class MultisetCollection : public Collection { +// ************************************************ + +// Types +// ***** + + public: typedef Collection Inherit; + + public: typedef multiset ElementMultiset; + + public: class Locator : public Hurricane::Locator { + // ******************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const ElementMultiset* _elementMultiset; + private: typename ElementMultiset::const_iterator _iterator; // AD + + public: Locator(const ElementMultiset* elementMultiset) + // ****************************************** + : Inherit(), + _elementMultiset(elementMultiset), + _iterator() + { + if (_elementMultiset) _iterator = _elementMultiset->begin(); + }; + + public: virtual Element GetElement() const + // *************************************** + { + return (IsValid()) ? *_iterator : Element(); + }; + + public: virtual Hurricane::Locator* GetClone() const + // ********************************************************** + { + return new Locator(_elementMultiset); + }; + + public: virtual bool IsValid() const + // ********************************* + { + return (_elementMultiset && (_iterator != _elementMultiset->end())); + }; + + public: virtual void Progress() + // **************************** + { + ++_iterator; + }; + + }; + +// Attributes +// ********** + + private: const ElementMultiset* _elementMultiset; + +// Constructors +// ************ + + public: MultisetCollection(const ElementMultiset* elementMultiset = NULL) + // ******************************************************* + : Inherit(), + _elementMultiset(elementMultiset) + { + }; + + public: MultisetCollection(const ElementMultiset& elementMultiset) + // ************************************************ + : Inherit(), + _elementMultiset(&elementMultiset) + { + }; + + public: MultisetCollection(const MultisetCollection& multisetCollection) + // ****************************************************** + : Inherit(), + _elementMultiset(multisetCollection._elementMultiset) + { + }; + +// Operators +// ********* + + public: MultisetCollection& operator=(const MultisetCollection& multisetCollection) + // ***************************************************************** + { + _elementMultiset = multisetCollection._elementMultiset; + return *this; + }; + +// Accessors +// ********* + + public: virtual Collection* GetClone() const + // ************************************************** + { + return new MultisetCollection(*this); + } + + public: virtual Hurricane::Locator* GetLocator() const + // ************************************************************ + { + // return (_elementMultiset) ? new Locator(_elementMultiset) : NULL; + // V3 + return (_elementMultiset) ? new Locator(_elementMultiset) : NULL; + } + + public: virtual unsigned GetSize() const + // ************************************* + { + return (_elementMultiset) ? _elementMultiset->size() : 0; + }; + +// Others +// ****** + + public: virtual string _GetString() const + // ************************************** + { + if (!_elementMultiset) + return "<" + _TName("MultisetCollection") + " unbounnd>"; + else { + if (_elementMultiset->empty()) + return "<" + _TName("MultisetCollection") + " empty>"; + else + return "<" + _TName("MultisetCollection") + " " + GetString(_elementMultiset->size()) + ">"; + } + }; + + Record* _GetRecord() const + // ***************** + { + Record* record = NULL; + if (!_elementMultiset->empty()) { + record = new Record(_GetString()); + unsigned n = 1; + typename multiset::const_iterator iterator = _elementMultiset->begin(); // AD + while (iterator != _elementMultiset->end()) { + record->Add(GetSlot(GetString(n++), *iterator)); + ++iterator; + } + } + return record; + } + +}; + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +template + inline GenericCollection GetCollection(const multiset& elementMultiset) +// **************************************************************************************** +{ + return MultisetCollection(elementMultiset); +} + +template + inline GenericCollection GetCollection(const multiset* elementMultiset) +// **************************************************************************************** +{ + return MultisetCollection(elementMultiset); +} + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_SET_COLLECTION + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Name.cpp b/hurricane/src/hurricane/Name.cpp new file mode 100644 index 00000000..b29dd7ba --- /dev/null +++ b/hurricane/src/hurricane/Name.cpp @@ -0,0 +1,191 @@ +// **************************************************************************************************** +// File: Name.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Name.h" +#include "SharedName.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Name implementation +// **************************************************************************************************** + +Name::Name() +// ********* +: _sharedName(NULL) +{ + string s = ""; + if (!SharedName::_SHARED_NAME_MAP) + _sharedName = new SharedName(s); + else { + SharedName::SharedNameMap::iterator iterator = + SharedName::_SHARED_NAME_MAP->find(&(string&)s); + if (iterator != SharedName::_SHARED_NAME_MAP->end()) + _sharedName = (*iterator).second; + else + _sharedName = new SharedName(s); + } + + assert(_sharedName); + + _sharedName->Capture(); +} + +Name::Name(const char* c) +// ********************** +: _sharedName(NULL) +{ + string s = c; + if (!SharedName::_SHARED_NAME_MAP) + _sharedName = new SharedName(s); + else { + SharedName::SharedNameMap::iterator iterator = + SharedName::_SHARED_NAME_MAP->find(&(string&)s); + if (iterator != SharedName::_SHARED_NAME_MAP->end()) + _sharedName = (*iterator).second; + else + _sharedName = new SharedName(s); + } + + assert(_sharedName); + + _sharedName->Capture(); +} + +Name::Name(const string& s) +// ************************ +: _sharedName(NULL) +{ + if (!SharedName::_SHARED_NAME_MAP) + _sharedName = new SharedName(s); + else { + SharedName::SharedNameMap::iterator iterator = + SharedName::_SHARED_NAME_MAP->find(&(string&)s); + if (iterator != SharedName::_SHARED_NAME_MAP->end()) + _sharedName = (*iterator).second; + else + _sharedName = new SharedName(s); + } + + assert(_sharedName); + + _sharedName->Capture(); +} + +Name::Name(const Name& name) +// ************************* +: _sharedName(name._sharedName) +{ + _sharedName->Capture(); +} + +Name::~Name() +// ********** +{ + _sharedName->Release(); +} + +Name& Name::operator=(const Name& name) +// ************************************ +{ + SharedName* sharedName = name._sharedName; + if (sharedName != _sharedName) { + _sharedName->Release(); + _sharedName = sharedName; + _sharedName->Capture(); + } + return *this; +} + +bool Name::operator==(const Name& name) const +// ****************************************** +{ + return (_sharedName == name._sharedName); +} + +bool Name::operator!=(const Name& name) const +// ****************************************** +{ + return (_sharedName != name._sharedName); +} + +bool Name::operator<(const Name& name) const +// ***************************************** +{ + return ((_sharedName != name._sharedName) && + (_sharedName->_string < name._sharedName->_string)); +} + +bool Name::operator<=(const Name& name) const +// ****************************************** +{ + return ((_sharedName == name._sharedName) || + (_sharedName->_string < name._sharedName->_string)); +} + +bool Name::operator>(const Name& name) const +// ***************************************** +{ + return ((_sharedName != name._sharedName) && + (_sharedName->_string > name._sharedName->_string)); +} + +bool Name::operator>=(const Name& name) const +// ****************************************** +{ + return ((_sharedName == name._sharedName) || + (_sharedName->_string >= name._sharedName->_string)); +} + +char Name::operator[](unsigned index) const +// **************************************** +{ + return _sharedName->_string[index]; +} + +bool Name::IsEmpty() const +// *********************** +{ + return _sharedName->_string.empty(); +} + +string Name::_GetString() const +// **************************** +{ + return _sharedName->_string; +} + +Record* Name::_GetRecord() const +// *********************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("SharedName", _sharedName)); + return record; +} + + + +} // End of Hurricane namespace. + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +bool Scan ( const string& s, H::Name& name ) +// ***************************************** +{ + name = s; + + return ( true ); +} + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Name.h b/hurricane/src/hurricane/Name.h new file mode 100644 index 00000000..037a71ce --- /dev/null +++ b/hurricane/src/hurricane/Name.h @@ -0,0 +1,88 @@ +// **************************************************************************************************** +// File: Name.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_NAME +#define HURRICANE_NAME + +#include "Commons.h" +#include "Names.h" + +namespace Hurricane { + +class SharedName; + + + +// **************************************************************************************************** +// Name declaration +// **************************************************************************************************** + +class Name { +// ******* + +// Attributes +// ********** + + private: SharedName* _sharedName; + +// Constructors +// ************ + + public: Name(); + + public: Name(const char* c); + public: Name(const string& s); + + public: Name(const Name& name); + +// Destructor +// ********** + + public: ~Name(); + +// Operators +// ********* + + public: Name& operator=(const Name& name); + + public: bool operator==(const Name& name) const; + public: bool operator!=(const Name& name) const; + public: bool operator<(const Name& name) const; + public: bool operator<=(const Name& name) const; + public: bool operator>(const Name& name) const; + public: bool operator>=(const Name& name) const; + + public: char operator[](unsigned index) const; + +// Predicates +// ********** + + public: bool IsEmpty() const; + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("Name"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + public: SharedName* _GetSharedName() const {return _sharedName;}; + +}; + + +} // End of Hurricane namespace. + + +ValueIOStreamSupport(Hurricane::Name) + + +bool Scan ( const string& s, H::Name& name ); + +#endif // HURRICANE_NAME + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Names.h b/hurricane/src/hurricane/Names.h new file mode 100644 index 00000000..4e3725a9 --- /dev/null +++ b/hurricane/src/hurricane/Names.h @@ -0,0 +1,55 @@ +#ifndef HURRICANE_NAMES +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +#define HURRICANE_NAMES + +#include "Collection.h" + +namespace Hurricane { + +class Name; + + + +// **************************************************************************************************** +// Names declaration +// **************************************************************************************************** + +typedef GenericCollection Names; + + + +// **************************************************************************************************** +// NameLocator declaration +// **************************************************************************************************** + +typedef GenericLocator NameLocator; + + + +// **************************************************************************************************** +// NameFilter declaration +// **************************************************************************************************** + +typedef GenericFilter NameFilter; + + + +// **************************************************************************************************** +// for_each_name declaration +// **************************************************************************************************** + +#define for_each_name(name, names)\ +/****************************************************/\ +{\ + NameLocator _locator = names.GetLocator();\ + while (_locator.IsValid()) {\ + Name* name = _locator.GetElement();\ + _locator.Progress(); + +} // End of Hurricane namespace. + +#endif // HURRICANE_NAMES diff --git a/hurricane/src/hurricane/Net.cpp b/hurricane/src/hurricane/Net.cpp new file mode 100644 index 00000000..03de58ab --- /dev/null +++ b/hurricane/src/hurricane/Net.cpp @@ -0,0 +1,929 @@ +// **************************************************************************************************** +// File: Net.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Net.h" +#include "Cell.h" +#include "Instance.h" +#include "Plug.h" +#include "RoutingPad.h" +#include "RoutingPads.h" +#include "Pin.h" +#include "Contact.h" +#include "Vertical.h" +#include "Horizontal.h" +#include "Pad.h" +#include "UpdateSession.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Filters declaration & implementation +// **************************************************************************************************** + +class Net_IsCellNetFilter : public Filter { +// ******************************************* + + public: Net_IsCellNetFilter() {}; + + public: Net_IsCellNetFilter(const Net_IsCellNetFilter& filter) {}; + + public: Net_IsCellNetFilter& operator=(const Net_IsCellNetFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Net_IsCellNetFilter(*this);}; + + public: virtual bool Accept(Net* net) const {return !net->IsDeepNet();}; + + public: virtual string _GetString() const {return "<" + _TName("Net::IsCellNetFilter>");}; + +}; + +class Net_IsDeepNetFilter : public Filter { +// ******************************************* + + public: Net_IsDeepNetFilter() {}; + + public: Net_IsDeepNetFilter(const Net_IsDeepNetFilter& filter) {}; + + public: Net_IsDeepNetFilter& operator=(const Net_IsDeepNetFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Net_IsDeepNetFilter(*this);}; + + public: virtual bool Accept(Net* net) const {return net->IsDeepNet();}; + + public: virtual string _GetString() const {return "<" + _TName("Net::IsDeepNetFilter>");}; + +}; + +class Net_IsGlobalFilter : public Filter { +// ******************************************* + + public: Net_IsGlobalFilter() {}; + + public: Net_IsGlobalFilter(const Net_IsGlobalFilter& filter) {}; + + public: Net_IsGlobalFilter& operator=(const Net_IsGlobalFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Net_IsGlobalFilter(*this);}; + + public: virtual bool Accept(Net* net) const {return net->IsGlobal();}; + + public: virtual string _GetString() const {return "<" + _TName("Net::IsGlobalFilter>");}; + +}; + +class Net_IsExternalFilter : public Filter { +// ********************************************* + + public: Net_IsExternalFilter() {}; + + public: Net_IsExternalFilter(const Net_IsExternalFilter& filter) {}; + + public: Net_IsExternalFilter& operator=(const Net_IsExternalFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Net_IsExternalFilter(*this);}; + + public: virtual bool Accept(Net* net) const {return net->IsExternal();}; + + public: virtual string _GetString() const {return "<" + _TName("Net::IsExternalFilter>");}; + +}; + +class Net_IsClockFilter : public Filter { +// ****************************************** + + public: Net_IsClockFilter() {}; + + public: Net_IsClockFilter(const Net_IsClockFilter& filter) {}; + + public: Net_IsClockFilter& operator=(const Net_IsClockFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Net_IsClockFilter(*this);}; + + public: virtual bool Accept(Net* net) const {return net->IsClock();}; + + public: virtual string _GetString() const {return "<" + _TName("Net::IsClockFilter>");}; + +}; + +class Net_IsSupplyFilter : public Filter { +// ******************************************* + + public: Net_IsSupplyFilter() {}; + + public: Net_IsSupplyFilter(const Net_IsSupplyFilter& filter) {}; + + public: Net_IsSupplyFilter& operator=(const Net_IsSupplyFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Net_IsSupplyFilter(*this);}; + + public: virtual bool Accept(Net* net) const {return net->IsSupply();}; + + public: virtual string _GetString() const {return "<" + _TName("Net::IsSupplyFilter>");}; + +}; + +class Net_IsPowerFilter : public Filter { +// ******************************************* + + public: Net_IsPowerFilter() {}; + + public: Net_IsPowerFilter(const Net_IsPowerFilter& filter) {}; + + public: Net_IsPowerFilter& operator=(const Net_IsPowerFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Net_IsPowerFilter(*this);}; + + public: virtual bool Accept(Net* net) const {return net->IsPower();}; + + public: virtual string _GetString() const {return "<" + _TName("Net::IsPowerFilter>");}; + +}; + +class Net_IsGroundFilter : public Filter { +// ******************************************* + + public: Net_IsGroundFilter() {}; + + public: Net_IsGroundFilter(const Net_IsGroundFilter& filter) {}; + + public: Net_IsGroundFilter& operator=(const Net_IsGroundFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Net_IsGroundFilter(*this);}; + + public: virtual bool Accept(Net* net) const {return net->IsGround();}; + + public: virtual string _GetString() const {return "<" + _TName("Net::IsGroundFilter>");}; + +}; + + + +// **************************************************************************************************** +// Net_SlavePlugs implementation +// **************************************************************************************************** + +class Net_SlavePlugs : public Collection { +// ******************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ***************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Net* _net; + private: Plug* _plug; + private: InstanceLocator _instanceLocator; + + public: Locator(const Net* net = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Plug* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Net* _net; + +// Constructors +// ************ + + public: Net_SlavePlugs(const Net* net = NULL); + public: Net_SlavePlugs(const Net_SlavePlugs& slavePlugs); + +// Operators +// ********* + + public: Net_SlavePlugs& operator=(const Net_SlavePlugs& slavePlugs); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Net implementation +// **************************************************************************************************** + +Net::Net(Cell* cell, const Name& name) +// *********************************** +: Inherit(), + _cell(cell), + _name(name), + _arity(1), + _isGlobal(false), + _isExternal(false), + _type(), + _direction(), + _position(0, 0), + _componentSet(), + _rubberSet(), + _nextOfCellNetMap(NULL) +{ + if (!_cell) + throw Error("Can't create " + _TName("Net") + " : null cell"); + + if (name.IsEmpty()) + throw Error("Can't create " + _TName("Net") + " : empty name"); + + if (_cell->GetNet(_name)) + throw Error("Can't create " + _TName("Net") + " : already exists"); +} + +Net* Net::Create(Cell* cell, const Name& name) +// ******************************************* +{ + Net* net = new Net(cell, name); + + net->_PostCreate(); + + return net; +} + +Box Net::GetBoundingBox() const +// **************************** +{ + Box boundingBox; + for_each_component(component, GetComponents()) { + boundingBox.Merge(component->GetBoundingBox()); + end_for; + } + return boundingBox; +} + +RoutingPads Net::GetRoutingPads() const +// ************************ +{ + // return GetComponents().GetSubSet(); + return SubTypeCollection(GetComponents()); +} + +Plugs Net::GetPlugs() const +// ************************ +{ + // return GetComponents().GetSubSet(); + return SubTypeCollection(GetComponents()); +} + +Pins Net::GetPins() const +// ********************** +{ + // return GetComponents().GetSubSet(); + return SubTypeCollection(GetComponents()); +} + +Contacts Net::GetContacts() const +// ****************************** +{ + // return GetComponents().GetSubSet(); + return SubTypeCollection(GetComponents()); +} + +Segments Net::GetSegments() const +// ****************************** +{ + // return GetComponents().GetSubSet(); + return SubTypeCollection(GetComponents()); +} + +Verticals Net::GetVerticals() const +// ******************************** +{ + // return GetComponents().GetSubSet(); + return SubTypeCollection(GetComponents()); +} + +Horizontals Net::GetHorizontals() const +// ************************************ +{ + // return GetComponents().GetSubSet(); + return SubTypeCollection(GetComponents()); +} + +Pads Net::GetPads() const +// ********************** +{ + // return GetComponents().GetSubSet(); + return SubTypeCollection(GetComponents()); +} + +Plugs Net::GetSlavePlugs() const +// ***************************** +{ + return Net_SlavePlugs(this); +} + +Plugs Net::GetConnectedSlavePlugs() const +// ************************************** +{ + return GetSlavePlugs().GetSubSet(Plug::GetIsConnectedFilter()); +} + +Plugs Net::GetUnconnectedSlavePlugs() const +// **************************************** +{ + return GetSlavePlugs().GetSubSet(Plug::GetIsUnconnectedFilter()); +} + +NetFilter Net::GetIsCellNetFilter() +// ******************************* +{ + return Net_IsCellNetFilter(); +} + +NetFilter Net::GetIsDeepNetFilter() +// ******************************* +{ + return Net_IsDeepNetFilter(); +} + +NetFilter Net::GetIsGlobalFilter() +// ******************************* +{ + return Net_IsGlobalFilter(); +} + +NetFilter Net::GetIsExternalFilter() +// ********************************* +{ + return Net_IsExternalFilter(); +} + +NetFilter Net::GetIsInternalFilter() +// ********************************* +{ + return !Net_IsExternalFilter(); +} + +NetFilter Net::GetIsClockFilter() +// ****************************** +{ + return Net_IsClockFilter(); +} + +NetFilter Net::GetIsSupplyFilter() +// ******************************* +{ + return Net_IsSupplyFilter(); +} + +NetFilter Net::GetIsPowerFilter() +// ******************************* +{ + return Net_IsPowerFilter(); +} + +NetFilter Net::GetIsGroundFilter() +// ******************************* +{ + return Net_IsGroundFilter(); +} + +void Net::SetName(const Name& name) +// ******************************** +{ + if (name != _name) { + if (name.IsEmpty()) + throw Error("Can't change net name : empty name"); + + if (_cell->GetNet(name)) + throw Error("Can't change net name : already exists"); + + _cell->_GetNetMap()._Remove(this); + _name = name; + _cell->_GetNetMap()._Insert(this); + } +} + +void Net::SetArity(const Arity& arity) +// *********************************** +{ + _arity = arity; +} + +void Net::SetGlobal(bool isGlobal) +// ******************************* +{ + _isGlobal = isGlobal; +} + +void Net::SetExternal(bool isExternal) +// *********************************** +{ + if (isExternal != _isExternal) { + if (!isExternal) { + if (!GetConnectedSlavePlugs().IsEmpty()) + throw Error("Can't set internal : has connected slave plugs"); + _direction = Direction::UNDEFINED; + } + _isExternal = isExternal; + if (_isExternal) { + OpenUpdateSession(); + SetPosition(Point(0, 0)); + for_each_instance(instance, _cell->GetSlaveInstances()) { + Plug::_Create(instance, this); + end_for; + } + CloseUpdateSession(); + } + } +} + +void Net::SetType(const Type& type) +// ******************************** +{ + _type = type; +} + +void Net::SetPosition(const Point& position) +// ***************************************** +{ + if (_position != position) { + for_each_plug(plug, GetSlavePlugs()) { + plug->Invalidate(true); + end_for; + } + _position = position; + } +} + +void Net::SetDirection(const Direction& direction) +// *********************************************** +{ + _direction = direction; +} + +void Net::Materialize() +// ******************** +{ + for_each_component(component, GetComponents()) { + component->Materialize(); + end_for; + } + for_each_rubber(rubber, GetRubbers()) { + rubber->Materialize(); + end_for; + } +} + +void Net::Unmaterialize() +// ********************** +{ + for_each_rubber(rubber, GetRubbers()) { + rubber->Unmaterialize(); + end_for; + } + for_each_component(component, GetComponents()) { + component->Unmaterialize(); + end_for; + } +} + +static void MergeNets(Net* net1, Net* net2) +// **************************************** +{ + assert(net1); + assert(net2); + + if (net2->GetName()[0] != '~') { + if ((net1->GetName()[0] == '~') || + (net2->IsGlobal() && !net1->IsGlobal()) || + (net2->IsExternal() && !net1->IsExternal())) { + Net* tmpNet = net1; + net1 = net2; + net2 = tmpNet; + } + } + + if (net2->IsExternal() && !net1->IsExternal()) { + Net* tmpNet = net1; + net1 = net2; + net2 = tmpNet; + } + + net1->Merge(net2); +} + +void Net::Merge(Net* net) +// ********************** +{ + if (!net) + throw Error("Can't merge net : null net"); + + if (net == this) + throw Error("Can't merge net : itself"); + + if (net->GetCell() != _cell) + throw Error("Can't merge net : incompatible net"); + + if (!IsExternal() && net->IsExternal() && !net->GetConnectedSlavePlugs().IsEmpty()) + throw Error("Can't merge net : incompatible net"); + + for_each_rubber(rubber, net->GetRubbers()) rubber->_SetNet(this); end_for; + for_each_component(component, net->GetComponents()) component->_SetNet(this); end_for; + + if (IsExternal() && net->IsExternal()) { + for_each_plug(plug, net->GetConnectedSlavePlugs()) { + Plug* mainPlug = plug->GetInstance()->GetPlug(this); + if (mainPlug->IsConnected() && (mainPlug->GetNet() != plug->GetNet())) + MergeNets(mainPlug->GetNet(), plug->GetNet()); + end_for; + } + for_each_plug(plug, net->GetConnectedSlavePlugs()) { + Plug* mainPlug = plug->GetInstance()->GetPlug(this); + if (!mainPlug->IsConnected()) mainPlug->SetNet(plug->GetNet()); + Hook* masterHook = plug->GetBodyHook(); + Hook* nextMasterHook = masterHook->GetNextMasterHook(); + if (nextMasterHook != masterHook) { + masterHook->Detach(); + mainPlug->GetBodyHook()->Merge(nextMasterHook); + } + Hooks slaveHooks = masterHook->GetSlaveHooks(); + while (!slaveHooks.IsEmpty()) { + Hook* slaveHook = slaveHooks.GetFirst(); + slaveHook->Detach(); + slaveHook->Attach(mainPlug->GetBodyHook()); + } + plug->_Delete(); + end_for; + } + } + + net->Delete(); +} + +void Net::_PostCreate() +// ******************** +{ + _cell->_GetNetMap()._Insert(this); + + if (_isExternal) { + for_each_instance(instance, _cell->GetSlaveInstances()) { + Plug::_Create(instance, this); + end_for; + } + } + + Inherit::_PostCreate(); +} + +void Net::_PreDelete() +// ******************* +{ + Inherit::_PreDelete(); + + for_each_plug(slavePlug, GetSlavePlugs()) slavePlug->_Delete(); end_for; + + Unmaterialize(); + + for_each_rubber(rubber, GetRubbers()) rubber->_Delete(); end_for; + + for_each_component(component, GetComponents()) { + for_each_hook(hook, component->GetHooks()) { + // 15 05 2006 xtof : detach all hooks in rings when + // a net deletion occurs, can't see why master hooks were not detached. + //if (!hook->IsMaster()) hook->Detach(); + hook->Detach(); + end_for; + } + end_for; + } + + for_each_component(component, GetComponents()) { + if (!is_a(component)) + component->Delete(); + else + ((Plug*)component)->SetNet(NULL); + end_for; + } + + _cell->_GetNetMap()._Remove(this); +} + +string Net::_GetString() const +// *************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_name)); + return s; +} + +Record* Net::_GetRecord() const +// ********************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Cell", _cell)); + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("Arity", &_arity)); + record->Add(GetSlot("Global", &_isGlobal)); + record->Add(GetSlot("External", &_isExternal)); + record->Add(GetSlot("Type", _type)); + record->Add(GetSlot("Direction", _direction)); + record->Add(GetSlot("Position", &_position)); + record->Add(GetSlot("Components", &_componentSet)); + record->Add(GetSlot("Rubbers", &_rubberSet)); + record->Add(GetSlot("External", &_isExternal)); + } + return record; +} + +// **************************************************************************************************** +// Net::Type implementation +// **************************************************************************************************** + +Net::Type::Type(const Code& code) +// ****************************** +: _code(code) +{ +} + +Net::Type::Type(const Type& type) +// ****************************** +: _code(type._code) +{ +} + +Net::Type& Net::Type::operator=(const Type& type) +// ********************************************** +{ + _code = type._code; + return *this; +} + +string Net::Type::_GetString() const +// ********************************* +{ + return GetString(&_code); +} + +Record* Net::Type::_GetRecord() const +// **************************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Code", &_code)); + return record; +} + + + +// **************************************************************************************************** +// Net::Direction implementation +// **************************************************************************************************** + +Net::Direction::Direction(const Code& code) +// **************************************** +: _code(code) +{ +} + +Net::Direction::Direction(const Direction& direction) +// ************************************************** +: _code(direction._code) +{ +} + +Net::Direction& Net::Direction::operator=(const Direction& direction) +// ****************************************************************** +{ + _code = direction._code; + return *this; +} + +string Net::Direction::_GetString() const +// ************************************** +{ + return GetString(&_code); +} + +Record* Net::Direction::_GetRecord() const +// ********************************* +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Code", &_code)); + return record; +} + + + +// **************************************************************************************************** +// Net::ComponentSet implementation +// **************************************************************************************************** + +Net::ComponentSet::ComponentSet() +// ****************************** +: Inherit() +{ +} + +unsigned Net::ComponentSet::_GetHashValue(Component* component) const +// ****************************************************************** +{ + return ( (unsigned int)( (unsigned long)component ) ) / 8; +} + +Component* Net::ComponentSet::_GetNextElement(Component* component) const +// ********************************************************************** +{ + return component->_GetNextOfNetComponentSet(); +} + +void Net::ComponentSet::_SetNextElement(Component* component, Component* nextComponent) const +// ****************************************************************************************** +{ + component->_SetNextOfNetComponentSet(nextComponent); +} + + + +// **************************************************************************************************** +// Net::RubberSet implementation +// **************************************************************************************************** + +Net::RubberSet::RubberSet() +// ************************ +: Inherit() +{ +} + +unsigned Net::RubberSet::_GetHashValue(Rubber* rubber) const +// ********************************************************* +{ + return ( (unsigned int)( (unsigned long)rubber ) ) / 8; +} + +Rubber* Net::RubberSet::_GetNextElement(Rubber* rubber) const +// ********************************************************** +{ + return rubber->_GetNextOfNetRubberSet(); +} + +void Net::RubberSet::_SetNextElement(Rubber* rubber, Rubber* nextRubber) const +// *************************************************************************** +{ + rubber->_SetNextOfNetRubberSet(nextRubber); +} + + + +// **************************************************************************************************** +// Net_SlavePlugs implementation +// **************************************************************************************************** + +Net_SlavePlugs::Net_SlavePlugs(const Net* net) +// ******************************************* +: Inherit(), + _net(net) +{ +} + +Net_SlavePlugs::Net_SlavePlugs(const Net_SlavePlugs& slavePlugs) +// ************************************************************* +: Inherit(), + _net(slavePlugs._net) +{ +} + +Net_SlavePlugs& Net_SlavePlugs::operator=(const Net_SlavePlugs& slavePlugs) +// ************************************************************************ +{ + _net = slavePlugs._net; + return *this; +} + +Collection* Net_SlavePlugs::GetClone() const +// ************************************************ +{ + return new Net_SlavePlugs(*this); +} + +Locator* Net_SlavePlugs::GetLocator() const +// *********************************************** +{ + return new Locator(_net); +} + +string Net_SlavePlugs::_GetString() const +// ************************************** +{ + string s = "<" + _TName("Net::SlavePlugs"); + if (_net) s += " " + GetString(_net); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Net_SlavePlugs::Locator implementation +// **************************************************************************************************** + +Net_SlavePlugs::Locator::Locator(const Net* net) +// ********************************************* +: Inherit(), + _net(net), + _plug(NULL), + _instanceLocator() +{ + if (_net) { + _instanceLocator = _net->GetCell()->GetSlaveInstances().GetLocator(); + while (!_plug && _instanceLocator.IsValid()) { + _plug = _instanceLocator.GetElement()->GetPlug(_net); + _instanceLocator.Progress(); + } + } +} + +Net_SlavePlugs::Locator::Locator(const Locator& locator) +// ***************************************************** +: Inherit(), + _net(locator._net), + _plug(locator._plug), + _instanceLocator(locator._instanceLocator) +{ +} + +Net_SlavePlugs::Locator& Net_SlavePlugs::Locator::operator=(const Locator& locator) +// ******************************************************************************** +{ + _net = locator._net; + _plug = locator._plug; + _instanceLocator = locator._instanceLocator; + return *this; +} + +Plug* Net_SlavePlugs::Locator::GetElement() const +// ********************************************** +{ + return _plug; +} + +Locator* Net_SlavePlugs::Locator::GetClone() const +// ****************************************************** +{ + return new Locator(*this); +} + +bool Net_SlavePlugs::Locator::IsValid() const +// ****************************************** +{ + return (_plug != NULL); +} + +void Net_SlavePlugs::Locator::Progress() +// ************************************* +{ + if (IsValid()) { + _plug = NULL; + while (!_plug && _instanceLocator.IsValid()) { + _plug = _instanceLocator.GetElement()->GetPlug(_net); + _instanceLocator.Progress(); + } + } +} + +string Net_SlavePlugs::Locator::_GetString() const +// *********************************************** +{ + string s = "<" + _TName("Net::SlavePlugs::Locator"); + if (_net) s += " " + GetString(_net); + s += ">"; + return s; +} + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Net.h b/hurricane/src/hurricane/Net.h new file mode 100644 index 00000000..7b2c98ab --- /dev/null +++ b/hurricane/src/hurricane/Net.h @@ -0,0 +1,298 @@ +// **************************************************************************************************** +// File: Net.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_NET +#define HURRICANE_NET + +#include "Entity.h" +#include "Nets.h" +#include "Component.h" +#include "Rubbers.h" +#include "Rubber.h" +#include "RoutingPads.h" +#include "Plugs.h" +#include "Pins.h" +#include "Contacts.h" +#include "Segments.h" +#include "Verticals.h" +#include "Horizontals.h" +#include "Pads.h" +#include "IntrusiveSet.h" +#include "Path.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Net declaration +// **************************************************************************************************** + +class Net : public Entity { +// ********************** + +// Types +// ***** + + public: typedef Entity Inherit; + + public: typedef unsigned Arity; + + public: class Type { + // *************** + + public: enum Code {UNDEFINED=0, LOGICAL=1, CLOCK=2, POWER=3, GROUND=4}; + + private: Code _code; + + public: Type(const Code& code = UNDEFINED); + public: Type(const Type& type); + + public: Type& operator=(const Type& type); + + public: operator const Code&() const {return _code;}; + + public: const Code& GetCode() const {return _code;}; + + public: string _GetTypeName() const { return _TName("Net::type"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + }; + + public: class Direction { + // ******************** + + public: enum Code {UNDEFINED=0, IN=1, OUT=2, INOUT=3, TRISTATE=4}; + + private: Code _code; + + public: Direction(const Code& code = UNDEFINED); + public: Direction(const Direction& direction); + + public: Direction& operator=(const Direction& direction); + + public: operator const Code&() const {return _code;}; + + public: const Code& GetCode() const {return _code;}; + + public: string _GetTypeName() const { return _TName("Net::Direction"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + }; + + class ComponentSet : public IntrusiveSet { + // ************************************************ + + public: typedef IntrusiveSet Inherit; + + public: ComponentSet(); + + public: virtual unsigned _GetHashValue(Component* component) const; + public: virtual Component* _GetNextElement(Component* component) const; + public: virtual void _SetNextElement(Component* component, Component* nextComponent) const; + + }; + + class RubberSet : public IntrusiveSet { + // ****************************************** + + public: typedef IntrusiveSet Inherit; + + public: RubberSet(); + + public: virtual unsigned _GetHashValue(Rubber* rubber) const; + public: virtual Rubber* _GetNextElement(Rubber* rubber) const; + public: virtual void _SetNextElement(Rubber* rubber, Rubber* nextRubber) const; + + }; + +// Attributes +// ********** + + private: Cell* _cell; + private: Name _name; + private: Arity _arity; + private: bool _isGlobal; + private: bool _isExternal; + private: Type _type; + private: Direction _direction; + private: Point _position; + private: ComponentSet _componentSet; + private: RubberSet _rubberSet; + private: Net* _nextOfCellNetMap; + +// Constructors +// ************ + + protected: Net(Cell* cell, const Name& name); + + public: static Net* Create(Cell* cell, const Name& name); + +// Accessors +// ********* + + public: virtual Cell* GetCell() const {return _cell;}; + public: virtual Box GetBoundingBox() const; + public: const Name& GetName() const {return _name;}; + public: const Arity& GetArity() const {return _arity;}; + public: const Type& GetType() const {return _type;}; + public: const Direction& GetDirection() const {return _direction;}; + public: const Point& GetPosition() const {return _position;}; + public: const Unit& GetX() const {return _position.GetX();}; + public: const Unit& GetY() const {return _position.GetY();}; + public: Components GetComponents() const {return _componentSet.GetElements();}; + public: Rubbers GetRubbers() const {return _rubberSet.GetElements();}; + public: RoutingPads GetRoutingPads() const; + public: Plugs GetPlugs() const; + public: Pins GetPins() const; + public: Contacts GetContacts() const; + public: Segments GetSegments() const; + public: Verticals GetVerticals() const; + public: Horizontals GetHorizontals() const; + public: Pads GetPads() const; + public: Plugs GetSlavePlugs() const; + public: Plugs GetConnectedSlavePlugs() const; + public: Plugs GetUnconnectedSlavePlugs() const; + +// Filters +// ******* + + public: static NetFilter GetIsCellNetFilter(); + public: static NetFilter GetIsDeepNetFilter(); + public: static NetFilter GetIsGlobalFilter(); + public: static NetFilter GetIsExternalFilter(); + public: static NetFilter GetIsInternalFilter(); + public: static NetFilter GetIsClockFilter(); + public: static NetFilter GetIsSupplyFilter(); + public: static NetFilter GetIsPowerFilter(); + public: static NetFilter GetIsGroundFilter(); + +// Predicates +// ********** + + public: virtual bool IsDeepNet () const {return false;}; + public: bool IsGlobal () const {return _isGlobal;}; + public: bool IsExternal() const {return _isExternal;}; + public: bool IsLogical () const {return (_type == Type::LOGICAL);}; + public: bool IsClock () const {return (_type == Type::CLOCK);}; + public: bool IsPower () const {return (_type == Type::POWER);}; + public: bool IsGround () const {return (_type == Type::GROUND);}; + public: bool IsSupply () const {return (IsPower() || IsGround());}; + +// Updators +// ******** + + public: void SetName(const Name& name); + public: void SetArity(const Arity& arity); + public: void SetGlobal(bool isGlobal); + public: void SetExternal(bool isExternal); + public: void SetType(const Type& type); + public: void SetDirection(const Direction& direction); + public: void SetPosition(const Point& position); + public: void Materialize(); + public: void Unmaterialize(); + public: void Merge(Net* net); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("Net");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: ComponentSet& _GetComponentSet() {return _componentSet;}; + public: RubberSet& _GetRubberSet() {return _rubberSet;}; + public: Net* _GetNextOfCellNetMap() const {return _nextOfCellNetMap;}; + + public: void _SetNextOfCellNetMap(Net* net) {_nextOfCellNetMap = net;}; + +}; + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName + ( const Net::Type::Code* object ) + { return ">"; } + +template<> + inline string ProxyString + ( const Net::Type::Code* object ) + { + switch ( *object ) { + case Net::Type::UNDEFINED: return "UNDEFINED"; + case Net::Type::LOGICAL: return "LOGICAL"; + case Net::Type::CLOCK: return "CLOCK"; + case Net::Type::POWER: return "POWER"; + case Net::Type::GROUND: return "GROUND"; + } + return "ABNORMAL"; + } + +template<> + inline Record* ProxyRecord + ( const Net::Type::Code* object ) + { + Record* record = new Record(GetString(object)); + record->Add(GetSlot("Code", (unsigned int*)object)); + return record; + } + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName + ( const Net::Direction::Code* object ) + { return ">"; } + +template<> + inline string ProxyString + ( const Net::Direction::Code* object ) + { + switch ( *object ) { + case Net::Direction::UNDEFINED: return "UNDEFINED"; + case Net::Direction::IN: return "IN"; + case Net::Direction::OUT: return "OUT"; + case Net::Direction::INOUT: return "INOUT"; + case Net::Direction::TRISTATE: return "TRISTATE"; + } + return "ABNORMAL"; + } + +template<> + inline Record* ProxyRecord + ( const Net::Direction::Code* object ) + { + Record* record = new Record(GetString(object)); + record->Add(GetSlot("Code", (unsigned int*)object)); + return record; + } + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Net) + + +#endif // HURRICANE_NET + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/NetExternalComponents.cpp b/hurricane/src/hurricane/NetExternalComponents.cpp new file mode 100644 index 00000000..d2fa8878 --- /dev/null +++ b/hurricane/src/hurricane/NetExternalComponents.cpp @@ -0,0 +1,60 @@ +// **************************************************************************************************** +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: NetExternalComponents.cpp +// Author: C. Alexandre +// **************************************************************************************************** + +#include "Error.h" +#include "Relation.h" +#include "Net.h" + +#include "NetExternalComponents.h" + +namespace Hurricane { + +static Name ExternalComponentsRelationName("ExternalComponentsRelation"); + +static StandardRelation* GetExternalComponentsRelation(const Net* net) +{ + Property* property = net->GetProperty(ExternalComponentsRelationName); + if (!property) + return NULL; + else + { + StandardRelation* relation = dynamic_cast(property); + if (!relation) + throw Error("Bad Property type: Must be a Standard Relation"); + return relation; + } + +} + +Components GetExternalComponents(const Net* net) +{ + if (!net->IsExternal()) + throw Error("Impossible to retrieve external components on non external net " + + net->GetName()._GetString()); + + StandardRelation* externalComponentsRelation = GetExternalComponentsRelation(net); + if (!externalComponentsRelation) + return Components(); + return externalComponentsRelation->GetSlaveOwners().GetSubSet(); +} + +void SetExternal(Component* component) +{ + Net* net = component->GetNet(); + if (!net->IsExternal()) + throw Error("Impossible to set as external a component member of non external net " + + net->GetName()._GetString()); + StandardRelation* externalComponentsRelation = GetExternalComponentsRelation(net); + if (!externalComponentsRelation) + externalComponentsRelation = StandardRelation::Create(net, ExternalComponentsRelationName); + component->Put(externalComponentsRelation); +} + +} // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/NetExternalComponents.h b/hurricane/src/hurricane/NetExternalComponents.h new file mode 100644 index 00000000..cc3e855f --- /dev/null +++ b/hurricane/src/hurricane/NetExternalComponents.h @@ -0,0 +1,25 @@ +// **************************************************************************************************** +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: NetExternalComponents.h +// Authors: C. Alexandre +// **************************************************************************************************** + +#ifndef HURRICANE_NET_EXTERNAL_COMPONENTS +#define HURRICANE_NET_EXTERNAL_COMPONENTS + +#include "Component.h" + +namespace Hurricane { + +Components GetExternalComponents(const Net* net); + +void SetExternal(Component* component); + + +} // End of Hurricane namespace. + +#endif // HURRICANE_NET_EXTERNAL_COMPONENTS diff --git a/hurricane/src/hurricane/Nets.h b/hurricane/src/hurricane/Nets.h new file mode 100644 index 00000000..99903554 --- /dev/null +++ b/hurricane/src/hurricane/Nets.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Nets.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_NETS +#define HURRICANE_NETS + +#include "Collection.h" + +namespace Hurricane { + +class Net; + + + +// **************************************************************************************************** +// Nets declaration +// **************************************************************************************************** + +typedef GenericCollection Nets; + + + +// **************************************************************************************************** +// NetLocator declaration +// **************************************************************************************************** + +typedef GenericLocator NetLocator; + + + +// **************************************************************************************************** +// NetFilter declaration +// **************************************************************************************************** + +typedef GenericFilter NetFilter; + + + +// **************************************************************************************************** +// for_each_net declaration +// **************************************************************************************************** + +#define for_each_net(net, nets)\ +/******************************/\ +{\ + NetLocator _locator = nets.GetLocator();\ + while (_locator.IsValid()) {\ + Net* net = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_NETS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Occurrence.cpp b/hurricane/src/hurricane/Occurrence.cpp new file mode 100644 index 00000000..7617aa01 --- /dev/null +++ b/hurricane/src/hurricane/Occurrence.cpp @@ -0,0 +1,247 @@ +// **************************************************************************************************** +// File: Occurrence.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Occurrence.h" +#include "Entity.h" +#include "Cell.h" +#include "SharedPath.h" +#include "Property.h" +#include "Quark.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Occurrence implementation +// **************************************************************************************************** + +Occurrence::Occurrence(const Entity* entity) +// ********************************* + : _entity(const_cast(entity)), + _sharedPath(NULL) +{ +} + +Occurrence::Occurrence(const Entity* entity, const Path& path) +// *************************************************** + : _entity(const_cast(entity)), + _sharedPath(path._GetSharedPath()) +{ + if (!_entity) { + throw Error("Can't create " + _TName("Occurrence") + " : null entity"); + } + if (_sharedPath) + if (_entity->GetCell() != _sharedPath->GetMasterCell()) + throw Error("Can't create " + _TName("Occurrence") + " : incompatible path"); +} + +Occurrence::Occurrence(const Occurrence& occurrence) +// ********************************************* +: _entity(occurrence._entity), + _sharedPath(occurrence._sharedPath) +{ +} + +Occurrence& Occurrence::operator=(const Occurrence& occurrence) +// ******************************************************** +{ + _entity = occurrence._entity; + _sharedPath = occurrence._sharedPath; + return *this; +} + +bool Occurrence::operator==(const Occurrence& occurrence) const +// ********************************************************* +{ + return _entity && occurrence._entity && + (_entity == occurrence._entity) && + (_sharedPath == occurrence._sharedPath); +} + +bool Occurrence::operator!=(const Occurrence& occurrence) const +// ********************************************************* +{ + return !_entity || + !occurrence._entity || + (_entity != occurrence._entity) || + (_sharedPath != occurrence._sharedPath); +} + +bool Occurrence::operator<(const Occurrence& occurrence) const +// ******************************************************** +{ + return ((_entity < occurrence._entity) || + ((_entity == occurrence._entity) && (_sharedPath < occurrence._sharedPath))); +} + +Cell* Occurrence::GetOwnerCell() const +// ********************************** +{ + if (!_entity) return NULL; + return (_sharedPath) ? _sharedPath->GetOwnerCell() : _entity->GetCell(); +} + +Cell* Occurrence::GetMasterCell() const +// *********************************** +{ + return (_entity) ? _entity->GetCell() : NULL; +} + +Property* Occurrence::GetProperty(const Name& name) const +// ***************************************************** +{ + if (_entity) { + //DBo* quark = _GetQuark(); + Quark* quark = _GetQuark(); + if (quark) return quark->GetProperty(name); + } + return NULL; +} + +Properties Occurrence::GetProperties() const +// **************************************** +{ + if (_entity) { + Quark* quark = _GetQuark(); + if (quark) return quark->GetProperties(); + } + return Properties(); +} + +Box Occurrence::GetBoundingBox() const +// ********************************** +{ + if (!_entity) return Box(); + if (!_sharedPath) return _entity->GetBoundingBox(); + return _sharedPath->GetTransformation().GetBox(_entity->GetBoundingBox()); +} + +bool Occurrence::HasProperty() const +// ******************************** +{ + return (_GetQuark() != NULL); +} + +void Occurrence::MakeInvalid() +// ************************** +{ + _entity = NULL; + _sharedPath = NULL; +} + +void Occurrence::Put(Property* property) +// ************************************ +{ + if (!_entity) + throw Error("Can't put property : invalid occurrence"); + + if (!property) + throw Error("Can't put property : null property"); + + Quark* quark = _GetQuark(); + if (!quark) quark = Quark::_Create(*this); + quark->Put(property); +} + +void Occurrence::Remove(Property* property) +// *************************************** +{ + if (!_entity) + throw Error("Can't remove property : invalid occurrence"); + + if (!property) + throw Error("Can't remove property : null property"); + + Quark* quark = _GetQuark(); + if (quark) quark->Remove(property); +} + +void Occurrence::RemoveProperty(const Name& name) +// ********************************************* +{ + if (!_entity) + throw Error("Can't remove property : invalid occurrence"); + + Quark* quark = _GetQuark(); + if (quark) quark->RemoveProperty(name); +} + +void Occurrence::ClearProperties() +// ****************************** +{ + Quark* quark = _GetQuark(); + if (quark) quark->Delete(); +} + +string Occurrence::_GetString() const +// ********************************* +{ + string s = "<" + _TName("Occurrence"); + if (_entity) { + s += " "; + s += GetString(GetOwnerCell()); + s += ":"; + if (_sharedPath) s += GetString(_sharedPath->GetName()) + ":"; + s += GetString(_entity); + } + s += ">"; + return s; +} + +Record* Occurrence::_GetRecord() const +// **************************** +{ + Record* record = NULL; + if (_entity) { + record = new Record(GetString(this)); + record->Add(GetSlot("Entity", _entity)); + record->Add(GetSlot("SharedPath", _sharedPath)); + Quark* quark = _GetQuark(); + if (quark) record->Add(GetSlot("Quark", quark)); + } + return record; +} + +//DBo* ... +Quark* Occurrence::_GetQuark() const +// ******************************** +{ + return (_entity) ? _entity->_GetQuark(_sharedPath) : NULL; +} + +string Occurrence::GetName() const +// ******************************* +{ + string description; + + if (_sharedPath) + description=_sharedPath->GetName()+SharedPath::GetNameSeparator(); + + if (Plug* plug= dynamic_cast(_entity)) + description += plug->GetName(); + else if (Pin* pin= dynamic_cast(_entity)) + description += GetString(pin->GetName()); + else if (Net* net= dynamic_cast(_entity)) + description += GetString(net->GetName()); + else if (Cell* cell= dynamic_cast(_entity)) + description += GetString(cell->GetName()); + else if (Instance* instance= dynamic_cast(_entity)) + description += GetString(instance->GetName()); + else + description+= GetString(_entity); + //throw Error("[Occurrence::GetName] No Name for "+GetString(_entity)); + + return description; +} + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Occurrence.h b/hurricane/src/hurricane/Occurrence.h new file mode 100644 index 00000000..6d6e7233 --- /dev/null +++ b/hurricane/src/hurricane/Occurrence.h @@ -0,0 +1,102 @@ +// **************************************************************************************************** +// File: Occurrence.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_OCCURENCE +#define HURRICANE_OCCURENCE + +#include "Path.h" +#include "Name.h" +#include "Properties.h" + +namespace Hurricane { + +class Entity; +class SharedPath; +class Quark; + + + +// **************************************************************************************************** +// Occurente declaration +// **************************************************************************************************** + +class Occurrence { +// ************* + +// Attributes +// ********** + + private: Entity* _entity; + private: SharedPath* _sharedPath; + +// Constructors +// ************ + + public: Occurrence(const Entity* entity = NULL); + public: Occurrence(const Entity* entity, const Path& path); + public: Occurrence(const Occurrence& occurrence); + +// Operators +// ********* + + public: Occurrence& operator=(const Occurrence& occurrence); + + public: bool operator==(const Occurrence& occurrence) const; + public: bool operator!=(const Occurrence& occurrence) const; + + public: bool operator<(const Occurrence& occurrence) const; // for stl set -> less predicate + +// Accessors +// ********* + + public: Entity* GetEntity() const {return _entity;}; + public: Path GetPath() const {return Path(_sharedPath);}; + public: Cell* GetOwnerCell() const; + public: Cell* GetMasterCell() const; + public: Property* GetProperty(const Name& name) const; + public: Properties GetProperties() const; + public: Box GetBoundingBox() const; + +// Predicates +// ********** + + public: bool IsValid() const {return (_entity != NULL);}; + public: bool HasProperty() const; + +// Updators +// ******** + + public: void MakeInvalid(); + public: void Put(Property* property); + public: void Remove(Property* property); + public: void RemoveProperty(const Name& name); + public: void ClearProperties(); + +// Others +// ****** + + public: string GetName() const; + public: string _GetTypeName() const { return _TName("Occurrence"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + public: SharedPath* _GetSharedPath() const {return _sharedPath;}; + public: Quark* _GetQuark() const; + +}; + + + +} // End of Hurricane namespace. + + +ValueIOStreamSupport(Hurricane::Occurrence) + + +#endif // HURRICANE_OCCURENCE + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Occurrences.h b/hurricane/src/hurricane/Occurrences.h new file mode 100644 index 00000000..f6659139 --- /dev/null +++ b/hurricane/src/hurricane/Occurrences.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Occurrences.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_OCCURENCES +#define HURRICANE_OCCURENCES + +#include "Collection.h" +#include "Occurrence.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Occurrences declaration +// **************************************************************************************************** + +typedef GenericCollection Occurrences; + + + +// **************************************************************************************************** +// OccurrenceLocator declaration +// **************************************************************************************************** + +typedef GenericLocator OccurrenceLocator; + + + +// **************************************************************************************************** +// OccurrenceFilter declaration +// **************************************************************************************************** + +typedef GenericFilter OccurrenceFilter; + + + +// **************************************************************************************************** +// for_each_occurrence declaration +// **************************************************************************************************** + +#define for_each_occurrence(occurrence, occurrences)\ +/************************************************/\ +{\ + OccurrenceLocator _locator = occurrences.GetLocator();\ + while (_locator.IsValid()) {\ + Occurrence occurrence = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + + +#endif // HURRICANE_OCCURENCES + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Pad.cpp b/hurricane/src/hurricane/Pad.cpp new file mode 100644 index 00000000..4fd99f48 --- /dev/null +++ b/hurricane/src/hurricane/Pad.cpp @@ -0,0 +1,148 @@ +// **************************************************************************************************** +// File: Pad.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment BULL-LIP6 (to be seen : PROVISOIREMENT in _Draw & _Highlight) + +#include "Pad.h" +#include "Net.h" +#include "BasicLayer.h" +#include "CompositeLayer.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Pad implementation +// **************************************************************************************************** + +Pad::Pad(Net* net, Layer* layer, const Box& boundingBox) +// ***************************************************** +: Inherit(net), + _layer(layer), + _boundingBox(boundingBox) +{ + if (!_layer) + throw Error("Can't create " + _TName("Pad") + " : null layer"); + + if (_boundingBox.IsEmpty()) + throw Error("Can't create " + _TName("Pad") + " : empty bounding box"); +} + +Pad* Pad::Create(Net* net, Layer* layer, const Box& boundingBox) +// ************************************************************* +{ + Pad* pad = new Pad(net, layer, boundingBox); + + pad->_PostCreate(); + + return pad; +} + +Unit Pad::GetX() const +// ******************* +{ + return 0; +} + +Unit Pad::GetY() const +// ******************* +{ + return 0; +} + +Box Pad::GetBoundingBox() const +// **************************** +{ + Box boundingBox = _boundingBox; + + if (is_a(_layer)) + boundingBox.Inflate(((CompositeLayer*)_layer)->GetMaximalPadSize()); + + return boundingBox; +} + +Box Pad::GetBoundingBox(BasicLayer* basicLayer) const +// ************************************************** +{ + if (!_layer->Contains(basicLayer)) return Box(); + + Box boundingBox = _boundingBox; + + if (is_a(_layer)) + boundingBox.Inflate(((CompositeLayer*)_layer)->GetPadSize(basicLayer)); + + return boundingBox; +} + +void Pad::Translate(const Unit& dx, const Unit& dy) +// ************************************************ +{ + if ((dx != 0) || (dy != 0)) { + Invalidate(true); + _boundingBox.Translate(dx, dy); + } +} + +void Pad::SetBoundingBox(const Box& boundingBox) +// ********************************************* +{ + if (_boundingBox.IsEmpty()) + throw Error("Can't set bounding box : empty bounding box"); + + if (boundingBox != _boundingBox) { + Invalidate(true); + _boundingBox = boundingBox; + } +} + +string Pad::_GetString() const +// *************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_layer->GetName())); + s.insert(s.length() - 1, " " + GetString(_boundingBox)); + return s; +} + +Record* Pad::_GetRecord() const +// ********************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Layer", _layer)); + record->Add(GetSlot("BoundingBox", &_boundingBox)); + } + return record; +} + +//void Pad::_Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) +//// **************************************************************************************************** +//{ +// Unit width = _boundingBox.GetWidth(); +// Unit height = _boundingBox.GetHeight(); +// if (1 < view->GetScreenSize(max(width, height))) { +// basicLayer->_Fill(view, transformation.GetBox(GetBoundingBox(basicLayer))); +// view->DrawRectangle(transformation.GetBox(GetBoundingBox(basicLayer))); // PROVISOIREMENT +// } +//} +// +//void Pad::_Highlight(View* view, const Box& updateArea, const Transformation& transformation) +//// ****************************************************************************************** +//{ +// for_each_basic_layer(basicLayer, GetLayer()->GetBasicLayers()) { +// basicLayer->_Fill(view, transformation.GetBox(GetBoundingBox(basicLayer))); +// view->DrawRectangle(transformation.GetBox(GetBoundingBox(basicLayer))); // PROVISOIREMENT +// end_for; +// } +//} +// + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Pad.h b/hurricane/src/hurricane/Pad.h new file mode 100644 index 00000000..95e56ac0 --- /dev/null +++ b/hurricane/src/hurricane/Pad.h @@ -0,0 +1,82 @@ +// **************************************************************************************************** +// File: Pad.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment BULL-LIP6 + +#ifndef HURRICANE_PAD +#define HURRICANE_PAD + +#include "Component.h" +#include "Pads.h" + +namespace Hurricane { + +class Layer; + + + +// **************************************************************************************************** +// Pad declaration +// **************************************************************************************************** + +class Pad : public Component { +// ************************* + +// Types +// ***** + + public: typedef Component Inherit; + +// Attributes +// ********** + + private: Layer* _layer; + private: Box _boundingBox; + +// Constructors +// ************ + + protected: Pad(Net* net, Layer* layer, const Box& boundingBox); + + public: static Pad* Create(Net* net, Layer* layer, const Box& boundingBox); + +// Accessors +// ********* + + public: virtual Unit GetX() const; + public: virtual Unit GetY() const; + public: virtual Box GetBoundingBox() const; + public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const; + public: virtual Layer* GetLayer() const {return _layer;}; + +// Updators +// ******** + + public: virtual void Translate(const Unit& dx, const Unit& dy); + public: void SetBoundingBox(const Box& boundingBox); + +// Others +// ****** + + public: virtual string _GetTypeName() const {return _TName("Pad");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + +// public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation); +// public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Pad) + +#endif // HURRICANE_PAD + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Pads.h b/hurricane/src/hurricane/Pads.h new file mode 100644 index 00000000..4967a6e8 --- /dev/null +++ b/hurricane/src/hurricane/Pads.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Pads.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_PADS +#define HURRICANE_PADS + +#include "Collection.h" + +namespace Hurricane { + +class Pad; + + + +// **************************************************************************************************** +// Pads declaration +// **************************************************************************************************** + +typedef GenericCollection Pads; + + + +// **************************************************************************************************** +// PadLocator declaration +// **************************************************************************************************** + +typedef GenericLocator PadLocator; + + + +// **************************************************************************************************** +// PadFilter declaration +// **************************************************************************************************** + +typedef GenericFilter PadFilter; + + + +// **************************************************************************************************** +// for_each_pad declaration +// **************************************************************************************************** + +#define for_each_pad(pad, pads)\ +/******************************/\ +{\ + PadLocator _locator = pads.GetLocator();\ + while (_locator.IsValid()) {\ + Pad* pad = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_PADS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Path.cpp b/hurricane/src/hurricane/Path.cpp new file mode 100644 index 00000000..2b99be21 --- /dev/null +++ b/hurricane/src/hurricane/Path.cpp @@ -0,0 +1,264 @@ +// **************************************************************************************************** +// File: Path.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Path.h" +#include "SharedPath.h" +#include "Cell.h" +#include "Instance.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Path implementation +// **************************************************************************************************** + +Path::Path(SharedPath* sharedPath) +// ******************************* +: _sharedPath(sharedPath) +{ +} + +Path::Path(Instance* instance) +// *************************** +: _sharedPath(NULL) +{ + if (instance) { + _sharedPath = instance->_GetSharedPath(NULL); + if (!_sharedPath) _sharedPath = new SharedPath(instance); + } +} + +Path::Path(Instance* headInstance, const Path& tailPath) +// ***************************************************** +: _sharedPath(NULL) +{ + if (!headInstance) + throw Error("Cant't create " + _TName("Path") + " : null head instance"); + + if (!tailPath._GetSharedPath()) { + _sharedPath = headInstance->_GetSharedPath(NULL); + if (!_sharedPath) _sharedPath = new SharedPath(headInstance); + } + else { + SharedPath* tailSharedPath = tailPath._GetSharedPath(); + if (tailSharedPath->GetOwnerCell() != headInstance->GetMasterCell()) + throw Error("Cant't create " + _TName("Path") + " : incompatible tail path"); + + _sharedPath = headInstance->_GetSharedPath(tailSharedPath); + if (!_sharedPath) _sharedPath = new SharedPath(headInstance, tailSharedPath); + } +} + +Path::Path(const Path& headPath, Instance* tailInstance) +// ***************************************************** +: _sharedPath(NULL) +{ + if (!tailInstance) + throw Error("Cant't create " + _TName("Path") + " : null tail instance"); + + if (!headPath._GetSharedPath()) { + _sharedPath = tailInstance->_GetSharedPath(NULL); + if (!_sharedPath) _sharedPath = new SharedPath(tailInstance); + } + else { + Instance* headInstance = headPath.GetHeadInstance(); + SharedPath* tailSharedPath = Path(headPath.GetTailPath(), tailInstance)._GetSharedPath(); + _sharedPath = headInstance->_GetSharedPath(tailSharedPath); + if (!_sharedPath) _sharedPath = new SharedPath(headInstance, tailSharedPath); + } +} + +Path::Path(const Path& headPath, const Path& tailPath) +// ***************************************************** +: _sharedPath(tailPath._GetSharedPath()) +{ + vector instances; + headPath.GetInstances().Fill(instances); + + for (vector::reverse_iterator rit=instances.rbegin() ; rit != instances.rend() ; rit++) + { Instance* instance=*rit; + SharedPath* sharedPath = _sharedPath; + _sharedPath = instance->_GetSharedPath(sharedPath); + if (!_sharedPath) _sharedPath = new SharedPath(instance,sharedPath); + } +} + +Path::Path(Cell* cell, const string& pathName) +// ******************************************* +: _sharedPath(NULL) +{ + if (cell) { + list instanceList; + string restOfPathName = pathName; + char nameSeparator = GetNameSeparator(); + while (!restOfPathName.empty()) { + size_t pos = restOfPathName.find(nameSeparator); + Instance* instance = cell->GetInstance(restOfPathName.substr(0, pos)); + if (!instance) throw Error("Cant't create " + _TName("Path") + " : invalid path name"); + cell = instance->GetMasterCell(); + restOfPathName = (pos == string::npos) ? string("") : restOfPathName.substr(pos + 1); + instanceList.push_back(instance); + } + if (!instanceList.empty()) { + list::reverse_iterator instanceIterator = instanceList.rbegin(); + while (instanceIterator != instanceList.rend()) { + Instance* headInstance = *instanceIterator; + SharedPath* tailSharedPath = _sharedPath; + _sharedPath = headInstance->_GetSharedPath(tailSharedPath); + if (!_sharedPath) _sharedPath = new SharedPath(headInstance, tailSharedPath); + ++instanceIterator; + } + } + } +} + +Path::Path(const Path& path) +// ************************* +: _sharedPath(path._sharedPath) +{ +} + +Path::~Path() +// ********** +{ +} + +Path& Path::operator=(const Path& path) +// ************************************ +{ + _sharedPath = path._sharedPath; + return *this; +} + +bool Path::operator==(const Path& path) const +// ****************************************** +{ + return (_sharedPath == path._sharedPath); +} + +bool Path::operator!=(const Path& path) const +// ****************************************** +{ + return (_sharedPath != path._sharedPath); +} + +bool Path::operator<(const Path& path) const +// ***************************************** +{ + return (_sharedPath < path._sharedPath); +} + +Instance* Path::GetHeadInstance() const +// ************************************ +{ + return (_sharedPath) ? _sharedPath->GetHeadInstance() : NULL; +} + +Path Path::GetTailPath() const +// *************************** +{ + return Path((_sharedPath) ? _sharedPath->GetTailSharedPath() : NULL); +} + +Path Path::GetHeadPath() const +// *************************** +{ + return Path((_sharedPath) ? _sharedPath->GetHeadSharedPath() : NULL); +} + +Instance* Path::GetTailInstance() const +// ************************************ +{ + return (_sharedPath) ? _sharedPath->GetTailInstance() : NULL; +} + +char Path::GetNameSeparator() +// ************************** +{ + return SharedPath::GetNameSeparator(); +} + +string Path::GetName() const +// ************************* +{ + return (_sharedPath) ? _sharedPath->GetName() : string(""); +} + +Cell* Path::GetOwnerCell() const +// ***************************** +{ + return (_sharedPath) ? _sharedPath->GetOwnerCell() : NULL; +} + +Cell* Path::GetMasterCell() const +// ****************************** +{ + return (_sharedPath) ? _sharedPath->GetMasterCell() : NULL; +} + +Instances Path::GetInstances() const +// ********************************* +{ + return (_sharedPath) ? _sharedPath->GetInstances() : Instances(); +} + +Transformation Path::GetTransformation(const Transformation& transformation) const +// ******************************************************************************* +{ + return (_sharedPath) ? _sharedPath->GetTransformation(transformation) : transformation; +} + +bool Path::IsEmpty() const +// *********************** +{ + return (_sharedPath == NULL); +} + +void Path::MakeEmpty() +// ******************* +{ + _sharedPath = NULL; +} + +void Path::SetNameSeparator(char nameSeparator) +// ******************************************** +{ + SharedPath::SetNameSeparator(nameSeparator); +} + +string Path::_GetString() const +// **************************** +{ + string s = "<" + _TName("Path"); + if (!_sharedPath) + s += " empty"; + else + s += " " + GetString(GetName()); + s += ">"; + return s; +} + +Record* Path::_GetRecord() const +// *********************** +{ + Record* record = NULL; + if (_sharedPath) { + record = new Record(GetString(this)); + record->Add(GetSlot("SharedPath", _sharedPath)); + } + return record; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Path.h b/hurricane/src/hurricane/Path.h new file mode 100644 index 00000000..3cfa1f03 --- /dev/null +++ b/hurricane/src/hurricane/Path.h @@ -0,0 +1,107 @@ +// **************************************************************************************************** +// File: Path.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_PATH +#define HURRICANE_PATH + +#include "Instances.h" +#include "Transformation.h" + +namespace Hurricane { + +class Cell; +class SharedPath; + + + +// **************************************************************************************************** +// Path declaration +// **************************************************************************************************** + +class Path { +// ******* + +// Attributes +// ********** + + private: SharedPath* _sharedPath; + +// Constructors +// ************ + + public: Path(SharedPath* sharedPath = NULL); + public: Path(Instance* instance); + public: Path(Instance* headInstance, const Path& tailPath); + public: Path(const Path& headPath, Instance* tailInstance); + public: Path(Cell* cell, const string& pathName); + public: Path(const Path& headPath, const Path& tailPath); + public: Path(const Path& path); + +// Destructor +// ********** + + public: ~Path(); + +// Operators +// ********* + + public: Path& operator=(const Path& path); + + public: bool operator==(const Path& path) const; + public: bool operator!=(const Path& path) const; + + public: bool operator<(const Path& path) const; // for stl set -> less predicate + +// Accessors +// ********* + + public: static char GetNameSeparator(); + + public: Instance* GetHeadInstance() const; + public: Path GetTailPath() const; + public: Path GetHeadPath() const; + public: Instance* GetTailInstance() const; + public: string GetName() const; + public: Cell* GetOwnerCell() const; + public: Cell* GetMasterCell() const; + public: Instances GetInstances() const; + public: Transformation GetTransformation(const Transformation& transformation = Transformation()) const; + +// Predicates +// ********** + + public: bool IsEmpty() const; + +// Updators +// ******** + + public: void MakeEmpty(); + public: static void SetNameSeparator(char nameSeparator); + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("Occurrence"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + public: SharedPath* _GetSharedPath() const {return _sharedPath;}; + +}; + + + +} // End of Hurricane namespace. + + +ValueIOStreamSupport(Hurricane::Path) + + +#endif // HURRICANE_PATH + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Pathes.h b/hurricane/src/hurricane/Pathes.h new file mode 100644 index 00000000..73077202 --- /dev/null +++ b/hurricane/src/hurricane/Pathes.h @@ -0,0 +1,61 @@ +// **************************************************************************************************** +// File: Pathes.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_PATHES +#define HURRICANE_PATHES + +#include "Collection.h" +#include "Path.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Pathes declaration +// **************************************************************************************************** + +typedef GenericCollection Pathes; + + + +// **************************************************************************************************** +// PathLocator declaration +// **************************************************************************************************** + +typedef GenericLocator PathLocator; + + + +// **************************************************************************************************** +// PathFilter declaration +// **************************************************************************************************** + +typedef GenericFilter PathFilter; + + + +// **************************************************************************************************** +// for_each_path declaration +// **************************************************************************************************** + +#define for_each_path(path, pathes)\ +/**********************************/\ +{\ + PathLocator _locator = pathes.GetLocator();\ + while (_locator.IsValid()) {\ + Path path = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_PATHES + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Pin.cpp b/hurricane/src/hurricane/Pin.cpp new file mode 100644 index 00000000..827dbdd3 --- /dev/null +++ b/hurricane/src/hurricane/Pin.cpp @@ -0,0 +1,245 @@ +// **************************************************************************************************** +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: Pin.cpp +// Authors: Christophe Alexandre. +// **************************************************************************************************** + +#include "Cell.h" +#include "Pin.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Pin implementation +// **************************************************************************************************** + +Pin::Pin(Net* net, const Name& name, const AccessDirection& accessDirection, const PlacementStatus& placementStatus, Layer* layer, const Unit& x, const Unit& y, const Unit& width, const Unit& height) +// **************************************************************************************************** +: Inherit(net, layer, x, y, width, height), + _name(name), + _accessDirection(accessDirection), + _placementStatus(placementStatus), + _nextOfCellPinMap(NULL) +{ + if (GetCell()->GetPin(name)) + throw Error("Can't create " + _TName("Pin") + " : already exists"); + +} + +Pin* Pin::Create(Net* net, const Name& name, const AccessDirection& accessDirection, const PlacementStatus& placementStatus, Layer* layer, const Unit& x, const Unit& y, const Unit& width, const Unit& height) +// **************************************************************************************************** +{ + if (!net) + throw Error("Can't create " + _TName("Pin") + " : NULL net"); + if (!layer) + throw Error("Can't create " + _TName("Pin") + " : NULL layer"); + + Pin* pin = new Pin(net, name, accessDirection, placementStatus, layer, x, y, width, height); + + pin->_PostCreate(); + + return pin; +} + +void Pin::SetPlacementStatus(const PlacementStatus& placementstatus) +// ********************************************************************** +{ + if (placementstatus != _placementStatus) { + Invalidate(true); + _placementStatus = placementstatus; + } +} + +void Pin::_PostCreate() +// ********************** +{ + GetCell()->_GetPinMap()._Insert(this); + + Inherit::_PostCreate(); +} + +void Pin::_PreDelete() +// ********************* +{ + Inherit::_PreDelete(); + + GetCell()->_GetPinMap()._Remove(this); +} + +string Pin::_GetString() const +// ***************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_name)); + s.insert(s.length() - 1, " " + GetString(_accessDirection)); + return s; +} + +Record* Pin::_GetRecord() const +// ************************ +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("AccessDirection", &_accessDirection)); + record->Add(GetSlot("PlacementStatus", &_placementStatus)); + } + return record; +} + +//void Pin::_Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) +//// ************************************************************************************************************* +//{ +// view->FillRectangle(transformation.GetBox(GetBoundingBox(basicLayer)), true); +//} +// +//void Pin::_Highlight(View* view, const Box& updateArea, const Transformation& transformation) +//// ****************************************************************************************** +//{ +// if (_width && _height) { +// if (1 < view->GetScreenSize(max(_width, _height))) { +// for_each_basic_layer(basicLayer, GetLayer()->GetBasicLayers()) { +// basicLayer->_Fill(view, transformation.GetBox(GetBoundingBox(basicLayer))); +// end_for; +// } +// } +// } +// if (view->GetScale() <= 1) +// view->DrawPoint(transformation.GetPoint(GetPosition()), 1); +// else if (view->GetScale() <= 3) +// { +// view->DrawPoint(transformation.GetPoint(GetPosition()), 2); +// +// if ( view->IsTextVisible() ) +// { +// string text = "(" +// + GetString ( GetValue ( GetX() ) ) + "," +// + GetString ( GetValue ( GetY() ) ) + ")"; +// view->DrawString ( text, +// transformation.GetBox ( GetBoundingBox() ).GetXMin(), +// transformation.GetBox ( GetBoundingBox() ).GetYMax() ); +// } +// } +// else { +// Point position = GetPosition(); +// view->DrawPoint(transformation.GetPoint(position), 3); +// if (_width) { +// Box box = transformation.GetBox(Box(position).Inflate(GetHalfWidth(), 0)); +// view->DrawLine(box.GetXMin(), box.GetYMin(), box.GetXMax(), box.GetYMax()); +// } +// if (_height) { +// Box box = transformation.GetBox(Box(position).Inflate(0, GetHalfHeight())); +// view->DrawLine(box.GetXMin(), box.GetYMin(), box.GetXMax(), box.GetYMax()); +// } +// +// if ( view->IsTextVisible() ) +// { +// string text = GetString ( _name ) + "(" +// + GetString ( GetValue ( GetX() ) ) + "," +// + GetString ( GetValue ( GetY() ) ) + ")"; +// view->DrawString ( text, +// transformation.GetBox ( GetBoundingBox() ).GetXMin(), +// transformation.GetBox ( GetBoundingBox() ).GetYMax() ); +// } +// } +//} +// + +// **************************************************************************************************** +// Pin::AccessDirection implementation +// **************************************************************************************************** + +Pin::AccessDirection::AccessDirection(const Code& code) +// ****************************************************** +: _code(code) +{ +} + +Pin::AccessDirection::AccessDirection(const AccessDirection& accessDirection) +// **************************************************************************** +: _code(accessDirection._code) +{ +} + +Pin::AccessDirection& Pin::AccessDirection::operator=(const AccessDirection& accessDirection) +// ********************************************************************************************** +{ + _code = accessDirection._code; + return *this; +} + +string Pin::AccessDirection::_GetString() const +// ********************************************** +{ + switch (_code) { + case UNDEFINED : return "UNDEFINED"; + case NORTH : return "NORTH"; + case SOUTH : return "SOUTH"; + case WEST : return "WEST"; + case EAST : return "EAST"; + } + return "ABNORMAL"; +} + +Record* Pin::AccessDirection::_GetRecord() const +// ***************************************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Code", (int)_code)); + return record; +} + + + +// **************************************************************************************************** +// Pin::PlacementStatus implementation +// **************************************************************************************************** + +Pin::PlacementStatus::PlacementStatus(const Code& code) +// **************************************************** +: _code(code) +{ +} + +Pin::PlacementStatus::PlacementStatus(const PlacementStatus& placementstatus) +// ************************************************************************** +: _code(placementstatus._code) +{ +} + +Pin::PlacementStatus& Pin::PlacementStatus::operator=(const PlacementStatus& placementstatus) +// ****************************************************************************************** +{ + _code = placementstatus._code; + return *this; +} + +string Pin::PlacementStatus::_GetString() const +// ******************************************** +{ + switch (_code) { + case UNPLACED : return "UNPLACED"; + case PLACED : return "PLACED"; + case FIXED : return "FIXED"; + } + return "ABNORMAL"; +} + +Record* Pin::PlacementStatus::_GetRecord() const +// *************************************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Code", (int)_code)); + return record; +} + + + +} // End of Hurricane namespace. + diff --git a/hurricane/src/hurricane/Pin.h b/hurricane/src/hurricane/Pin.h new file mode 100644 index 00000000..ecc9bfe7 --- /dev/null +++ b/hurricane/src/hurricane/Pin.h @@ -0,0 +1,137 @@ +// **************************************************************************************************** +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: Pin.h +// Author: C. Alexandre freely inspired from Remy's Contact.h +// **************************************************************************************************** + +#ifndef HURRICANE_PIN +#define HURRICANE_PIN + +#include "Contact.h" +#include "Pins.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Pin declaration +// **************************************************************************************************** + +class Pin : public Contact { +// *********************** + +// Types +// ***** + + public: typedef Contact Inherit; + + public: class AccessDirection { + // ************************** + + public: enum Code {UNDEFINED=0, NORTH=1, SOUTH=2, EAST=3, WEST=4}; + + private: Code _code; + + public: AccessDirection(const Code& code = UNDEFINED); + public: AccessDirection(const AccessDirection& accessDirection); + + public: AccessDirection& operator=(const AccessDirection& accessDirection); + + public: operator const Code&() const {return _code;}; + + public: const Code& GetCode() const {return _code;}; + + public: string _GetTypeName() const { return _TName("Pin::AccessDirection"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + }; + + public: class PlacementStatus { + // ************************** + + public: enum Code {UNPLACED=0, PLACED=1, FIXED=2}; + + private: Code _code; + + public: PlacementStatus(const Code& code = UNPLACED); + public: PlacementStatus(const PlacementStatus& placementstatus); + + public: PlacementStatus& operator=(const PlacementStatus& placementstatus); + + public: operator const Code&() const {return _code;}; + + public: const Code& GetCode() const {return _code;}; + + public: string _GetTypeName() const { return _TName("Pin::PlacementStatus"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + }; + +// Attributes +// ********** + + private: Name _name; + private: AccessDirection _accessDirection; + private: PlacementStatus _placementStatus; + private: Pin* _nextOfCellPinMap; + +// Constructors +// ************ + + protected: Pin(Net* net, const Name& name, const AccessDirection& accessDirection, const PlacementStatus& placementStatus, Layer* layer, const Unit& x, const Unit& y, const Unit& width = 0, const Unit& height = 0); + + public: static Pin* Create(Net* net, const Name& name, const AccessDirection& accessDirection, const PlacementStatus& placementStatus, Layer* layer, const Unit& x, const Unit& y, const Unit& width = 0, const Unit& height = 0); + +// Accessors +// ********* + + public: const Name& GetName() const {return _name;}; + public: const AccessDirection& GetAccessDirection() const {return _accessDirection;}; + public: const PlacementStatus& GetPlacementStatus() const {return _placementStatus;}; + +// Predicates +// ********** + + public: bool IsUnplaced() const {return _placementStatus == PlacementStatus::UNPLACED;}; + public: bool IsPlaced() const {return _placementStatus == PlacementStatus::PLACED;}; + public: bool IsFixed() const {return _placementStatus == PlacementStatus::FIXED;}; + +// Updators +// ******** + + public: void SetPlacementStatus(const PlacementStatus& placementstatus); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("Pin");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: Pin* _GetNextOfCellPinMap() const {return _nextOfCellPinMap;}; + + public: void _SetNextOfCellPinMap(Pin* pin) {_nextOfCellPinMap = pin;}; + + //public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation); + //public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Pin) + +#endif // HURRICANE_PIN diff --git a/hurricane/src/hurricane/Pins.h b/hurricane/src/hurricane/Pins.h new file mode 100644 index 00000000..a86d20de --- /dev/null +++ b/hurricane/src/hurricane/Pins.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: Pins.h +// Authors: Christophe Alexandre. +// **************************************************************************************************** + +#ifndef HURRICANE_PINS +#define HURRICANE_PINS + +#include "Collection.h" + +namespace Hurricane { + +class Pin; + + + +// **************************************************************************************************** +// Pins declaration +// **************************************************************************************************** + +typedef GenericCollection Pins; + + + +// **************************************************************************************************** +// PinLocator declaration +// **************************************************************************************************** + +typedef GenericLocator PinLocator; + + + +// **************************************************************************************************** +// PinFilter declaration +// **************************************************************************************************** + +typedef GenericFilter PinFilter; + + + +// **************************************************************************************************** +// for_each_pin declaration +// **************************************************************************************************** + +#define for_each_pin(pin, pins)\ +/******************************/\ +{\ + PinLocator _locator = pins.GetLocator();\ + while (_locator.IsValid()) {\ + Pin* pin = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_PINS diff --git a/hurricane/src/hurricane/Plug.cpp b/hurricane/src/hurricane/Plug.cpp new file mode 100644 index 00000000..ce550473 --- /dev/null +++ b/hurricane/src/hurricane/Plug.cpp @@ -0,0 +1,217 @@ +// **************************************************************************************************** +// File: Plug.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Plug.h" +#include "Net.h" +#include "Cell.h" +#include "Instance.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Filters declaration & implementation +// **************************************************************************************************** + +class Plug_IsConnectedFilter : public Filter { +// ************************************************ + + public: Plug_IsConnectedFilter() {}; + + public: Plug_IsConnectedFilter(const Plug_IsConnectedFilter& filter) {}; + + public: Plug_IsConnectedFilter& operator=(const Plug_IsConnectedFilter& filter) {return *this;}; + + public: virtual Filter* GetClone() const {return new Plug_IsConnectedFilter(*this);}; + + public: virtual bool Accept(Plug* plug) const {return plug->IsConnected();}; + + public: virtual string _GetString() const {return "<" + _TName("Plug::IsConnectedFilter>");}; + +}; + + + +// **************************************************************************************************** +// Plug implementation +// **************************************************************************************************** + +Plug::Plug(Instance* instance, Net* masterNet) +// ******************************************* +: Inherit(NULL, true), + _instance(instance), + _masterNet(masterNet), + _nextOfInstancePlugMap(NULL) +{ + if (!_instance) + throw Error("Can't create " + _TName("Plug") + " : null instance"); + + if (!_masterNet) + throw Error("Can't create " + _TName("Plug") + " : null master net"); + + if (_masterNet->GetCell() != _instance->GetMasterCell()) + throw Error("Can't create " + _TName("Plug") + " : incompatible master net"); + + if (!_masterNet->IsExternal()) + throw Error("Can't create " + _TName("Plug") + " : not an external master net"); + + if (_instance->GetPlug(_masterNet)) + throw Error("Can't create " + _TName("Plug") + " : already exists"); +} + +void Plug::Delete() +// **************** +{ + throw Error("Abnormal deletion of " + _TName("Plug")); +} + +Cell* Plug::GetCell() const +// ************************ +{ + return _instance->GetCell(); +} + +Unit Plug::GetX() const +// ******************** +{ + return _instance->GetTransformation().GetX(_masterNet->GetPosition()); +} + +Unit Plug::GetY() const +// ******************** +{ + return _instance->GetTransformation().GetY(_masterNet->GetPosition()); +} + +Point Plug::GetPosition() const +// **************************** +{ + return _instance->GetTransformation().GetPoint(_masterNet->GetPosition()); +} + +Box Plug::GetBoundingBox() const +// ***************************** +{ + return _instance->GetTransformation().GetBox(_masterNet->GetPosition()); +} + +Box Plug::GetBoundingBox(BasicLayer* basicLayer) const +// *************************************************** +{ + return Box(); +} + +PlugFilter Plug::GetIsConnectedFilter() +// ************************************ +{ + return Plug_IsConnectedFilter(); +} + +PlugFilter Plug::GetIsUnconnectedFilter() +// ************************************** +{ + return !Plug_IsConnectedFilter(); +} + +void Plug::Materialize() +// ********************* +{ +} + +void Plug::Unmaterialize() +// *********************** +{ +} + +void Plug::SetNet(Net* net) +// ************************ +{ + if (net != GetNet()) { + + if (net && (GetCell() != net->GetCell())) + throw Error("Can't change net of plug : net : " + GetString(net) + "does not belong to the cell : " + GetString(GetCell())); + + if (!GetBodyHook()->GetSlaveHooks().IsEmpty()) + throw Error("Can't change net of plug : not empty slave hooks"); + + _SetNet(net); + } +} + +Plug* Plug::_Create(Instance* instance, Net* masterNet) +// **************************************************** +{ + Plug* plug = new Plug(instance, masterNet); + + plug->_PostCreate(); + + return plug; +} + +void Plug::_PostCreate() +// ********************* +{ + _instance->_GetPlugMap()._Insert(this); + + Inherit::_PostCreate(); +} + +void Plug::_Delete() +// ***************** +{ + _PreDelete(); + + delete this; +} + +void Plug::_PreDelete() +// ******************** +{ +// trace << "entering Plug::_PreDelete: " << this << endl; +// trace_in(); + + Inherit::_PreDelete(); + + _instance->_GetPlugMap()._Remove(this); + +// trace << "exiting Plug::_PreDelete:" << endl; +// trace_out(); +} + +string Plug::_GetString() const +// **************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetName()); + return s; +} + +Record* Plug::_GetRecord() const +// *********************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Instance", _instance)); + record->Add(GetSlot("MasterNet", _masterNet)); + } + return record; +} + +string Plug::GetName() const +// ************************* +{ + return GetString(_instance->GetName()) + + "." + + GetString(_masterNet->GetName()); +} + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Plug.h b/hurricane/src/hurricane/Plug.h new file mode 100644 index 00000000..9e7c87f6 --- /dev/null +++ b/hurricane/src/hurricane/Plug.h @@ -0,0 +1,116 @@ +// **************************************************************************************************** +// File: Plug.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_PLUG +#define HURRICANE_PLUG + +#include "Component.h" +#include "Plugs.h" + +namespace Hurricane { + +class Net; +class Instance; + + + +// **************************************************************************************************** +// Plug declaration +// **************************************************************************************************** + +class Plug : public Component { +// ************************** + +// Types +// ***** + + public: typedef Component Inherit; + +// Attributes +// ********** + + private: Instance* _instance; + private: Net* _masterNet; + private: Plug* _nextOfInstancePlugMap; + +// Constructors +// ************ + + protected: Plug(Instance* instance, Net* masterNet); + +// Destructor +// ********** + + public: virtual void Delete(); + +// Accessors +// ********* + + public: virtual Cell* GetCell() const; + public: virtual Unit GetX() const; + public: virtual Unit GetY() const; + public: virtual Point GetPosition() const; + public: virtual Box GetBoundingBox() const; + public: virtual Layer* GetLayer() const {return NULL;}; + public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const; + public: Instance* GetInstance() const {return _instance;}; + public: Net* GetMasterNet() const {return _masterNet;}; + +// Filters +// ******* + + public: static PlugFilter GetIsConnectedFilter(); + public: static PlugFilter GetIsUnconnectedFilter(); + +// Predicates +// ********** + + public: bool IsConnected() const {return (GetNet() != NULL);}; + +// Updators +// ******** + + public: virtual void Translate(const Unit& dx, const Unit& dy) {}; + + public: void SetNet(Net* net); + + public: virtual void Materialize(); + public: virtual void Unmaterialize(); + +// Others +// ****** + + public: static Plug* _Create(Instance* instance, Net* masterNet); + protected: virtual void _PostCreate(); + + public: void _Delete(); + protected: virtual void _PreDelete(); + + public: virtual string GetName() const; + public: virtual string _GetTypeName() const {return _TName("Plug");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: Plug* _GetNextOfInstancePlugMap() const {return _nextOfInstancePlugMap;}; + + public: virtual void _SetMasterNet(Net* masterNet) {_masterNet = masterNet;}; + public: void _SetNextOfInstancePlugMap(Plug* plug) {_nextOfInstancePlugMap = plug;}; + + //public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) {}; + //public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation) {}; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Plug) + +#endif // HURRICANE_PLUG + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Plugs.h b/hurricane/src/hurricane/Plugs.h new file mode 100644 index 00000000..872b29a2 --- /dev/null +++ b/hurricane/src/hurricane/Plugs.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Plugs.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_PLUGS +#define HURRICANE_PLUGS + +#include "Collection.h" + +namespace Hurricane { + +class Plug; + + + +// **************************************************************************************************** +// Plugs declaration +// **************************************************************************************************** + +typedef GenericCollection Plugs; + + + +// **************************************************************************************************** +// PlugLocator declaration +// **************************************************************************************************** + +typedef GenericLocator PlugLocator; + + + +// **************************************************************************************************** +// PlugFilter declaration +// **************************************************************************************************** + +typedef GenericFilter PlugFilter; + + + +// **************************************************************************************************** +// for_each_plug declaration +// **************************************************************************************************** + +#define for_each_plug(plug, plugs)\ +/*********************************/\ +{\ + PlugLocator _locator = plugs.GetLocator();\ + while (_locator.IsValid()) {\ + Plug* plug = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_PLUGS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Point.cpp b/hurricane/src/hurricane/Point.cpp new file mode 100644 index 00000000..c78532ca --- /dev/null +++ b/hurricane/src/hurricane/Point.cpp @@ -0,0 +1,116 @@ +// **************************************************************************************************** +// File: Point.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment BULL-LIP6 : added operators+ += ... (questionnable!) + +#include "Point.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Point implementation +// **************************************************************************************************** + +Point::Point() +// *********** +: _x(0), + _y(0) +{ +} + +Point::Point(const Unit& x, const Unit& y) +// *************************************** +: _x(x), + _y(y) +{ +} + +Point::Point(const Point& point) +// ***************************** +: _x(point._x), + _y(point._y) +{ +} + +Point& Point::operator=(const Point& point) +// **************************************** +{ + _x = point._x; + _y = point._y; + return *this; +} + +bool Point::operator==(const Point& point) const +// ********************************************* +{ + return ((_x == point._x) && (_y == point._y)); +} + +bool Point::operator!=(const Point& point) const +// ********************************************* +{ + return ((_x != point._x) || (_y != point._y)); +} + +Point Point::operator+(const Point& point) const +// ********************************************* +{ + return Point(_x+point._x,_y+point._y); +} + +Point Point::operator-(const Point& point) const +// ********************************************* +{ + return Point(_x-point._x,_y-point._y); +} + +Point& Point::operator+=(const Point &point) +// ***************************************** +{ + _x += point._x; + _y += point._y; + return *this; +} + +Point& Point::operator-=(const Point &point) +// ***************************************** +{ + _x -= point._x; + _y -= point._y; + return *this; +} + +Point& Point::Translate(const Unit& dx, const Unit& dy) +// **************************************************** +{ + _x += dx; + _y += dy; + return *this; +} + +string Point::_GetString() const +// ***************************** +{ + return "<" + _TName("Point") + " " + GetValueString(_x) + " " + GetValueString(_y) + ">"; +} + +Record* Point::_GetRecord() const +// ****************************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("X", &_x)); + record->Add(GetSlot("Y", &_y)); + return record; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Point.h b/hurricane/src/hurricane/Point.h new file mode 100644 index 00000000..d0460b1e --- /dev/null +++ b/hurricane/src/hurricane/Point.h @@ -0,0 +1,89 @@ +// **************************************************************************************************** +// File: Point.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment BULL-LIP6 : added operators+ += ... (questionnable!) + +#ifndef HURRICANE_POINT +#define HURRICANE_POINT + +#include "Unit.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Point declaration +// **************************************************************************************************** + +class Point { +// ******** + +// Attributes +// ********** + + private: Unit _x; + private: Unit _y; + +// Constructors +// ************ + + public: Point(); + + public: Point(const Unit& x, const Unit& y); + + public: Point(const Point& point); + +// Operators +// ********* + + public: Point& operator=(const Point& point); + + public: bool operator==(const Point& point) const; + public: bool operator!=(const Point& point) const; + + public: Point operator+(const Point& point) const; + public: Point operator-(const Point& point) const; + public: Point& operator+=(const Point& point); + public: Point& operator-=(const Point& point); + +// Accessors +// ********* + + public: const Unit& GetX() const {return _x;}; + public: const Unit& GetY() const {return _y;}; + + public: Unit ManhattanDistance(const Point pt) const + {return abs(_x - pt.GetX()) + abs(_y - pt.GetY());}; + +// Updators +// ******** + + public: void SetX(const Unit& x) {_x = x;}; + public: void SetY(const Unit& y) {_y = y;}; + public: Point& Translate(const Unit& dx, const Unit& dy); + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("Point"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + +}; + + + +} // End of Hurricane namespace. + + +ValueIOStreamSupport(Hurricane::Point) + + +#endif // HURRICANE_POINT + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Points.h b/hurricane/src/hurricane/Points.h new file mode 100644 index 00000000..e525660a --- /dev/null +++ b/hurricane/src/hurricane/Points.h @@ -0,0 +1,61 @@ +// **************************************************************************************************** +// File: Points.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_POINTS +#define HURRICANE_POINTS + +#include "Collection.h" +#include "Point.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Points declaration +// **************************************************************************************************** + +typedef GenericCollection Points; + + + +// **************************************************************************************************** +// PointLocator declaration +// **************************************************************************************************** + +typedef GenericLocator PointLocator; + + + +// **************************************************************************************************** +// PointFilter declaration +// **************************************************************************************************** + +typedef GenericFilter PointFilter; + + + +// **************************************************************************************************** +// for_each_point declaration +// **************************************************************************************************** + +#define for_each_point(point, points)\ +/************************************/\ +{\ + PointLocator _locator = points.GetLocator();\ + while (_locator.IsValid()) {\ + Point point = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_POINTS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Primitives.h b/hurricane/src/hurricane/Primitives.h new file mode 100644 index 00000000..143af152 --- /dev/null +++ b/hurricane/src/hurricane/Primitives.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Primitives.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_PRIMITIVES +#define HURRICANE_PRIMITIVES + +#include "Collection.h" + +namespace Hurricane { + +class Primitive; + + + +// **************************************************************************************************** +// Primitives declaration +// **************************************************************************************************** + +typedef GenericCollection Primitives; + + + +// **************************************************************************************************** +// PrimitiveLocator declaration +// **************************************************************************************************** + +typedef GenericLocator PrimitiveLocator; + + + +// **************************************************************************************************** +// PrimitiveFilter declaration +// **************************************************************************************************** + +typedef GenericFilter PrimitiveFilter; + + + +// **************************************************************************************************** +// for_each_primitive declaration +// **************************************************************************************************** + +#define for_each_primitive(primitive, primitives)\ +/************************************************/\ +{\ + PrimitiveLocator _locator = primitives.GetLocator();\ + while (_locator.IsValid()) {\ + Primitive* primitive = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_PRIMITIVES + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Properties.h b/hurricane/src/hurricane/Properties.h new file mode 100644 index 00000000..cfa0deb1 --- /dev/null +++ b/hurricane/src/hurricane/Properties.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Properties.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_PROPERTIES +#define HURRICANE_PROPERTIES + +#include "Collection.h" + +namespace Hurricane { + +class Property; + + + +// **************************************************************************************************** +// Properties declaration +// **************************************************************************************************** + +typedef GenericCollection Properties; + + + +// **************************************************************************************************** +// PropertyLocator declaration +// **************************************************************************************************** + +typedef GenericLocator PropertyLocator; + + + +// **************************************************************************************************** +// PropertyFilter declaration +// **************************************************************************************************** + +typedef GenericFilter PropertyFilter; + + + +// **************************************************************************************************** +// for_each_property declaration +// **************************************************************************************************** + +#define for_each_property(property, properties)\ +/**********************************************/\ +{\ + PropertyLocator _locator = properties.GetLocator();\ + while (_locator.IsValid()) {\ + Property* property = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_PROPERTIES + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Property.cpp b/hurricane/src/hurricane/Property.cpp new file mode 100644 index 00000000..60b0ea55 --- /dev/null +++ b/hurricane/src/hurricane/Property.cpp @@ -0,0 +1,183 @@ +// **************************************************************************************************** +// File: Property.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Property.h" +#include "DBo.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Property implementation +// **************************************************************************************************** + +Property::Property() +// ***************** +{ +} + +Property::~Property() +// ****************** +{ +} + +void Property::Delete() +// ******************** +{ + _PreDelete(); + + delete this; +} + +void Property::_PostCreate() +// ************************* +{ +} + +void Property::_PreDelete() +// ************************ +{ +} + +string Property::_GetString() const +// ******************************** +{ + string s = "<" + _GetTypeName() + ">"; + s.insert(s.length() - 1, " " + GetString(GetName())); + return s; +} + +Record* Property::_GetRecord() const +// *************************** +{ + return new Record(GetString(this)); +} + + + +// **************************************************************************************************** +// PrivateProperty implementation +// **************************************************************************************************** + +PrivateProperty::PrivateProperty() +// ******************************* +: Inherit(), + _owner(NULL) +{ +} + +void PrivateProperty::_PreDelete() +// ******************************* +{ + Inherit::_PreDelete(); + + if (_owner) _owner->_OnDeleted(this); +} + +void PrivateProperty::OnCapturedBy(DBo* owner) +// ******************************************* +{ + _owner = owner; +} + +void PrivateProperty::OnReleasedBy(DBo* owner) +// ******************************************* +{ + if (_owner == owner) OnNotOwned(); +} + +void PrivateProperty::OnNotOwned() +// ******************************* +{ + Delete(); +} + +string PrivateProperty::_GetString() const +// *************************************** +{ + return Inherit::_GetString(); +} + +Record* PrivateProperty::_GetRecord() const +// ********************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Owner", _owner)); + } + return record; +} + + + +// **************************************************************************************************** +// SharedProperty implementation +// **************************************************************************************************** + +SharedProperty::SharedProperty() +// ***************************** +: Inherit(), + _ownerSet() +{ +} + +void SharedProperty::_PreDelete() +// ****************************** +{ + Inherit::_PreDelete(); + + while (!_ownerSet.empty()) { + DBo* owner = *_ownerSet.begin(); + _ownerSet.erase(owner); + owner->_OnDeleted(this); + } +} + +void SharedProperty::OnCapturedBy(DBo* owner) +// ****************************************** +{ + _ownerSet.insert(owner); +} + +void SharedProperty::OnReleasedBy(DBo* owner) +// ****************************************** +{ + _ownerSet.erase(owner); + + if (_ownerSet.empty()) OnNotOwned(); +} + +void SharedProperty::OnNotOwned() +// ****************************** +{ + Delete(); +} + +string SharedProperty::_GetString() const +// ************************************** +{ + return Inherit::_GetString(); +} + +Record* SharedProperty::_GetRecord() const +// ********************************* +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Owners", &_ownerSet)); + } + return record; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Property.h b/hurricane/src/hurricane/Property.h new file mode 100644 index 00000000..ebe6f8c5 --- /dev/null +++ b/hurricane/src/hurricane/Property.h @@ -0,0 +1,375 @@ +// **************************************************************************************************** +// File: Property.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_PROPERTY +#define HURRICANE_PROPERTY + +#include "Name.h" +#include "Properties.h" +#include "DBos.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Property declaration +// **************************************************************************************************** + +class Property : public NestedSlotAdapter { +// ************************************** + +// Constructors +// ************ + + protected: Property(); + + private: Property(const Property& property); // not implemented to forbid copy construction + +// Destructors +// *********** + + protected: virtual ~Property(); + + public: virtual void Delete(); + +// Operators +// ********* + + private: Property& operator=(const Property& property); // not implemented to forbid assignment + +// Accessors +// ********* + + public: virtual Name GetName() const = 0; + +// Managers +// ******** + + public: virtual void OnCapturedBy(DBo* owner) = 0; + public: virtual void OnReleasedBy(DBo* owner) = 0; + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const = 0; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + +}; + + + +// **************************************************************************************************** +// PrivateProperty declaration +// **************************************************************************************************** + +class PrivateProperty : public Property { +// ************************************ + +// Types +// ***** + + public: typedef Property Inherit; + +// Attributes +// ********** + + private: DBo* _owner; + +// Constructors +// ************ + + protected: PrivateProperty(); + +// Accessors +// ********* + + public: DBo* GetOwner() const {return _owner;}; + +// Managers +// ******** + + public: virtual void OnCapturedBy(DBo* owner); + public: virtual void OnReleasedBy(DBo* owner); + public: virtual void OnNotOwned(); + +// Others +// ****** + + protected: virtual void _PreDelete(); + + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + +}; + + + +// **************************************************************************************************** +// StandardPrivateProperty declaration +// **************************************************************************************************** + +template class StandardPrivateProperty : public PrivateProperty { +// ************************************************************************* + +// Types +// ***** + + public: typedef PrivateProperty Inherit; + +// Attributes +// ********** + + private: Name _name; + private: Value _value; + +// Constructors +// ************ + + protected: StandardPrivateProperty(const Name& name, const Value& value) + // ********************************************************************* + : Inherit(), + _name(name), + _value(value) + { + }; + + public: static StandardPrivateProperty* Create(const Name& name, const Value& value ) + // ********************************************************************************** + { + StandardPrivateProperty* property = new StandardPrivateProperty(name, value); + + property->_PostCreate(); + + return property; + }; + +// Accessors +// ********* + + public: virtual Name GetName() const + // ********************************* + { + return _name; + }; + + public: const Value& GetValue() const + // ********************************** + { + return _value; + }; + +// Modifieurs +// ********** + + public: void SetValue(const Value& value) + // ************************************** + { + _value = value; + }; + +// Others +// ****** + + public: virtual string _GetTypeName() const + // **************************************** + { + return _TName("StandardPrivateProperty"); + }; + + public: virtual string _GetString() const + // ************************************** + { + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_value)); + return s; + }; + + public: virtual Record* _GetRecord() const + // ********************************* + { + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("Value", _value)); + } + return record; + }; + +}; + + + +// **************************************************************************************************** +// SharedProperty declaration +// **************************************************************************************************** + +class SharedProperty : public Property { +// *********************************** + +// Types +// ***** + + public: typedef Property Inherit; + public: typedef set DBoSet; + +// Attributes +// ********** + + private: DBoSet _ownerSet; + +// Constructors +// ************ + + protected: SharedProperty(); + +// Accessors +// ********* + + public: DBos GetOwners() const {return GetCollection(_ownerSet);}; + +// Managers +// ******** + + public: virtual void OnCapturedBy(DBo* owner); + public: virtual void OnReleasedBy(DBo* owner); + public: virtual void OnNotOwned(); + +// Accessors +// ********* + + protected: virtual void _PreDelete(); + + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: DBoSet& _GetOwnerSet() {return _ownerSet;}; + +}; + + + +// **************************************************************************************************** +// StandardSharedProperty declaration +// **************************************************************************************************** + +template class StandardSharedProperty : public SharedProperty { +// *********************************************************************** + +// Types +// ***** + + public: typedef SharedProperty Inherit; + +// Attributes +// ********** + + private: Name _name; + private: Value _value; + +// Constructors +// ************ + + protected: StandardSharedProperty(const Name& name, const Value& value) + // ******************************************************************** + : Inherit(), + _name(name), + _value(value) + { + }; + + public: static StandardSharedProperty* Create(const Name& name, const Value& value ) + // ********************************************************************************* + { + StandardSharedProperty* property = new StandardSharedProperty(name, value); + + property->_PostCreate(); + + return property; + }; + +// Accessors +// ********* + + public: virtual Name GetName() const + // ********************************* + { + return _name; + }; + + public: const Value& GetValue() const + // ********************************** + { + return _value; + }; + +// Modifieurs +// ********** + + public: void SetValue(const Value& value) + // ************************************** + { + _value = value; + }; + +// Others +// ****** + + public: virtual string _GetTypeName() const + // **************************************** + { + return _TName("StandardSharedProperty"); + }; + + public: virtual string _GetString() const + // ************************************** + { + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_value)); + return s; + }; + + public: virtual Record* _GetRecord() const + // ********************************* + { + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("Value", &_value)); + } + return record; + }; + +}; + + +template + class IsNestedSlotAdapter > { + public: + enum { True=1, False=0 }; + }; + + +template + class IsNestedSlotAdapter > { + public: + enum { True=1, False=0 }; + }; + + +} // End of Hurricane namespace. + +#endif // HURRICANE_PROPERTY + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/QuadTree.cpp b/hurricane/src/hurricane/QuadTree.cpp new file mode 100644 index 00000000..05d72588 --- /dev/null +++ b/hurricane/src/hurricane/QuadTree.cpp @@ -0,0 +1,824 @@ +// **************************************************************************************************** +// File: QuadTree.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "QuadTree.h" +#include "Go.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Definitions +// **************************************************************************************************** + +#define QUAD_TREE_IMPLODE_THRESHOLD 80 +#define QUAD_TREE_EXPLODE_THRESHOLD 100 + + + +// **************************************************************************************************** +// QuadTree_Gos declaration +// **************************************************************************************************** + +class QuadTree_Gos : public Collection { +// **************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // *************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const QuadTree* _quadTree; + private: QuadTree* _currentQuadTree; + private: GoLocator _goLocator; + + public: Locator(const QuadTree* quadTree = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Go* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const QuadTree* _quadTree; + +// Constructors +// ************ + + public: QuadTree_Gos(const QuadTree* quadTree = NULL); + public: QuadTree_Gos(const QuadTree_Gos& gos); + +// Operators +// ********* + + public: QuadTree_Gos& operator=(const QuadTree_Gos& gos); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// QuadTree_GosUnder declaration +// **************************************************************************************************** + +class QuadTree_GosUnder : public Collection { +// ********************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // *************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const QuadTree* _quadTree; + private: Box _area; + private: QuadTree* _currentQuadTree; + private: GoLocator _goLocator; + + public: Locator(); + public: Locator(const QuadTree* quadTree, const Box& area); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Go* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const QuadTree* _quadTree; + private: Box _area; + +// Constructors +// ************ + + public: QuadTree_GosUnder(); + public: QuadTree_GosUnder(const QuadTree* quadTree, const Box& area); + public: QuadTree_GosUnder(const QuadTree_GosUnder& gos); + +// Operators +// ********* + + public: QuadTree_GosUnder& operator=(const QuadTree_GosUnder& gos); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// QuadTree declaration +// **************************************************************************************************** + +QuadTree::QuadTree() +// ***************** +: _parent(NULL), + _x(0), + _y(0), + _boundingBox(), + _size(0), + _goSet(), + _ulChild(NULL), + _urChild(NULL), + _llChild(NULL), + _lrChild(NULL) +{ +} + +QuadTree::QuadTree(QuadTree* parent) +// ********************************* +: _parent(parent), + _x(0), + _y(0), + _boundingBox(), + _size(0), + _goSet(), + _ulChild(NULL), + _urChild(NULL), + _llChild(NULL), + _lrChild(NULL) +{ +} + +QuadTree::~QuadTree() +// ****************** +{ + if (_ulChild) delete _ulChild; + if (_urChild) delete _urChild; + if (_llChild) delete _llChild; + if (_lrChild) delete _lrChild; +} + +const Box& QuadTree::GetBoundingBox() const +// **************************************** +{ + if (_boundingBox.IsEmpty()) { + Box& boundingBox = ((QuadTree*)this)->_boundingBox; + if (_ulChild) boundingBox.Merge(_ulChild->GetBoundingBox()); + if (_urChild) boundingBox.Merge(_urChild->GetBoundingBox()); + if (_llChild) boundingBox.Merge(_llChild->GetBoundingBox()); + if (_lrChild) boundingBox.Merge(_lrChild->GetBoundingBox()); + for_each_go(go, _goSet.GetElements()) { + boundingBox.Merge(go->GetBoundingBox()); + end_for; + } + } + return _boundingBox; +} + +Gos QuadTree::GetGos() const +// ************************* +{ + return QuadTree_Gos(this); +} + +Gos QuadTree::GetGosUnder(const Box& area) const +// ********************************************* +{ + return QuadTree_GosUnder(this, area); +} + +void QuadTree::Insert(Go* go) +// ************************** +{ + if (!go) + throw Error("Can't insert go : null go"); + + if (!go->IsMaterialized()) { + Box boundingBox = go->GetBoundingBox(); + QuadTree* child = _GetDeepestChild(boundingBox); + child->_goSet._Insert(go); + go->_quadTree = child; + QuadTree* parent = child; + while (parent) { + parent->_size++; + if (parent->IsEmpty() || !parent->_boundingBox.IsEmpty()) + parent->_boundingBox.Merge(boundingBox); + parent = parent->_parent; + } + if (QUAD_TREE_EXPLODE_THRESHOLD <= child->_size) + child->_Explode(); + } +} + +void QuadTree::Remove(Go* go) +// ************************** +{ + if (!go) + throw Error("Can't remove go : null go"); + + if (go->IsMaterialized()) { + Box boundingBox = go->GetBoundingBox(); + QuadTree* child = go->_quadTree; + child->_goSet._Remove(go); + go->_quadTree = NULL; + QuadTree* parent = child; + while (parent) { + parent->_size--; + if (parent->_boundingBox.IsConstrainedBy(boundingBox)) + parent->_boundingBox = Box(); + parent = parent->_parent; + } + parent = child; + while (parent) { + if (!(parent->_size <= QUAD_TREE_IMPLODE_THRESHOLD)) + break; + parent->_Implode(); + parent = parent->_parent; + } + } +} + +string QuadTree::_GetString() const +// ******************************** +{ + string s = "<" + _TName("QuadTree"); + if (!_size) + s += " empty"; + else + s += " " + GetString(_size); + s += ">"; + return s; +} + +Record* QuadTree::_GetRecord() const +// *************************** +{ + Record* record = NULL; + if (_size) { + record = new Record(GetString(this)); + record->Add(GetSlot("Parent", _parent)); + record->Add(GetSlot("X", &_x)); + record->Add(GetSlot("Y", &_y)); + record->Add(GetSlot("BoundingBox", &_boundingBox)); + record->Add(GetSlot("Size", &_size)); + record->Add(GetSlot("Gos", &_goSet)); + record->Add(GetSlot("ULChild", _ulChild)); + record->Add(GetSlot("URChild", _urChild)); + record->Add(GetSlot("LLChild", _llChild)); + record->Add(GetSlot("LRChild", _lrChild)); + } + return record; +} + +QuadTree* QuadTree::_GetDeepestChild(const Box& box) +// ************************************************ +{ + if (_HasBeenExploded()) { + if (box.GetXMax() < _x) { + if (box.GetYMax() < _y) + return _llChild->_GetDeepestChild(box); + if (_y < box.GetYMin()) + return _ulChild->_GetDeepestChild(box); + } + if (_x < box.GetXMin()) { + if (box.GetYMax() < _y) + return _lrChild->_GetDeepestChild(box); + if (_y < box.GetYMin()) + return _urChild->_GetDeepestChild(box); + } + } + return this; +} + +QuadTree* QuadTree::_GetFirstQuadTree() const +// ****************************************** +{ + if (!_goSet.IsEmpty()) return (QuadTree*)this; + QuadTree* quadTree = NULL; + if (_HasBeenExploded()) { + if (!quadTree) quadTree = _ulChild->_GetFirstQuadTree(); + if (!quadTree) quadTree = _urChild->_GetFirstQuadTree(); + if (!quadTree) quadTree = _llChild->_GetFirstQuadTree(); + if (!quadTree) quadTree = _lrChild->_GetFirstQuadTree(); + } + return quadTree; +} + +QuadTree* QuadTree::_GetFirstQuadTree(const Box& area) const +// ********************************************************* +{ + if (GetBoundingBox().Intersect(area)) { + if (!_goSet.IsEmpty()) return (QuadTree*)this; + QuadTree* quadTree = NULL; + if (_HasBeenExploded()) { + if (!quadTree) quadTree = _ulChild->_GetFirstQuadTree(area); + if (!quadTree) quadTree = _urChild->_GetFirstQuadTree(area); + if (!quadTree) quadTree = _llChild->_GetFirstQuadTree(area); + if (!quadTree) quadTree = _lrChild->_GetFirstQuadTree(area); + } + return quadTree; + } + return NULL; +} + +QuadTree* QuadTree::_GetNextQuadTree() +// *********************************** +{ + QuadTree* nextQuadTree = NULL; + if (_HasBeenExploded()) { + if (!nextQuadTree) nextQuadTree = _ulChild->_GetFirstQuadTree(); + if (!nextQuadTree) nextQuadTree = _urChild->_GetFirstQuadTree(); + if (!nextQuadTree) nextQuadTree = _llChild->_GetFirstQuadTree(); + if (!nextQuadTree) nextQuadTree = _lrChild->_GetFirstQuadTree(); + } + QuadTree* quadTree = this; + while (!nextQuadTree && quadTree->_parent) { + if (quadTree->_parent->_llChild == quadTree) + nextQuadTree = quadTree->_parent->_lrChild->_GetFirstQuadTree(); + else if (quadTree->_parent->_urChild == quadTree) { + nextQuadTree = quadTree->_parent->_llChild->_GetFirstQuadTree(); + if (!nextQuadTree) + nextQuadTree = quadTree->_parent->_lrChild->_GetFirstQuadTree(); + } + else if (quadTree->_parent->_ulChild == quadTree) { + nextQuadTree = quadTree->_parent->_urChild->_GetFirstQuadTree(); + if (!nextQuadTree) + nextQuadTree = quadTree->_parent->_llChild->_GetFirstQuadTree(); + if (!nextQuadTree) + nextQuadTree = quadTree->_parent->_lrChild->_GetFirstQuadTree(); + } + quadTree = quadTree->_parent; + } + return nextQuadTree; +} + +QuadTree* QuadTree::_GetNextQuadTree(const Box& area) +// ************************************************** +{ + QuadTree* nextQuadTree = NULL; + if (_HasBeenExploded()) { + if (!nextQuadTree) nextQuadTree = _ulChild->_GetFirstQuadTree(area); + if (!nextQuadTree) nextQuadTree = _urChild->_GetFirstQuadTree(area); + if (!nextQuadTree) nextQuadTree = _llChild->_GetFirstQuadTree(area); + if (!nextQuadTree) nextQuadTree = _lrChild->_GetFirstQuadTree(area); + } + QuadTree* quadTree = this; + while (!nextQuadTree && quadTree->_parent) { + if (quadTree->_parent->_llChild == quadTree) + nextQuadTree = quadTree->_parent->_lrChild->_GetFirstQuadTree(area); + else if (quadTree->_parent->_urChild == quadTree) { + nextQuadTree = quadTree->_parent->_llChild->_GetFirstQuadTree(area); + if (!nextQuadTree) + nextQuadTree = quadTree->_parent->_lrChild->_GetFirstQuadTree(area); + } + else if (quadTree->_parent->_ulChild == quadTree) { + nextQuadTree = quadTree->_parent->_urChild->_GetFirstQuadTree(area); + if (!nextQuadTree) + nextQuadTree = quadTree->_parent->_llChild->_GetFirstQuadTree(area); + if (!nextQuadTree) + nextQuadTree = quadTree->_parent->_lrChild->_GetFirstQuadTree(area); + } + quadTree = quadTree->_parent; + } + return nextQuadTree; +} + +void QuadTree::_Explode() +// ********************** +{ + if (!_HasBeenExploded()) { + _x = GetBoundingBox().GetXCenter(); + _y = GetBoundingBox().GetYCenter(); + _ulChild = new QuadTree(this); + _urChild = new QuadTree(this); + _llChild = new QuadTree(this); + _lrChild = new QuadTree(this); + set goSet; + for_each_go(go, _goSet.GetElements()) { + _goSet._Remove(go); + go->_quadTree = NULL; + goSet.insert(go); + end_for; + } + for_each_go(go, GetCollection(goSet)) { + QuadTree* child = _GetDeepestChild(go->GetBoundingBox()); + child->_goSet._Insert(go); + go->_quadTree = child; + if (child != this) child->_size++; + end_for; + } + } +} + +void QuadTree::_Implode() +// ********************** +{ + if (_HasBeenExploded()) { + if (_ulChild->_HasBeenExploded()) _ulChild->_Implode(); + for_each_go(go, _ulChild->_goSet.GetElements()) { + _ulChild->_goSet._Remove(go); + _goSet._Insert(go); + go->_quadTree = this; + end_for; + } + delete _ulChild; + _ulChild = NULL; + if (_urChild->_HasBeenExploded()) _urChild->_Implode(); + for_each_go(go, _urChild->_goSet.GetElements()) { + _urChild->_goSet._Remove(go); + _goSet._Insert(go); + go->_quadTree = this; + end_for; + } + delete _urChild; + _urChild = NULL; + if (_llChild->_HasBeenExploded()) _llChild->_Implode(); + for_each_go(go, _llChild->_goSet.GetElements()) { + _llChild->_goSet._Remove(go); + _goSet._Insert(go); + go->_quadTree = this; + end_for; + } + delete _llChild; + _llChild = NULL; + if (_lrChild->_HasBeenExploded()) _lrChild->_Implode(); + for_each_go(go, _lrChild->_goSet.GetElements()) { + _lrChild->_goSet._Remove(go); + _goSet._Insert(go); + go->_quadTree = this; + end_for; + } + delete _lrChild; + _lrChild = NULL; + } +} + + + +// **************************************************************************************************** +// QuadTree::GoSet implementation +// **************************************************************************************************** + +QuadTree::GoSet::GoSet() +// ********************* +: Inherit() +{ +} + +unsigned QuadTree::GoSet::_GetHashValue(Go* go) const +// ************************************************** +{ + return ( (unsigned int)( (unsigned long)go ) ) / 8; +} + +Go* QuadTree::GoSet::_GetNextElement(Go* go) const +// *********************************************** +{ + return go->_GetNextOfQuadTreeGoSet(); +} + +void QuadTree::GoSet::_SetNextElement(Go* go, Go* nextGo) const +// ************************************************************ +{ + go->_SetNextOfQuadTreeGoSet(nextGo); +} + + + +// **************************************************************************************************** +// QuadTree_Gos implementation +// **************************************************************************************************** + +QuadTree_Gos::QuadTree_Gos(const QuadTree* quadTree) +// ************************************************* +: Inherit(), + _quadTree(quadTree) +{ +} + +QuadTree_Gos::QuadTree_Gos(const QuadTree_Gos& gos) +// ************************************************ +: Inherit(), + _quadTree(gos._quadTree) +{ +} + +QuadTree_Gos& QuadTree_Gos::operator=(const QuadTree_Gos& gos) +// *********************************************************** +{ + _quadTree = gos._quadTree; + return *this; +} + +Collection* QuadTree_Gos::GetClone() const +// ******************************************** +{ + return new QuadTree_Gos(*this); +} + +Locator* QuadTree_Gos::GetLocator() const +// ******************************************* +{ + return new Locator(_quadTree); +} + +string QuadTree_Gos::_GetString() const +// ************************************ +{ + string s = "<" + _TName("QuadTree::Gos"); + if (_quadTree) s += " " + GetString(_quadTree); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// QuadTree_Gos::Locator implementation +// **************************************************************************************************** + +QuadTree_Gos::Locator::Locator(const QuadTree* quadTree) +// ***************************************************** +: Inherit(), + _quadTree(quadTree), + _currentQuadTree(NULL), + _goLocator() +{ + if (_quadTree) { + _currentQuadTree = _quadTree->_GetFirstQuadTree(); + if (_currentQuadTree) + _goLocator = _currentQuadTree->_GetGoSet().GetElements().GetLocator(); + } +} + +QuadTree_Gos::Locator::Locator(const Locator& locator) +// *************************************************** +: Inherit(), + _quadTree(locator._quadTree), + _currentQuadTree(locator._currentQuadTree), + _goLocator(locator._goLocator) +{ +} + +QuadTree_Gos::Locator& QuadTree_Gos::Locator::operator=(const Locator& locator) +// **************************************************************************** +{ + _quadTree = locator._quadTree; + _currentQuadTree = locator._currentQuadTree; + _goLocator = locator._goLocator; + return *this; +} + +Go* QuadTree_Gos::Locator::GetElement() const +// ****************************************** +{ + return _goLocator.GetElement(); +} + +Locator* QuadTree_Gos::Locator::GetClone() const +// ************************************************** +{ + return new Locator(*this); +} + +bool QuadTree_Gos::Locator::IsValid() const +// **************************************** +{ + return _goLocator.IsValid(); +} + +void QuadTree_Gos::Locator::Progress() +// *********************************** +{ + if (IsValid()) { + _goLocator.Progress(); + if (!_goLocator.IsValid()) { + _currentQuadTree = _currentQuadTree->_GetNextQuadTree(); + if (_currentQuadTree) + _goLocator = _currentQuadTree->_GetGoSet().GetElements().GetLocator(); + } + } +} + +string QuadTree_Gos::Locator::_GetString() const +// ********************************************* +{ + string s = "<" + _TName("QuadTree::Gos::Locator"); + if (_quadTree) s += " " + GetString(_quadTree); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// QuadTree_GosUnder implementation +// **************************************************************************************************** + +QuadTree_GosUnder::QuadTree_GosUnder() +// *********************************** +: Inherit(), + _quadTree(NULL), + _area() +{ +} + +QuadTree_GosUnder::QuadTree_GosUnder(const QuadTree* quadTree, const Box& area) +// **************************************************************************** +: Inherit(), + _quadTree(quadTree), + _area(area) +{ +} + +QuadTree_GosUnder::QuadTree_GosUnder(const QuadTree_GosUnder& gos) +// *************************************************************** +: Inherit(), + _quadTree(gos._quadTree), + _area(gos._area) +{ +} + +QuadTree_GosUnder& QuadTree_GosUnder::operator=(const QuadTree_GosUnder& gos) +// ************************************************************************** +{ + _quadTree = gos._quadTree; + _area = gos._area; + return *this; +} + +Collection* QuadTree_GosUnder::GetClone() const +// ************************************************* +{ + return new QuadTree_GosUnder(*this); +} + +Locator* QuadTree_GosUnder::GetLocator() const +// ************************************************ +{ + return new Locator(_quadTree, _area); +} + +string QuadTree_GosUnder::_GetString() const +// ***************************************** +{ + string s = "<" + _TName("QuadTree::GosUnder"); + if (_quadTree) { + s += " " + GetString(_quadTree); + s += " " + GetString(_area); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// QuadTree_GosUnder::Locator implementation +// **************************************************************************************************** + +QuadTree_GosUnder::Locator::Locator() +// ********************************** +: Inherit(), + _quadTree(NULL), + _area(), + _currentQuadTree(NULL), + _goLocator() +{ +} + +QuadTree_GosUnder::Locator::Locator(const QuadTree* quadTree, const Box& area) +// *************************************************************************** +: Inherit(), + _quadTree(quadTree), + _area(area), + _currentQuadTree(NULL), + _goLocator() +{ + if (_quadTree && !_area.IsEmpty()) { + _currentQuadTree = _quadTree->_GetFirstQuadTree(_area); + if (_currentQuadTree) { + _goLocator = _currentQuadTree->_GetGoSet().GetElements().GetLocator(); + if (!GetElement()->GetBoundingBox().Intersect(_area)) Progress(); + } + } +} + +QuadTree_GosUnder::Locator::Locator(const Locator& locator) +// ******************************************************** +: Inherit(), + _quadTree(locator._quadTree), + _area(locator._area), + _currentQuadTree(locator._currentQuadTree), + _goLocator(locator._goLocator) +{ +} + +QuadTree_GosUnder::Locator& QuadTree_GosUnder::Locator::operator=(const Locator& locator) +// ************************************************************************************** +{ + _quadTree = locator._quadTree; + _area = locator._area; + _currentQuadTree = locator._currentQuadTree; + _goLocator = locator._goLocator; + return *this; +} + +Go* QuadTree_GosUnder::Locator::GetElement() const +// *********************************************** +{ + return _goLocator.GetElement(); +} + +Locator* QuadTree_GosUnder::Locator::GetClone() const +// ******************************************************* +{ + return new Locator(*this); +} + +bool QuadTree_GosUnder::Locator::IsValid() const +// ********************************************* +{ + return _goLocator.IsValid(); +} + +void QuadTree_GosUnder::Locator::Progress() +// **************************************** +{ + if (IsValid()) { + do { + _goLocator.Progress(); + if (!_goLocator.IsValid()) { + _currentQuadTree = _currentQuadTree->_GetNextQuadTree(_area); + if (_currentQuadTree) + _goLocator = _currentQuadTree->_GetGoSet().GetElements().GetLocator(); + } + } while (IsValid() && !GetElement()->GetBoundingBox().Intersect(_area)); + } +} + +string QuadTree_GosUnder::Locator::_GetString() const +// ************************************************** +{ + string s = "<" + _TName("QuadTree::GosUnder::Locator"); + if (_quadTree) { + s += " " + GetString(_quadTree); + s += " " + GetString(_area); + } + s += ">"; + return s; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/QuadTree.h b/hurricane/src/hurricane/QuadTree.h new file mode 100644 index 00000000..5cbe4d61 --- /dev/null +++ b/hurricane/src/hurricane/QuadTree.h @@ -0,0 +1,118 @@ +// **************************************************************************************************** +// File: QuadTree.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_QUAD_TREE +#define HURRICANE_QUAD_TREE + +#include "Box.h" +#include "Gos.h" +#include "IntrusiveSet.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// QuadTree declaration +// **************************************************************************************************** + +class QuadTree { +// Types +// ***** + + public: class GoSet : public IntrusiveSet { + // ******************************************* + + public: typedef IntrusiveSet Inherit; + + public: GoSet(); + + public: virtual unsigned _GetHashValue(Go* go) const; + public: virtual Go* _GetNextElement(Go* go) const; + public: virtual void _SetNextElement(Go* go, Go* nextGo) const; + + }; + +// Attributes +// ********** + + private: QuadTree* _parent; + private: Unit _x; + private: Unit _y; + private: Box _boundingBox; + private: unsigned _size; + private: GoSet _goSet; + private: QuadTree* _ulChild; // Upper Left Child + private: QuadTree* _urChild; // Upper Right Child + private: QuadTree* _llChild; // Lower Left Child + private: QuadTree* _lrChild; // Lower Right Child + +// Constructors +// ************ + + public: QuadTree(); + + private: QuadTree(QuadTree* parent); + + private: QuadTree(const QuadTree& quadTree); // not implemented to forbid copy construction + +// Destructor +// ********** + + public: ~QuadTree(); + +// Operators +// ********* + + private: QuadTree& operator=(const QuadTree& quadTree); // not implemented to forbid assignment + +// Accessors +// ********* + + public: const Box& GetBoundingBox() const; + public: Gos GetGos() const; + public: Gos GetGosUnder(const Box& area) const; + +// Predicates +// ********** + + public: bool IsEmpty() const {return (_size == 0);}; + +// Updators +// ******** + + public: void Insert(Go* go); + public: void Remove(Go* go); + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("QuadTree"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + public: GoSet& _GetGoSet() {return _goSet;}; + public: QuadTree* _GetDeepestChild(const Box& box); + public: QuadTree* _GetFirstQuadTree() const; + public: QuadTree* _GetFirstQuadTree(const Box& area) const; + public: QuadTree* _GetNextQuadTree(); + public: QuadTree* _GetNextQuadTree(const Box& area); + + public: bool _HasBeenExploded() const {return (_ulChild != NULL);}; + + public: void _Explode(); + public: void _Implode(); + +}; + + +} // End of Hurricane namespace. + +#endif // HURRICANE_QUAD_TREE + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Quark.cpp b/hurricane/src/hurricane/Quark.cpp new file mode 100644 index 00000000..79c2e9d5 --- /dev/null +++ b/hurricane/src/hurricane/Quark.cpp @@ -0,0 +1,128 @@ +// **************************************************************************************************** +// File: Quark.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Quark.h" +#include "SharedPath.h" +#include "Entity.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Variables +// **************************************************************************************************** + +typedef SharedPath::QuarkMap Quark_QuarkMap; + +static Quark_QuarkMap* NULL_SHARED_PATH_QUARK_MAP = NULL; + + + +// **************************************************************************************************** +// Quark implementation +// **************************************************************************************************** + +Quark::Quark(const Occurrence& occurrence) +// ************************************* +: Inherit(), + _occurrence(occurrence), + _nextOfSharedPathQuarkMap(NULL) +{ + if (!_occurrence.IsValid()) + throw Error("Can't create " + _TName("Quark") + " : invalid occurrence"); + + if (_occurrence._GetQuark()) + throw Error("Can't create " + _TName("Quark") + " : already exists"); +} + +Quark* Quark::_Create(const Occurrence& occurrence) +// ********************************************** +{ + Quark* quark = new Quark(occurrence); + + quark->_PostCreate(); + + return quark; +} + +void Quark::_PostCreate() +// ********************** +{ + SharedPath* sharedPath = _occurrence._GetSharedPath(); + + if (sharedPath) + sharedPath->_GetQuarkMap()._Insert(this); + else { + if (!NULL_SHARED_PATH_QUARK_MAP) NULL_SHARED_PATH_QUARK_MAP = new Quark_QuarkMap(); + NULL_SHARED_PATH_QUARK_MAP->_Insert(this); + } + + Inherit::_PostCreate(); +} + +void Quark::_PreDelete() +// ********************* +{ +// trace << "entering Quark::_PreDelete: " << this << endl; +// trace_in(); + + Inherit::_PreDelete(); + + SharedPath* sharedPath = _occurrence._GetSharedPath(); + + if (sharedPath) + sharedPath->_GetQuarkMap()._Remove(this); + else + if (NULL_SHARED_PATH_QUARK_MAP) NULL_SHARED_PATH_QUARK_MAP->_Remove(this); + +// trace << "exiting Quark::_PreDelete:" << endl; +// trace_out(); +} + +string Quark::_GetString() const +// ***************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_occurrence)); + return s; +} + +Record* Quark::_GetRecord() const +// ************************ +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Occurrence", &_occurrence)); + } + return record; +} + + + +// **************************************************************************************************** +// Entity implementation (located here to access the local variables) +// **************************************************************************************************** + +Quark* Entity::_GetQuark(SharedPath* sharedPath) const +// *************************************************** +{ + if (sharedPath) + return sharedPath->_GetQuark(this); + else { + if (!NULL_SHARED_PATH_QUARK_MAP) return NULL; + return NULL_SHARED_PATH_QUARK_MAP->GetElement(this); + } +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Quark.h b/hurricane/src/hurricane/Quark.h new file mode 100644 index 00000000..df8bdede --- /dev/null +++ b/hurricane/src/hurricane/Quark.h @@ -0,0 +1,73 @@ +// **************************************************************************************************** +// File: Quark.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_QUARK +#define HURRICANE_QUARK + +#include "DBo.h" +#include "Quarks.h" +#include "Occurrence.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Quark declaration +// **************************************************************************************************** + +class Quark : public DBo { +// ********************* + +// Types +// ***** + + public: typedef DBo Inherit; + +// Attributes +// ********** + + private: Occurrence _occurrence; + private: Quark* _nextOfSharedPathQuarkMap; + +// Constructors +// ************ + + protected: Quark(const Occurrence& occurrence); + +// Accessors +// ********* + + public: const Occurrence& GetOccurrence() const {return _occurrence;}; + +// Others +// ****** + + public: static Quark* _Create(const Occurrence& occurrence); + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("Quark");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: Quark* _GetNextOfSharedPathQuarkMap() const {return _nextOfSharedPathQuarkMap;}; + + public: void _SetNextOfSharedPathQuarkMap(Quark* quark) {_nextOfSharedPathQuarkMap = quark;}; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Quark) + +#endif // HURRICANE_QUARK + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Quarks.h b/hurricane/src/hurricane/Quarks.h new file mode 100644 index 00000000..179439e4 --- /dev/null +++ b/hurricane/src/hurricane/Quarks.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Quarks.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_QUARKS +#define HURRICANE_QUARKS + +#include "Collection.h" + +namespace Hurricane { + +class Quark; + + + +// **************************************************************************************************** +// Quarks declaration +// **************************************************************************************************** + +typedef GenericCollection Quarks; + + + +// **************************************************************************************************** +// QuarkLocator declaration +// **************************************************************************************************** + +typedef GenericLocator QuarkLocator; + + + +// **************************************************************************************************** +// QuarkFilter declaration +// **************************************************************************************************** + +typedef GenericFilter QuarkFilter; + + + +// **************************************************************************************************** +// for_each_quark declaration +// **************************************************************************************************** + +#define for_each_quark(quark, quarks)\ +/************************************/\ +{\ + QuarkLocator _locator = quarks.GetLocator();\ + while (_locator.IsValid()) {\ + Quark* quark = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_QUARKS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Record.cpp b/hurricane/src/hurricane/Record.cpp new file mode 100644 index 00000000..3f78bbaa --- /dev/null +++ b/hurricane/src/hurricane/Record.cpp @@ -0,0 +1,64 @@ +// **************************************************************************************************** +// File: Record.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Commons.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Record implementation +// **************************************************************************************************** + +Record::Record(const string& name) +// ******************************* +: _name(name), + _slotList() +{ +} + +Record::~Record() +// ************** +{ + while (!_slotList.empty()) { + Slot* slot = *_slotList.begin(); + _slotList.remove(slot); + delete slot; + } +} + +Slot* Record::GetSlot(unsigned no) const +// ************************************* +{ + SlotList::const_iterator iterator = _slotList.begin(); + while (no-- && (iterator != _slotList.end())) ++iterator; + return (iterator == _slotList.end()) ? NULL : *iterator; +} + +void Record::Add(Slot* slot) +// ************************* +{ + if (!slot) { + cerr << "[ERROR] Record::Add(): Attempt to add NULL Slot." << endl; + return; + } + _slotList.push_back(slot); +} + +string Record::_GetString() const +// ****************************** +{ + return "<" + _TName("Record") + " " + GetName() + ">"; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Record.h b/hurricane/src/hurricane/Record.h new file mode 100644 index 00000000..c2888583 --- /dev/null +++ b/hurricane/src/hurricane/Record.h @@ -0,0 +1,97 @@ + + +// -*- C++ -*- +// +// This file is part of the Hurricane Software. +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// +// =================================================================== +// +// $Id: Record.h,v 1.7 2007/07/29 15:24:58 jpc Exp $ +// +// x-----------------------------------------------------------------x +// | | +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Remy Escassut | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./Record.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + + + +# ifndef __RECORD__ +# define __RECORD__ + + +# ifndef __HURRICANE_COMMONS__ +# error "Record.h musn't be included alone, please uses Commons.h." +# endif + + +namespace Hurricane { + + +// ------------------------------------------------------------------- +// Forward Declarations. + + class Slot; + + + + +// ------------------------------------------------------------------- +// Class : "Record". + + class Record { + + // Types. + public: + typedef list SlotList; + + // Attributes + private: + string _name; + SlotList _slotList; + + // Constructors + public: + Record ( const string& name ); + private: + Record ( const Record& record ); + Record& operator= ( const Record& record ); + + // Destructor + public: + virtual ~Record(); + + // Accessors + public: + const string& GetName () const { return _name; }; + Slot* GetSlot ( unsigned no ) const; + + // Updators + public: + void Add ( Slot* slot ); + + // Others + public: + string _GetTypeName () const { return _TName("Record"); }; + string _GetString () const; + SlotList& _GetSlotList () { return _slotList; }; + +}; + + +} // End of Hurricane namespace. + + + + +#endif diff --git a/hurricane/src/hurricane/Reference.cpp b/hurricane/src/hurricane/Reference.cpp new file mode 100644 index 00000000..228a4049 --- /dev/null +++ b/hurricane/src/hurricane/Reference.cpp @@ -0,0 +1,134 @@ +// **************************************************************************************************** +// File: Reference.cpp +// Authors: J.-P. Chaput +// Copyright (c) LIP6/UPMC 2006-2006, All Rights Reserved +// **************************************************************************************************** + +#include "Reference.h" +#include "Cell.h" +#include "Slice.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Reference implementation +// **************************************************************************************************** + +// Static Variables +// **************** + + +Unit Reference::_extend = 0; + + +Reference::Reference(Cell* cell, const Name& name, Unit x, Unit y) +// *************************************************************** +: Inherit(cell), + _name(name), + _point(x,y) +{ + if ( !_extend ) _extend = GetUnit(0.5); + + if (_name.IsEmpty()) + throw Error("Can't create " + _TName("Reference") + " : empty name"); +} + +Reference* Reference::Create(Cell* cell, const Name& name, Unit x, Unit y) +// *********************************************************************** +{ + Reference* reference = new Reference(cell, name, x, y); + + reference->_PostCreate(); + + return reference; +} + +Reference* Reference::Create(Cell* cell, const Name& name, const Point& point) +// *************************************************************************** +{ + return Create(cell,name,point.GetX(),point.GetY()); +} + +Box Reference::GetBoundingBox() const +// *********************************** +{ + return Box(_point).Inflate(_extend); +} + +void Reference::Translate(const Unit& dx, const Unit& dy) +// ***************************************************** +{ + if ((dx != 0) || (dy != 0)) { + Invalidate(false); + _point.Translate(dx, dy); + } +} + +string Reference::_GetString() const +// ******************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_name)); + s.insert(s.length() - 1, " " + GetString(_point)); + return s; +} + +Record* Reference::_GetRecord() const +// *************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("point", &_point)); + } + return record; +} + +//bool Reference::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +//// **************************************************************************************** +//{ +// return GetBoundingBox().Intersect(Box(point).Inflate(aperture)); +//} +// +//void Reference::_Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) +//// **************************************************************************************************** +//{ +// assert(!basicLayer); +// +// Point center = transformation.GetPoint(_point); +// +// view->DrawLine( center.GetX() - _extend +// , center.GetY() +// , center.GetX() + _extend +// , center.GetY() +// ); +// view->DrawLine( center.GetX() +// , center.GetY() - _extend +// , center.GetX() +// , center.GetY() + _extend +// ); +// view->FillCircle(center, _extend>>1); +// if ( view->IsTextVisible() ) { +// view->DrawString( GetString(_name) +// , center.GetX() + _extend +// , center.GetY() + _extend +// ); +// } +//} +// +//void Reference::_Highlight(View* view, const Box& updateArea, const Transformation& transformation) +//// ********************************************************************************************** +//{ +// _Draw(view,NULL,updateArea,transformation); +//} +// +// + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) LIP6/UPMC 2006-2006, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Reference.h b/hurricane/src/hurricane/Reference.h new file mode 100644 index 00000000..6cff7bf3 --- /dev/null +++ b/hurricane/src/hurricane/Reference.h @@ -0,0 +1,77 @@ +// **************************************************************************************************** +// File: Reference.h +// Authors: J.-P. Chaput +// Copyright (c) LIP6/UPMC 2006-2006, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_REFERENCE +#define HURRICANE_REFERENCE + +#include "Marker.h" +#include "References.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Reference declaration +// **************************************************************************************************** + +class Reference : public Marker { +// ********************************* + +// Types +// ***** + + public: typedef Marker Inherit; + +// Attributes +// ********** + + public: Name _name; + public: Point _point; + public: static Unit _extend; + +// Constructors +// ************ + + protected: Reference(Cell* cell, const Name& name, Unit x, Unit y); + + public: static Reference* Create(Cell* cell, const Name& name, Unit x, Unit y ); + public: static Reference* Create(Cell* cell, const Name& name, const Point& point ); + +// Accessors +// ********* + + public: virtual Box GetBoundingBox() const; + public: const Name& GetName() const {return _name;}; + public: const Point& GetPoint() const {return _point;}; + +// Updators +// ******** + + public: virtual void Translate(const Unit& dx, const Unit& dy); + +// Others +// ****** + + public: virtual string _GetTypeName() const {return _TName("Reference");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + //public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; + //public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation); + //public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_REFERENCE + +// **************************************************************************************************** +// Copyright (c) LIP6/UPMC 2006-2006, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/References.h b/hurricane/src/hurricane/References.h new file mode 100644 index 00000000..091fc212 --- /dev/null +++ b/hurricane/src/hurricane/References.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: References.h +// Authors: J.-P. Chaput +// Copyright (c) LIP6/UPMC 2006-2006, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_REFERENCES +#define HURRICANE_REFERENCES + +#include "Collection.h" + +namespace Hurricane { + +class Reference; + + + +// **************************************************************************************************** +// References declaration +// **************************************************************************************************** + +typedef GenericCollection References; + + + +// **************************************************************************************************** +// ReferenceLocator declaration +// **************************************************************************************************** + +typedef GenericLocator ReferenceLocator; + + + +// **************************************************************************************************** +// ReferenceFilter declaration +// **************************************************************************************************** + +typedef GenericFilter ReferenceFilter; + + + +// **************************************************************************************************** +// for_each_marker declaration +// **************************************************************************************************** + +#define for_each_reference(reference, references)\ +/***************************************/\ +{\ + ReferenceLocator _locator = references.GetLocator();\ + while (_locator.IsValid()) {\ + Reference* reference = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_REFERENCES + +// **************************************************************************************************** +// Copyright (c) LIP6/UPMC 2006-2006, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Region.cpp b/hurricane/src/hurricane/Region.cpp new file mode 100644 index 00000000..d9bd812a --- /dev/null +++ b/hurricane/src/hurricane/Region.cpp @@ -0,0 +1,3130 @@ +// **************************************************************************************************** +// File: Region.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Region.h" +#include "Error.h" + + +namespace Hurricane { + +// **************************************************************************************************** +// Debugging purpose +// **************************************************************************************************** +#define DEBUG_REGION 0 +#if DEBUG_REGION +// to Stop and show region in graphic mode (for debugging) +void DblSupply_Stop(const Region& region, const string msg, const Box selBox, const int level); +#endif +#if DEBUG_REGION + // Calling sequence + string msg = "Region::GetIntersection avant Groove"; + DblSupply_Stop(region, msg, box, -10); +#endif + + +// **************************************************************************************************** +// Region_Tile declaration +// **************************************************************************************************** + +class Region_Tile { +// ************** + +// Types +// ***** + + public: class IsVoidFilter : public Filter { + // ***************************************************** + + public: IsVoidFilter(); + + public: IsVoidFilter(const IsVoidFilter& filter); + + public: IsVoidFilter& operator=(const IsVoidFilter& filter); + + public: virtual Filter* GetClone() const; + + public: virtual bool Accept(Region_Tile* tile) const; + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + public: Box _boundingBox; + public: bool _isVoid; + public: Region_Tile* _leftTile; + public: Region_Tile* _bottomTile; + public: Region_Tile* _topTile; + public: Region_Tile* _rightTile; + +// Constructors +// ************ + + public: Region_Tile(const Box& boundingBox, bool isVoid = false); + + private: Region_Tile(const Region_Tile& tile); // not implemented to forbid copy + +// Destructor +// ********** + + public: ~Region_Tile(); + +// Operators +// ********* + + private: Region_Tile& operator=(const Region_Tile& tile); // not implemented to forbid assignment + +// Accessors +// ********* + + public: const Box& GetBoundingBox() const {return _boundingBox;}; + + public: const Unit& GetXMin() const {return _boundingBox.GetXMin();}; + public: const Unit& GetYMin() const {return _boundingBox.GetYMin();}; + public: const Unit& GetXMax() const {return _boundingBox.GetXMax();}; + public: const Unit& GetYMax() const {return _boundingBox.GetYMax();}; + + public: Region_Tile* GetTileAt(const Point& point) const; + public: Region_Tile* GetNonVoidTileAt(const Point& point) const; + + public: Region_Tile* GetLeftTile(const Unit& y) const; + public: Region_Tile* GetBottomTile(const Unit& x) const; + public: Region_Tile* GetTopTile(const Unit& x) const; + public: Region_Tile* GetRightTile(const Unit& y) const; + +// Filters +// ******* + + public: static GenericFilter GetIsVoidFilter(); + +// Predicates +// ********** + + public: bool IsVoid() const {return _isVoid;}; + public: bool Contains(const Point& point) const; + +// Updators +// ******** + + public: void SplitVertical(Region* region, const Unit& x); + public: void SplitHorizontal(Region* region, const Unit& y); + public: bool MergeLeftTile(Region* region); + public: bool MergeBottomTile(Region* region); + public: bool MergeTopTile(Region* region); + public: bool MergeRightTile(Region* region); + public: void MergeNeighbours(Region* region); + public: void CleanNeighbours(Region* region); + public: bool VerticalEnhancement(Region* region); + public: bool HorizontalEnhancement(Region* region); + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("Region_Tile"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + private: bool _IsTopFull() const; + private: bool _IsBottomFull() const; + private: bool _IsLeftFull() const; + private: bool _IsRightFull() const; + private: Unit _TopSplitAtVerticalSize (Region* region); + private: Unit _BottomSplitAtVerticalSize (Region* region); + private: Unit _LeftSplitAtHorizontalSize (Region* region); + private: Unit _RightSplitAtHorizontalSize (Region* region); + private: bool _TopSplitAtHorizontalSize (Region* region, const Unit height); + private: bool _BottomSplitAtHorizontalSize (Region* region, const Unit height); + private: bool _LeftSplitAtVerticalSize (Region* region, const Unit width); + private: bool _RightSplitAtVerticalSize (Region* region, const Unit width); + + public: Interval _GetTopNeighbour () const; + public: Interval _GetBottomNeighbour () const; + public: Interval _GetLeftNeighbour () const; + public: Interval _GetRightNeighbour () const; +}; // class Region_Tile + + + +// **************************************************************************************************** +// Region_Tile implementation +// **************************************************************************************************** + +Region_Tile::Region_Tile(const Box& boundingBox, bool isVoid) +// ********************************************************** +: _boundingBox(boundingBox), + _isVoid(isVoid), + _leftTile(NULL), + _bottomTile(NULL), + _topTile(NULL), + _rightTile(NULL) +{ + if (boundingBox.IsEmpty()) + throw Error("Can't create " + _TName("Region::Tile") + " : empty bounding box"); +} + +Region_Tile::~Region_Tile() +// ************************ +{ +} + +bool Region_Tile::Contains(const Point& point) const +// ************************************************* +{ + return ((GetXMin() <= point.GetX()) && + (GetYMin() <= point.GetY()) && + ((point.GetX() < GetXMax()) || (!_rightTile && (point.GetX() == GetXMax()))) && + ((point.GetY() < GetYMax()) || (!_topTile && (point.GetY() == GetYMax())))); +} + +Region_Tile* Region_Tile::GetTileAt(const Point& point) const +// ********************************************************** +{ + if (Contains(point)) return (Region_Tile*)this; + + if (_topTile && (GetYMax() <= point.GetY())) return _topTile->GetTileAt(point); + + if (_leftTile && (point.GetX() < GetXMin())) return _leftTile->GetTileAt(point); + + return NULL; +} + +Region_Tile* Region_Tile::GetNonVoidTileAt(const Point& point) const +// ***************************************************************** +{ + if (Contains(point)) { + if (!_isVoid) return (Region_Tile*)this; + if ((GetXMin() < point.GetX()) && (GetYMin() < point.GetY())) return NULL; + } + + if (_topTile && (GetYMax() <= point.GetY())) return _topTile->GetNonVoidTileAt(point); + + if (_leftTile && (point.GetX() <= GetXMin())) return _leftTile->GetNonVoidTileAt(point); + + return NULL; +} + +Region_Tile* Region_Tile::GetLeftTile(const Unit& y) const +// ******************************************************* +{ + Region_Tile* tile = _leftTile; + while (tile && (tile->GetYMax() <= y)) tile = tile->_topTile; + return tile; +} + +Region_Tile* Region_Tile::GetBottomTile(const Unit& x) const +// ********************************************************* +{ + Region_Tile* tile = _bottomTile; + while (tile && (tile->GetXMax() <= x)) tile = tile->_rightTile; + return tile; +} + +Region_Tile* Region_Tile::GetTopTile(const Unit& x) const +// ****************************************************** +{ + Region_Tile* tile = _topTile; + while (tile && (x < tile->GetXMin())) tile = tile->_leftTile; + return tile; +} + +Region_Tile* Region_Tile::GetRightTile(const Unit& y) const +// ******************************************************** +{ + Region_Tile* tile = _rightTile; + while (tile && (y < tile->GetYMin())) tile = tile->_bottomTile; + return tile; +} + +GenericFilter Region_Tile::GetIsVoidFilter() +// ******************************************************* +{ + return Region_Tile::IsVoidFilter(); +} + +void Region_Tile::SplitVertical(Region* region, const Unit& x) +// *********************************************************** +{ + if ((GetXMin() < x) && (x < GetXMax())) { + Region_Tile* newTile = new Region_Tile(Box(x, GetYMin(), GetXMax(), GetYMax()), IsVoid()); + + newTile->_leftTile = this; + newTile->_rightTile = _rightTile; + if (_rightTile) { + Region_Tile* tile = _rightTile; + while (tile && (tile->_leftTile == this)) { + tile->_leftTile = newTile; + tile = tile->_bottomTile; + } + } + _rightTile = newTile; + + Region_Tile* tile = _bottomTile; + while (tile && (tile->_topTile == this)) { + if (x < tile->GetXMax()) tile->_topTile = newTile; + tile = tile->_rightTile; + } + if (_bottomTile) { + newTile->_bottomTile = _bottomTile; + while (newTile->_bottomTile->GetXMax() <= newTile->GetXMin()) + newTile->_bottomTile = newTile->_bottomTile->_rightTile; + } + + newTile->_topTile = _topTile; + while (_topTile && (_topTile->_bottomTile == this)) { + if (_topTile->GetXMin() < x) break; + _topTile->_bottomTile = newTile; + _topTile = _topTile->_leftTile; + } + + _boundingBox = Box(GetXMin(), GetYMin(), x, GetYMax()); + + if (region->_GetBottomRightTile() == this) region->_SetBottomRightTile(newTile); + } +} + +void Region_Tile::SplitHorizontal(Region* region, const Unit& y) +// ************************************************************* +{ + if ((GetYMin() < y) && (y < GetYMax())) { + Region_Tile* newTile = new Region_Tile(Box(GetXMin(), y, GetXMax(), GetYMax()), IsVoid()); + + newTile->_bottomTile = this; + newTile->_topTile = _topTile; + if (_topTile) { + Region_Tile* tile = _topTile; + while (tile && (tile->_bottomTile == this)) { + tile->_bottomTile = newTile; + tile = tile->_leftTile; + } + } + _topTile = newTile; + + Region_Tile* tile = _leftTile; + while (tile && (tile->_rightTile == this)) { + if (y < tile->GetYMax()) tile->_rightTile = newTile; + tile = tile->_topTile; + } + if (_leftTile) { + newTile->_leftTile = _leftTile; + while (newTile->_leftTile->GetYMax() <= newTile->GetYMin()) + newTile->_leftTile = newTile->_leftTile->_topTile; + } + + newTile->_rightTile = _rightTile; + while (_rightTile && (_rightTile->_leftTile == this)) { + if (_rightTile->GetYMin() < y) break; + _rightTile->_leftTile = newTile; + _rightTile = _rightTile->_bottomTile; + } + + _boundingBox = Box(GetXMin(), GetYMin(), GetXMax(), y); + + if (region->_GetTopLeftTile() == this) region->_SetTopLeftTile(newTile); + } +} + +bool Region_Tile::MergeLeftTile(Region* region) +// ******************************************** +{ + Region_Tile* uselessTile = _leftTile; + + if (!uselessTile) return false; + if (uselessTile->_rightTile != this) return false; + if (uselessTile->_isVoid != _isVoid) return false; + if (uselessTile->GetXMax() != GetXMin()) return false; + if (uselessTile->GetYMin() != GetYMin()) return false; + if (uselessTile->GetYMax() != GetYMax()) return false; + + Region_Tile* tile = uselessTile->_topTile; + while (tile && (tile->_bottomTile == uselessTile)) { + tile->_bottomTile = this; + tile = tile->_leftTile; + } + + tile = uselessTile->_bottomTile; + while (tile && (tile->_topTile == uselessTile)) { + tile->_topTile = this; + tile = tile->_rightTile; + } + + tile = uselessTile->_leftTile; + while (tile && (tile->_rightTile == uselessTile)) { + tile->_rightTile = this; + tile = tile->_topTile; + } + + _leftTile = uselessTile->_leftTile; + _bottomTile = uselessTile->_bottomTile; + + _boundingBox.Merge(uselessTile->_boundingBox); + + if (region->_GetTopLeftTile() == uselessTile) region->_SetTopLeftTile(this); + + delete uselessTile; + + return true; +} + +bool Region_Tile::MergeBottomTile(Region* region) +// ********************************************** +{ + Region_Tile* uselessTile = _bottomTile; + + if (!uselessTile) return false; + if (uselessTile->_topTile != this) return false; + if (uselessTile->_isVoid != _isVoid) return false; + if (uselessTile->GetYMax() != GetYMin()) return false; + if (uselessTile->GetXMin() != GetXMin()) return false; + if (uselessTile->GetXMax() != GetXMax()) return false; + + Region_Tile* tile = uselessTile->_rightTile; + while (tile && (tile->_leftTile == uselessTile)) { + tile->_leftTile = this; + tile = tile->_bottomTile; + } + + tile = uselessTile->_leftTile; + while (tile && (tile->_rightTile == uselessTile)) { + tile->_rightTile = this; + tile = tile->_topTile; + } + + tile = uselessTile->_bottomTile; + while (tile && (tile->_topTile == uselessTile)) { + tile->_topTile = this; + tile = tile->_rightTile; + } + + _leftTile = uselessTile->_leftTile; + _bottomTile = uselessTile->_bottomTile; + + _boundingBox.Merge(uselessTile->_boundingBox); + + if (region->_GetBottomRightTile() == uselessTile) region->_SetBottomRightTile(this); + + delete uselessTile; + + return true; +} + +bool Region_Tile::MergeTopTile(Region* region) +// ******************************************* +{ + Region_Tile* uselessTile = _topTile; + + if (!uselessTile) return false; + if (uselessTile->_bottomTile != this) return false; + if (uselessTile->_isVoid != _isVoid) return false; + if (uselessTile->GetYMin() != GetYMax()) return false; + if (uselessTile->GetXMin() != GetXMin()) return false; + if (uselessTile->GetXMax() != GetXMax()) return false; + + Region_Tile* tile = uselessTile->_rightTile; + while (tile && (tile->_leftTile == uselessTile)) { + tile->_leftTile = this; + tile = tile->_bottomTile; + } + + tile = uselessTile->_leftTile; + while (tile && (tile->_rightTile == uselessTile)) { + tile->_rightTile = this; + tile = tile->_topTile; + } + + tile = uselessTile->_topTile; + while (tile && (tile->_bottomTile == uselessTile)) { + tile->_bottomTile = this; + tile = tile->_leftTile; + } + + _topTile = uselessTile->_topTile; + _rightTile = uselessTile->_rightTile; + + _boundingBox.Merge(uselessTile->_boundingBox); + + if (region->_GetTopLeftTile() == uselessTile) region->_SetTopLeftTile(this); + + delete uselessTile; + + return true; +} + +bool Region_Tile::MergeRightTile(Region* region) +// ********************************************* +{ + Region_Tile* uselessTile = _rightTile; + + if (!uselessTile) return false; + if (uselessTile->_leftTile != this) return false; + if (uselessTile->_isVoid != _isVoid) return false; + if (uselessTile->GetXMin() != GetXMax()) return false; + if (uselessTile->GetYMin() != GetYMin()) return false; + if (uselessTile->GetYMax() != GetYMax()) return false; + + Region_Tile* tile = uselessTile->_topTile; + while (tile && (tile->_bottomTile == uselessTile)) { + tile->_bottomTile = this; + tile = tile->_leftTile; + } + + tile = uselessTile->_bottomTile; + while (tile && (tile->_topTile == uselessTile)) { + tile->_topTile = this; + tile = tile->_rightTile; + } + + tile = uselessTile->_rightTile; + while (tile && (tile->_leftTile == uselessTile)) { + tile->_leftTile = this; + tile = tile->_bottomTile; + } + + _topTile = uselessTile->_topTile; + _rightTile = uselessTile->_rightTile; + + _boundingBox.Merge(uselessTile->_boundingBox); + + if (region->_GetBottomRightTile() == uselessTile) region->_SetBottomRightTile(this); + + delete uselessTile; + + return true; +} + +void Region_Tile::MergeNeighbours(Region* region) +// ********************************************** +{ + while (MergeLeftTile(region) || MergeTopTile(region) || + MergeBottomTile(region) || MergeRightTile(region)) { + } +} + +void Region_Tile::CleanNeighbours(Region* region) +// ********************************************** +{ + Region_Tile* tile = NULL; + + set tileSet; + + tile = _leftTile; + while (tile && (tile->GetYMin() <= GetYMax())) { + tileSet.insert(tile); + tile = tile->_topTile; + } + + tile = _topTile; + while (tile && (GetXMin() <= tile->GetXMax())) { + tileSet.insert(tile); + tile = tile->_leftTile; + } + + tile = _bottomTile; + while (tile && (tile->GetXMin() <= GetXMax())) { + tileSet.insert(tile); + tile = tile->_rightTile; + } + + tile = _rightTile; + while (tile && (GetYMin() <= tile->GetYMax())) { + tileSet.insert(tile); + tile = tile->_bottomTile; + } + + while (!tileSet.empty()) { + tile = *tileSet.begin(); + while (true) { + Region_Tile* leftTile = tile->_leftTile; + if ((leftTile == this) || !tile->MergeLeftTile(region)) break; + tileSet.erase(leftTile); + } + while (true) { + Region_Tile* topTile = tile->_topTile; + if ((topTile == this) || !tile->MergeTopTile(region)) break; + tileSet.erase(topTile); + } + while (true) { + Region_Tile* bottomTile = tile->_bottomTile; + if ((bottomTile == this) || !tile->MergeBottomTile(region)) break; + tileSet.erase(bottomTile); + } + while (true) { + Region_Tile* rightTile = tile->_rightTile; + if ((rightTile == this) || !tile->MergeRightTile(region)) break; + tileSet.erase(rightTile); + } + tileSet.erase(tile); + } +}; // Region_Tile::CleanNeighbours + + +bool +Region_Tile::_IsTopFull() const +// ******************************* +// Retourne true si toutes les tuiles sur this sont de meme isVoid, +{ + Region_Tile* upTile = _topTile; + while (upTile && upTile->_isVoid == _isVoid && + upTile->GetXMin() > GetXMin()) { + upTile = upTile->_leftTile; + } + return (upTile && upTile->_isVoid == _isVoid && + upTile->GetXMin() <= GetXMin()); +}; // Region_Tile::_IsTopFull + +bool +Region_Tile::_IsBottomFull() const +// ******************************* +// Retourne true si toutes les tuiles sous this sont de meme isVoid, +{ + Region_Tile* downTile = _bottomTile; + while (downTile && downTile->_isVoid == _isVoid && + downTile->GetXMax() < GetXMax()) { + downTile = downTile->_rightTile; + } + return (downTile && downTile->_isVoid == _isVoid && + downTile->GetXMax() >= GetXMax()); +}; // Region_Tile::_IsBottomFull + +bool +Region_Tile::_IsLeftFull() const +// ******************************* +// Retourne true si toutes les tuiles a gauche de this sont de meme isVoid, +{ + Region_Tile* leftTile = _leftTile; + while (leftTile && leftTile->_isVoid == _isVoid && + leftTile->GetYMax() < GetYMax()) { + leftTile = leftTile->_topTile; + } + return (leftTile && leftTile->_isVoid == _isVoid && + leftTile->GetYMax() >= GetYMax()); +}; // Region_Tile::_IsLeftFull + +bool +Region_Tile::_IsRightFull() const +// ******************************* +// Retourne true si toutes les tuiles a droite de this sont de meme isVoid, +{ + Region_Tile* rightTile = _rightTile; + while (rightTile && rightTile->_isVoid == _isVoid && + rightTile->GetYMin() > GetYMin()) { + rightTile = rightTile->_bottomTile; + } + return (rightTile && rightTile->_isVoid == _isVoid && + rightTile->GetYMin() <= GetYMin()); +}; // Region_Tile::_IsRightFull + +Unit +Region_Tile::_TopSplitAtVerticalSize (Region* region) +// ************************************************** +// Decoupe les tuiles top-left et top-right a la taille de this +// Retourne la hauteur minimale de la rangee +// Doit etre appele apres verif _IsTopFull() +{ + Region_Tile* upTile = _topTile; + Unit height = upTile->GetYMax() - GetYMax(); + if (upTile && upTile->GetXMax() != GetXMax()) { + upTile->SplitVertical (region, GetXMax()); + upTile = _topTile; + } + Unit ht; + while (upTile && upTile->GetXMin() > GetXMin()) { + ht = upTile->GetYMax() - GetYMax(); + if (height > ht) height = ht; + upTile = upTile->_leftTile; + } + ht = upTile->GetYMax() - GetYMax(); + if (height > ht) height = ht; + if (upTile && upTile->GetXMin() != GetXMin()) { + upTile->SplitVertical (region, GetXMin()); + } + return height; +}; // Region_Tile::_TopSplitAtVerticalSize + +Unit +Region_Tile::_BottomSplitAtVerticalSize (Region* region) +// ***************************************************** +// Decoupe les tuiles bottom-left et bottom-right a la taille de this +// Retourne la hauteur minimale de la rangee +// Doit etre appele apres verif _IsBottomFull() +{ + Region_Tile* downTile = _bottomTile; + Unit height = GetYMin() - downTile->GetYMin(); + if (downTile && downTile->GetXMin() != GetXMin()) { + downTile->SplitVertical (region, GetXMin()); + downTile = _bottomTile; + } + Unit ht; + while (downTile && downTile->GetXMax() < GetXMax()) { + ht = GetYMin() - downTile->GetYMin(); + if (height > ht) height = ht; + downTile = downTile->_rightTile; + } + ht = GetYMin() - downTile->GetYMin(); + if (height > ht) height = ht; + if (downTile && downTile->GetXMax() != GetXMax()) { + downTile->SplitVertical (region, GetXMax()); + } + return height; +}; // Region_Tile::_BottomSplitAtVerticalSize + + +Unit +Region_Tile::_LeftSplitAtHorizontalSize (Region* region) +// ***************************************************** +// Decoupe les tuiles left-top et left-bottom a la taille de this +// Retourne la largeur minimale de la colonne +// Doit etre appele apres verif _IsLeftFull() +{ + Region_Tile* leftTile = _leftTile; + Unit width = GetXMin() - leftTile->GetXMin(); + if (leftTile && leftTile->GetYMin() != GetYMin()) { + leftTile->SplitHorizontal (region, GetYMin()); + leftTile = _leftTile; + } + Unit wt; + while (leftTile && leftTile->GetYMax() < GetYMax()) { + wt = GetXMin() - leftTile->GetXMin(); + if (width > wt) width = wt; + leftTile = leftTile->_topTile; + } + wt = GetXMin() - leftTile->GetXMin(); + if (width > wt) width = wt; + if (leftTile && leftTile->GetYMax() != GetYMax()) { + leftTile->SplitHorizontal (region, GetYMax()); + } + return width; +}; // Region_Tile::_LeftSplitAtHorizontalSize + + +Unit +Region_Tile::_RightSplitAtHorizontalSize (Region* region) +// ****************************************************** +// Decoupe les tuiles right-bottom et right-top a la taille de this +// Retourne la largeur minimale de la colonne +// Doit etre appele apres verif _IsRightFull() +{ + Region_Tile* rightTile = _rightTile; + Unit width = rightTile->GetXMax() - GetXMax(); + if (rightTile && rightTile->GetYMax() != GetYMax()) { + rightTile->SplitHorizontal (region, GetYMax()); + rightTile = _rightTile; + } + Unit wt; + while (rightTile && rightTile->GetYMin() > GetYMin()) { + wt = rightTile->GetXMax() - GetXMax(); + if (width > wt) width = wt; + rightTile = rightTile->_bottomTile; + } + wt = rightTile->GetXMax() - GetXMax(); + if (width > wt) width = wt; + if (rightTile && rightTile->GetYMin() != GetYMin()) { + rightTile->SplitHorizontal (region, GetYMin()); + } + return width; +}; // Region_Tile::_RightSplitAtHorizontalSize + + +bool +Region_Tile::_TopSplitAtHorizontalSize (Region* region, const Unit height) +// *********************************************************************** +// Retaille la hauteur de toutes les tuiles sur this a la hauteur height +// Retourne true si une modif a ete faite +{ + bool modif = false; + Region_Tile* upTile = _topTile; + + while (upTile && upTile->GetXMin() >= GetXMin()) { + if (upTile->GetYMax() - GetYMax() > height) { + upTile->SplitHorizontal (region, GetYMax() + height); + if (upTile->_bottomTile != this) upTile = upTile->_bottomTile; + modif = true; + } + if (upTile->_rightTile && upTile->_rightTile->GetXMax() == GetXMax()) { + // Merge upTile et upTile->_rightTile + modif = upTile->MergeRightTile (region) || modif; + } + upTile = upTile->_leftTile; + } + return modif; +}; // Region_Tile::_TopSplitAtHorizontalSize + + +bool +Region_Tile::_BottomSplitAtHorizontalSize (Region* region, const Unit height) +// ************************************************************************** +// Retaille la hauteur de toutes les tuiles sous this a la hauteur height +// Retourne true si une modif a ete faite +{ + bool modif = false; + Region_Tile* downTile = _bottomTile; + + while (downTile && downTile->GetXMax() <= GetXMax()) { + if (GetYMin() - downTile->GetYMin() > height) { + downTile->SplitHorizontal (region, GetYMin() - height); + modif = true; + if (downTile->_topTile != this) downTile = downTile->_topTile; + } + if (downTile->_leftTile && downTile->_leftTile->GetXMin() == GetXMin()) { + // Merge downTile et downTile->_leftTile + modif = downTile->MergeLeftTile (region) || modif; + } + downTile = downTile->_rightTile; + } + return modif; +}; // Region_Tile::_BottomSplitAtHorizontalSize + +bool +Region_Tile::_LeftSplitAtVerticalSize (Region* region, const Unit width) +// ************************************************************************** +// Retaille la largeur de toutes les tuiles a gauche de this a la largeur width +// Retourne true si une modif a ete faite +{ + bool modif = false; + Region_Tile* leftTile = _leftTile; + + while (leftTile && leftTile->GetYMax() <= GetYMax()) { + if (GetXMin() - leftTile->GetXMin() > width) { + leftTile->SplitVertical (region, GetXMin() - width); + modif = true; + if (leftTile->_rightTile != this) leftTile = leftTile->_rightTile; + } + if (leftTile->_bottomTile && leftTile->_bottomTile->GetYMin() == GetYMin()) { + // Merge leftTile et leftTile->_bottomTile + modif = leftTile->MergeBottomTile (region) || modif; + } + leftTile = leftTile->_topTile; + } + return modif; +}; // Region_Tile::_LeftSplitAtVerticalSize + + +bool +Region_Tile::_RightSplitAtVerticalSize (Region* region, const Unit width) +// ************************************************************************** +// Retaille la hauteur de toutes les tuiles a droite de this a la largeur width +// Retourne true si une modif a ete faite +{ + bool modif = false; + Region_Tile* rightTile = _rightTile; + + while (rightTile && rightTile->GetYMin() >= GetYMin()) { + if (rightTile->GetXMax() - GetXMax() > width) { + rightTile->SplitVertical (region, GetXMax() + width); + modif = true; + if (rightTile->_leftTile != this) rightTile = rightTile->_leftTile; + } + if (rightTile->_topTile && rightTile->_topTile->GetYMax() == GetYMax()) { + // Merge rightTile et rightTile->_leftTile + modif = rightTile->MergeTopTile (region) || modif; + } + rightTile = rightTile->_bottomTile; + } + return modif; +}; // Region_Tile::_RightSplitAtVerticalSize + + +Interval +Region_Tile::_GetTopNeighbour () const +// *********************************** +// Retourne le merge des intervals de voisins sur this +{ + Interval result = Interval(); + Region_Tile* topTile = _topTile; + while (topTile && topTile->GetXMax() > GetXMin()) { + if (topTile->_isVoid == _isVoid) { + result.Merge (Interval (topTile->GetXMin(), topTile->GetXMax())); + } + topTile = topTile->_leftTile; + } + return result.GetIntersection (Interval (GetXMin(), GetXMax())); +}; // Region_Tile::_GetTopNeighbour + +Interval +Region_Tile::_GetBottomNeighbour () const +// *********************************** +// Retourne le merge des intervals de voisins sur this +{ + Interval result = Interval(); + Region_Tile* bottomTile = _bottomTile; + while (bottomTile && bottomTile->GetXMin() < GetXMax()) { + if (bottomTile->_isVoid == _isVoid) { + result.Merge (Interval (bottomTile->GetXMin(), bottomTile->GetXMax())); + } + bottomTile = bottomTile->_rightTile; + } + return result.GetIntersection (Interval (GetXMin(), GetXMax())); +}; // Region_Tile::_GetBottomNeighbour + +Interval +Region_Tile::_GetLeftNeighbour () const +// ************************************ +// Retourne le merge des intervals de voisins de gauche de this +{ + Interval result = Interval(); + Region_Tile* leftTile = _leftTile; + while (leftTile && leftTile->GetYMin() < GetYMax()) { + if (leftTile->_isVoid == _isVoid) { + result.Merge (Interval (leftTile->GetYMin(), leftTile->GetYMax())); + } + leftTile = leftTile->_topTile; + } + return result.GetIntersection (Interval (GetYMin(), GetYMax())); +}; // Region_Tile::_GetLeftNeighbour + +Interval +Region_Tile::_GetRightNeighbour () const +// ************************************* +// Retourne le merge des intervals de voisins de droite de this +{ + Interval result = Interval(); + Region_Tile* rightTile = _rightTile; + while (rightTile && rightTile->GetYMax() > GetYMin()) { + if (rightTile->_isVoid == _isVoid) { + result.Merge (Interval (rightTile->GetYMin(), rightTile->GetYMax())); + } + rightTile = rightTile->_bottomTile; + } + return result.GetIntersection (Interval (GetYMin(), GetYMax())); +}; // Region_Tile::_GetRightNeighbour + +bool +Region_Tile::VerticalEnhancement(Region* region) +// ********************************************* +{ + bool modif = false; + + while (_IsTopFull ()) { + Unit height = _TopSplitAtVerticalSize (region); + modif = _TopSplitAtHorizontalSize (region, height); + modif = MergeTopTile (region) || modif; + } + while (_IsBottomFull ()) { + Unit height = _BottomSplitAtVerticalSize (region); + modif = _BottomSplitAtHorizontalSize (region, height); + modif = MergeBottomTile (region) || modif; + } + return modif; +}; // Region_Tile::VerticalEnhancement + +bool +Region_Tile::HorizontalEnhancement(Region* region) +// *********************************************** +{ + bool modif = false; + + while (_IsLeftFull ()) { + Unit width = _LeftSplitAtHorizontalSize (region); + modif = _LeftSplitAtVerticalSize (region, width); + modif = MergeLeftTile (region) || modif; + } + while (_IsRightFull ()) { + Unit width = _RightSplitAtHorizontalSize (region); + modif = _RightSplitAtVerticalSize (region, width); + modif = MergeRightTile (region) || modif; + } + return modif; +}; // Region_Tile::HorizontalEnhancement + + +string Region_Tile::_GetString() const +// *********************************** +{ + string s = "<" + _TName("Region::Tile") + ">"; + s.insert(s.length() - 1, " " + GetString(_boundingBox)); + if (_isVoid) s.insert(s.length() - 1, " VOID"); + return s; +}; // ion_Tile::_Get + +Record* Region_Tile::_GetRecord() const +// ****************************** +{ + Record* record = new Record(GetString(this)); + if (record) { + record->Add(GetSlot("BoundingBox", &_boundingBox)); + record->Add(GetSlot("IsVoid", &_isVoid)); + record->Add(GetSlot("LeftTile", _leftTile)); + record->Add(GetSlot("BottomTile", _bottomTile)); + record->Add(GetSlot("TopTile", _topTile)); + record->Add(GetSlot("RightTile", _rightTile)); + } + return record; +} + + + +// **************************************************************************************************** +// Region_Tile::IsVoidFilter implementation +// **************************************************************************************************** + +Region_Tile::IsVoidFilter::IsVoidFilter() +// ************************************** +{ +} + +Region_Tile::IsVoidFilter::IsVoidFilter(const Region_Tile::IsVoidFilter& filter) +// ***************************************************************************** +{ +} + +Region_Tile::IsVoidFilter& Region_Tile::IsVoidFilter::operator=(const IsVoidFilter& filter) +// **************************************************************************************** +{ + return *this; +} + +Filter* Region_Tile::IsVoidFilter::GetClone() const +// ************************************************************** +{ + return new Region_Tile::IsVoidFilter(*this); +} + +bool Region_Tile::IsVoidFilter::Accept(Region_Tile* tile) const +// ************************************************************ +{ + return tile->IsVoid(); +} + +string Region_Tile::IsVoidFilter::_GetString() const +// ************************************************* +{ + return "<" + _TName("RegionTile::IsVoidFilter") + ">"; +} + + + +// **************************************************************************************************** +// Region_Tiles declaration +// **************************************************************************************************** + +class Region_Tiles : public Collection { +// ************************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ************************************************************ + + public: typedef Hurricane::Locator Inherit; + + private: const Region* _region; + private: stack _tileStack; + + public: Locator(const Region* region = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Region_Tile* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Region* _region; + +// Constructors +// ************ + + public: Region_Tiles(const Region* region = NULL); + public: Region_Tiles(const Region_Tiles& Tiles); + +// Operators +// ********* + + public: Region_Tiles& operator=(const Region_Tiles& Tiles); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Region_Tiles implementation +// **************************************************************************************************** + +Region_Tiles::Region_Tiles(const Region* region) +// ********************************************* +: Inherit(), + _region(region) +{ +} + +Region_Tiles::Region_Tiles(const Region_Tiles& tiles) +// ************************************************** +: Inherit(), + _region(tiles._region) +{ +} + +Region_Tiles& Region_Tiles::operator=(const Region_Tiles& tiles) +// ************************************************************* +{ + _region = tiles._region; + return *this; +} + +Collection* Region_Tiles::GetClone() const +// ***************************************************** +{ + return new Region_Tiles(*this); +} + +Locator* Region_Tiles::GetLocator() const +// **************************************************** +{ + return new Locator(_region); +} + +string Region_Tiles::_GetString() const +// ************************************ +{ + string s = "<" + _TName("Region::Tiles"); + if (_region) s += " " + GetString(_region); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Region_Tiles::Locator implementation +// **************************************************************************************************** + +Region_Tiles::Locator::Locator(const Region* region) +// ************************************************* +: Inherit(), + _region(region), + _tileStack() +{ + if (_region) { + Region_Tile* tile = _region->_GetBottomRightTile(); + while (tile) { + _tileStack.push(tile); + tile = tile->_leftTile; + } + } +} + +Region_Tiles::Locator::Locator(const Locator& locator) +// *************************************************** +: Inherit(), + _region(locator._region), + _tileStack(locator._tileStack) +{ +} + +Region_Tiles::Locator& Region_Tiles::Locator::operator=(const Locator& locator) +// **************************************************************************** +{ + _region = locator._region; + _tileStack = locator._tileStack; + return *this; +} + +Region_Tile* Region_Tiles::Locator::GetElement() const +// *************************************************** +{ + return (!_tileStack.empty()) ? _tileStack.top() : NULL; +} + +Locator* Region_Tiles::Locator::GetClone() const +// *********************************************************** +{ + return new Locator(*this); +} + +bool Region_Tiles::Locator::IsValid() const +// *************************************** +{ + return !_tileStack.empty(); +} + +void Region_Tiles::Locator::Progress() +// ********************************** +{ + if (!_tileStack.empty()) { + Region_Tile* tile = _tileStack.top(); + _tileStack.pop(); + Unit xMin = tile->GetXMin(); + Unit xMax = tile->GetXMax(); + Region_Tile* topTile = tile->_topTile; + while (topTile && (xMin < topTile->GetXMax())) { + if (topTile->GetXMax() <= xMax) _tileStack.push(topTile); + topTile = topTile->_leftTile; + } + } +} + +string Region_Tiles::Locator::_GetString() const +// ********************************************* +{ + string s = "<" + _TName("Region::Tiles::Locator"); + if (_region) s += " " + GetString(_region); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Region_TilesUnder declaration +// **************************************************************************************************** + +class Region_TilesUnder : public Collection { +// ****************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ************************************************************ + + public: typedef Hurricane::Locator Inherit; + + private: const Region* _region; + private: Box _area; + private: Region_Tile* _startTile; + private: stack _tileStack; + private: set _tileSet; // to check never stack 2 times the same tile + + public: Locator(); + public: Locator(const Region* region, const Box& area, Region_Tile* startTile = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Region_Tile* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Region* _region; + private: Box _area; + private: Region_Tile* _startTile; + +// Constructors +// ************ + + public: Region_TilesUnder(); + public: Region_TilesUnder(const Region* region, const Box& area, Region_Tile* startTile = NULL); + public: Region_TilesUnder(const Region_TilesUnder& Tiles); + +// Operators +// ********* + + public: Region_TilesUnder& operator=(const Region_TilesUnder& Tiles); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Region_TilesUnder implementation +// **************************************************************************************************** + +Region_TilesUnder::Region_TilesUnder() +// *********************************** +: Inherit(), + _region(NULL), + _area(), + _startTile(NULL) +{ +} + +Region_TilesUnder::Region_TilesUnder(const Region* region, const Box& area, Region_Tile* startTile) +// ************************************************************************************************ +: Inherit(), + _region(region), + _startTile(startTile) +{ + _area = area.GetIntersection(region->GetBoundingBox()); +} + +Region_TilesUnder::Region_TilesUnder(const Region_TilesUnder& tiles) +// ***************************************************************** +: Inherit(), + _region(tiles._region), + _area(tiles._area), + _startTile(tiles._startTile) +{ +} + +Region_TilesUnder& Region_TilesUnder::operator=(const Region_TilesUnder& tiles) +// **************************************************************************** +{ + _region = tiles._region; + _area = tiles._area; + _startTile = tiles._startTile; + return *this; +} + +Collection* Region_TilesUnder::GetClone() const +// ********************************************************** +{ + return new Region_TilesUnder(*this); +} + +Locator* Region_TilesUnder::GetLocator() const +// ********************************************************* +{ + return new Locator(_region, _area, _startTile); +} + +string Region_TilesUnder::_GetString() const +// ***************************************** +{ + string s = "<" + _TName("Region::TilesUnder"); + if (_region) { + s += " " + GetString(_region); + s += " " + GetString(_area); + s += " " + GetString(_startTile); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Region_TilesUnder::Locator implementation +// **************************************************************************************************** + +Region_TilesUnder::Locator::Locator() +// ********************************** +: Inherit(), + _region(NULL), + _area(), + _startTile(NULL), + _tileStack() +{ +} + +Region_TilesUnder::Locator::Locator(const Region* region, const Box& area, Region_Tile* startTile) +// *********************************************************************************************** +: Inherit(), + _region(region), + _area(area), + _startTile(startTile), + _tileStack() +{ + if (_region && !_area.IsEmpty()) { + Region_Tile* tile = _region->_GetTileAt(Point(_area.GetXMax(), _area.GetYMin()), _startTile); + while (tile && (_area.GetXMin() < tile->GetXMax())) { + while (tile && (tile->GetYMax() <= _area.GetYMin())) tile = tile->_topTile; + if (tile) { + if (_tileSet.find(tile) == _tileSet.end()) { + _tileSet.insert(tile); + _tileStack.push(tile); + } + tile = tile->_leftTile; + } + } + } +} + +Region_TilesUnder::Locator::Locator(const Locator& locator) +// ******************************************************** +: Inherit(), + _region(locator._region), + _area(locator._area), + _startTile(locator._startTile), + _tileStack(locator._tileStack) +{ +} + +Region_TilesUnder::Locator& Region_TilesUnder::Locator::operator=(const Locator& locator) +// ************************************************************************************** +{ + _region = locator._region; + _area = locator._area; + _startTile = locator._startTile; + _tileStack = locator._tileStack; + return *this; +} + +Region_Tile* Region_TilesUnder::Locator::GetElement() const +// ******************************************************** +{ + return (!_tileStack.empty()) ? _tileStack.top() : NULL; +} + +Locator* Region_TilesUnder::Locator::GetClone() const +// **************************************************************** +{ + return new Locator(*this); +} + +bool Region_TilesUnder::Locator::IsValid() const +// ********************************************* +{ + return !_tileStack.empty(); +} + +void Region_TilesUnder::Locator::Progress() +// **************************************** +{ + if (!_tileStack.empty()) { + Region_Tile* tile = _tileStack.top(); + _tileStack.pop(); + Unit xMin = max(tile->GetXMin(), _area.GetXMin()); + Unit xMax = tile->GetXMax(); + Region_Tile* topTile = tile->_topTile; + while (topTile && (xMin < topTile->GetXMax())) { + if ((topTile->GetXMin() <= _area.GetXMax()) && + (topTile->GetYMin() <= _area.GetYMax()) && + (min(topTile->GetXMax(), _area.GetXMax()) <= xMax)) { + if (_tileSet.find(topTile) == _tileSet.end()) { + _tileSet.insert(topTile); + _tileStack.push(topTile); + } + } + topTile = topTile->_leftTile; + } + } +} + +string Region_TilesUnder::Locator::_GetString() const +// ************************************************** +{ + string s = "<" + _TName("Region::TilesUnder::Locator"); + if (_region) { + s += " " + GetString(_region); + s += " " + GetString(_area); + s += " " + GetString(_startTile); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Region_BoxesUnder declaration +// **************************************************************************************************** + +class Region_BoxesUnder : public Collection { +// ********************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // *************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Region* _region; + private: Box _area; + private: GenericLocator _tileLocator; + + public: Locator(); + public: Locator(const Region* region, const Box& area = Box()); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Box GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Region* _region; + private: Box _area; + +// Constructors +// ************ + + public: Region_BoxesUnder(); + public: Region_BoxesUnder(const Region* region, const Box& area = Box()); + public: Region_BoxesUnder(const Region_BoxesUnder& boxes); + +// Operators +// ********* + + public: Region_BoxesUnder& operator=(const Region_BoxesUnder& boxes); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Region_BoxesUnder implementation +// **************************************************************************************************** + +Region_BoxesUnder::Region_BoxesUnder() +// *********************************** +: Inherit(), + _region(NULL), + _area() +{ +} + +Region_BoxesUnder::Region_BoxesUnder(const Region* region, const Box& area) +// ************************************************************************ +: Inherit(), + _region(region), + _area(area) +{ +} + +Region_BoxesUnder::Region_BoxesUnder(const Region_BoxesUnder& boxes) +// ***************************************************************** +: Inherit(), + _region(boxes._region), + _area(boxes._area) +{ +} + +Region_BoxesUnder& Region_BoxesUnder::operator=(const Region_BoxesUnder& boxes) +// **************************************************************************** +{ + _region = boxes._region; + _area = boxes._area; + return *this; +} + +Collection* Region_BoxesUnder::GetClone() const +// ************************************************* +{ + return new Region_BoxesUnder(*this); +} + +Locator* Region_BoxesUnder::GetLocator() const +// ************************************************ +{ + return new Locator(_region, _area); +} + +string Region_BoxesUnder::_GetString() const +// ***************************************** +{ + string s = "<" + _TName("Region::BoxesUnder"); + if (_region) { + s += " " + GetString(_region); + s += " " + GetString(_area); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Region_BoxesUnder::Locator implementation +// **************************************************************************************************** + +Region_BoxesUnder::Locator::Locator() +// ********************************** +: Inherit(), + _region(NULL), + _area(), + _tileLocator() +{ +} + +Region_BoxesUnder::Locator::Locator(const Region* region, const Box& area) +// *********************************************************************** +: Inherit(), + _region(region), + _area(area), + _tileLocator() +{ + if (_region) { + _tileLocator = + (_area.IsEmpty()) ? + _region->_GetTiles().GetSubSet(!Region_Tile::GetIsVoidFilter()).GetLocator() : + _region->_GetTilesUnder(_area).GetSubSet(!Region_Tile::GetIsVoidFilter()).GetLocator(); + } +} + +Region_BoxesUnder::Locator::Locator(const Locator& locator) +// ******************************************************** +: Inherit(), + _region(locator._region), + _area(locator._area), + _tileLocator(locator._tileLocator) +{ +} + +Region_BoxesUnder::Locator& Region_BoxesUnder::Locator::operator=(const Locator& locator) +// ************************************************************************************** +{ + _region = locator._region; + _area = locator._area; + _tileLocator = locator._tileLocator; + return *this; +} + +Box Region_BoxesUnder::Locator::GetElement() const +// *********************************************** +{ + return (_tileLocator.IsValid()) ? _tileLocator.GetElement()->GetBoundingBox() : Box(); +} + +Locator* Region_BoxesUnder::Locator::GetClone() const +// ******************************************************* +{ + return new Locator(*this); +} + +bool Region_BoxesUnder::Locator::IsValid() const +// ******************************************** +{ + return _tileLocator.IsValid(); +} + +void Region_BoxesUnder::Locator::Progress() +// **************************************** +{ + _tileLocator.Progress(); +} + +string Region_BoxesUnder::Locator::_GetString() const +// ************************************************** +{ + string s = "<" + _TName("Region::BoxesUnder::Locator"); + if (_region) { + s += " " + GetString(_region); + s += " " + GetString(_area); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Region_VoidBoxesUnder declaration +// **************************************************************************************************** + +class Region_VoidBoxesUnder : public Collection { +// ************************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // *************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Region* _region; + private: Box _area; + private: GenericLocator _tileLocator; + + public: Locator(); + public: Locator(const Region* region, const Box& area = Box()); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Box GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Region* _region; + private: Box _area; + +// Constructors +// ************ + + public: Region_VoidBoxesUnder(); + public: Region_VoidBoxesUnder(const Region* region, const Box& area = Box()); + public: Region_VoidBoxesUnder(const Region_VoidBoxesUnder& boxes); + +// Operators +// ********* + + public: Region_VoidBoxesUnder& operator=(const Region_VoidBoxesUnder& boxes); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Region_VoidBoxesUnder implementation +// **************************************************************************************************** + +Region_VoidBoxesUnder::Region_VoidBoxesUnder() +// ******************************************* +: Inherit(), + _region(NULL), + _area() +{ +} + +Region_VoidBoxesUnder::Region_VoidBoxesUnder(const Region* region, const Box& area) +// ******************************************************************************** +: Inherit(), + _region(region), + _area(area) +{ +} + +Region_VoidBoxesUnder::Region_VoidBoxesUnder(const Region_VoidBoxesUnder& boxes) +// ***************************************************************************** +: Inherit(), + _region(boxes._region), + _area(boxes._area) +{ +} + +Region_VoidBoxesUnder& Region_VoidBoxesUnder::operator=(const Region_VoidBoxesUnder& boxes) +// **************************************************************************************** +{ + _region = boxes._region; + _area = boxes._area; + return *this; +} + +Collection* Region_VoidBoxesUnder::GetClone() const +// ***************************************************** +{ + return new Region_VoidBoxesUnder(*this); +} + +Locator* Region_VoidBoxesUnder::GetLocator() const +// **************************************************** +{ + return new Locator(_region, _area); +} + +string Region_VoidBoxesUnder::_GetString() const +// ********************************************* +{ + string s = "<" + _TName("Region::VoidBoxesUnder"); + if (_region) { + s += " " + GetString(_region); + s += " " + GetString(_area); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Region_VoidBoxesUnder::Locator implementation +// **************************************************************************************************** + +Region_VoidBoxesUnder::Locator::Locator() +// ************************************** +: Inherit(), + _region(NULL), + _area(), + _tileLocator() +{ +} + +Region_VoidBoxesUnder::Locator::Locator(const Region* region, const Box& area) +// *************************************************************************** +: Inherit(), + _region(region), + _area(area), + _tileLocator() +{ + if (_region) { + _tileLocator = + (_area.IsEmpty()) ? + _region->_GetTiles().GetSubSet(Region_Tile::GetIsVoidFilter()).GetLocator() : + _region->_GetTilesUnder(_area).GetSubSet(Region_Tile::GetIsVoidFilter()).GetLocator(); + } +} + +Region_VoidBoxesUnder::Locator::Locator(const Locator& locator) +// ************************************************************ +: Inherit(), + _region(locator._region), + _area(locator._area), + _tileLocator(locator._tileLocator) +{ +} + +Region_VoidBoxesUnder::Locator& Region_VoidBoxesUnder::Locator::operator=(const Locator& locator) +// ********************************************************************************************** +{ + _region = locator._region; + _area = locator._area; + _tileLocator = locator._tileLocator; + return *this; +} + +Box Region_VoidBoxesUnder::Locator::GetElement() const +// *************************************************** +{ + return (_tileLocator.IsValid()) ? _tileLocator.GetElement()->GetBoundingBox() : Box(); +} + +Locator* Region_VoidBoxesUnder::Locator::GetClone() const +// *********************************************************** +{ + return new Locator(*this); +} + +bool Region_VoidBoxesUnder::Locator::IsValid() const +// ************************************************* +{ + return _tileLocator.IsValid(); +} + +void Region_VoidBoxesUnder::Locator::Progress() +// ******************************************** +{ + _tileLocator.Progress(); +} + +string Region_VoidBoxesUnder::Locator::_GetString() const +// ****************************************************** +{ + string s = "<" + _TName("Region::VoidBoxesUnder::Locator"); + if (_region) { + s += " " + GetString(_region); + s += " " + GetString(_area); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Region_Intervals declaration +// **************************************************************************************************** + +class Region_Intervals : public Collection { +// ************************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ******************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Region::SwapLine* _swapLine; + private: Region::Tile* _lowerTile; + private: Region::Tile* _upperTile; + + public: Locator(const Region::SwapLine* swapLine = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Interval GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Region::SwapLine* _swapLine; + +// Constructors +// ************ + + public: Region_Intervals(const Region::SwapLine* swapLine = NULL); + public: Region_Intervals(const Region_Intervals& intervals); + +// Operators +// ********* + + public: Region_Intervals& operator=(const Region_Intervals& intervals); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Region_Intervals implementation +// **************************************************************************************************** + +Region_Intervals::Region_Intervals(const Region::SwapLine* swapLine) +// ***************************************************************** +: Inherit(), + _swapLine(swapLine) +{ +} + +Region_Intervals::Region_Intervals(const Region_Intervals& intervals) +// ****************************************************************** +: Inherit(), + _swapLine(intervals._swapLine) +{ +} + +Region_Intervals& Region_Intervals::operator=(const Region_Intervals& intervals) +// ***************************************************************************** +{ + _swapLine = intervals._swapLine; + return *this; +} + +Collection* Region_Intervals::GetClone() const +// ***************************************************** +{ + return new Region_Intervals(*this); +} + +Locator* Region_Intervals::GetLocator() const +// **************************************************** +{ + return new Locator(_swapLine); +} + +string Region_Intervals::_GetString() const +// **************************************** +{ + string s = "<" + _TName("Region::SwapLine::Intervals"); + if (_swapLine) s += " " + GetString(_swapLine); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Region_Intervals::Locator implementation +// **************************************************************************************************** + +Region_Intervals::Locator::Locator(const Region::SwapLine* swapLine) +// ***************************************************************** +: Inherit(), + _swapLine(swapLine), + _lowerTile(NULL), + _upperTile(NULL) +{ + if (_swapLine) { + switch (_swapLine->GetType()) { + case Region::SwapLine::Type::VERTICAL : { + Unit x = _swapLine->GetPosition(); + Unit yMax = _swapLine->GetExtention().GetVMax(); + _lowerTile = _swapLine->_GetBaseTile(); + while (_lowerTile && _lowerTile->IsVoid()) + _lowerTile = _lowerTile->GetTopTile(x); + if (_lowerTile && (yMax < _lowerTile->GetYMin())) _lowerTile = NULL; + if (_lowerTile) { + Region::Tile* tile = _lowerTile; + while (tile && !tile->IsVoid()) { + _upperTile = tile; + tile = tile->GetTopTile(x); + if (tile && (yMax < tile->GetYMin())) tile = NULL; + } + } + break; + } + case Region::SwapLine::Type::HORIZONTAL : { + Unit y = _swapLine->GetPosition(); + Unit xMax = _swapLine->GetExtention().GetVMax(); + _lowerTile = _swapLine->_GetBaseTile(); + while (_lowerTile && _lowerTile->IsVoid()) + _lowerTile = _lowerTile->GetRightTile(y); + if (_lowerTile && (xMax < _lowerTile->GetXMin())) _lowerTile = NULL; + if (_lowerTile) { + Region::Tile* tile = _lowerTile; + while (tile && !tile->IsVoid()) { + _upperTile = tile; + tile = tile->GetRightTile(y); + if (tile && (xMax < tile->GetXMin())) tile = NULL; + } + } + break; + } + } + } +} + +Region_Intervals::Locator::Locator(const Locator& locator) +// ******************************************************* +: Inherit(), + _swapLine(locator._swapLine), + _lowerTile(locator._lowerTile), + _upperTile(locator._upperTile) +{ +} + +Region_Intervals::Locator& Region_Intervals::Locator::operator=(const Locator& locator) +// ************************************************************************************ +{ + _swapLine = locator._swapLine; + _lowerTile = locator._lowerTile; + _upperTile = locator._upperTile; + return *this; +} + +Interval Region_Intervals::Locator::GetElement() const +// *************************************************** +{ + if (!IsValid()) return Interval(); + + Interval interval; + switch (_swapLine->GetType()) { + case Region::SwapLine::Type::VERTICAL : { + interval = Interval(_lowerTile->GetYMin(), _upperTile->GetYMax()); + break; + } + case Region::SwapLine::Type::HORIZONTAL : { + interval = Interval(_lowerTile->GetXMin(), _upperTile->GetXMax()); + break; + } + } + + return interval.GetIntersection(_swapLine->GetExtention()); +} + +Locator* Region_Intervals::Locator::GetClone() const +// *********************************************************** +{ + return new Locator(*this); +} + +bool Region_Intervals::Locator::IsValid() const +// ******************************************** +{ + return (_lowerTile && _upperTile); +} + +void Region_Intervals::Locator::Progress() +// *************************************** +{ + if (IsValid()) { + switch (_swapLine->GetType()) { + case Region::SwapLine::Type::VERTICAL : { + Unit x = _swapLine->GetPosition(); + Unit yMax = _swapLine->GetExtention().GetVMax(); + _lowerTile = _upperTile->GetTopTile(x); + while (_lowerTile && _lowerTile->IsVoid()) + _lowerTile = _lowerTile->GetTopTile(x); + if (_lowerTile && (yMax < _lowerTile->GetYMin())) _lowerTile = NULL; + _upperTile = NULL; + if (_lowerTile) { + Region::Tile* tile = _lowerTile; + while (tile && !tile->IsVoid()) { + _upperTile = tile; + tile = tile->GetTopTile(x); + if (tile && (yMax < tile->GetYMin())) tile = NULL; + } + } + break; + } + case Region::SwapLine::Type::HORIZONTAL : { + Unit y = _swapLine->GetPosition(); + Unit xMax = _swapLine->GetExtention().GetVMax(); + _lowerTile = _upperTile->GetRightTile(y); + while (_lowerTile && _lowerTile->IsVoid()) + _lowerTile = _lowerTile->GetRightTile(y); + if (_lowerTile && (xMax < _lowerTile->GetXMin())) _lowerTile = NULL; + _upperTile = NULL; + if (_lowerTile) { + Region::Tile* tile = _lowerTile; + while (tile && !tile->IsVoid()) { + _upperTile = tile; + tile = tile->GetRightTile(y); + if (tile && (xMax < tile->GetXMin())) tile = NULL; + } + } + break; + } + } + } +} + +string Region_Intervals::Locator::_GetString() const +// ************************************************* +{ + string s = "<" + _TName("Region::SwapLine::Intervals::Locator"); + if (_swapLine) s += " " + GetString(_swapLine); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Region::SwapLine::Type implementation +// **************************************************************************************************** + +Region::SwapLine::Type::Type(const Code& code) +// ******************************************* +: _code(code) +{ +} + +Region::SwapLine::Type::Type(const Type& type) +// ******************************************* +: _code(type._code) +{ +} + +Region::SwapLine::Type& Region::SwapLine::Type::operator=(const Type& type) +// ************************************************************************ +{ + _code = type._code; + return *this; +} + +string Region::SwapLine::Type::_GetString() const +// ********************************************** +{ + switch (_code) { + case VERTICAL : return "VERTICAL"; + case HORIZONTAL : return "HORIZONTAL"; + } + return "ABNORMAL"; +} + +Record* Region::SwapLine::Type::_GetRecord() const +// ***************************************** +{ + Record* record = new Record(GetString(this)); + record->Add ( GetSlot ( "Code", ((unsigned int*)((void*)&_code)) ) ); + return record; +} + + + +// **************************************************************************************************** +// Region::SwapLine implementation +// **************************************************************************************************** + +Region::SwapLine::SwapLine() +// ************************* +: _region(NULL), + _type(), + _position(), + _extention(), + _baseTile(NULL) +{ +} + +Region::SwapLine::SwapLine(Region* region, const Type& type, const Interval& extention) +// ************************************************************************************ +: _region(region), + _type(type), + _position(), + _extention(extention), + _baseTile(NULL) +{ + if (!_region) + throw Error("Can't create " + _TName("Region::SwapLine") + " : null region"); + + if (!_region->IsEmpty()) { + switch (_type) { + case Type::VERTICAL : { + _position = _region->GetXMin(); + if (_extention.IsEmpty()) _extention = Interval(_region->GetYMin(), _region->GetYMax()); + _baseTile = _region->_GetTileAt(Point(_position, _extention.GetVMin())); + break; + } + case Type::HORIZONTAL : { + _position = _region->GetYMin(); + if (_extention.IsEmpty()) _extention = Interval(_region->GetXMin(), _region->GetXMax()); + _baseTile = _region->_GetTileAt(Point(_extention.GetVMin(), _position)); + break; + } + } + } +} + +Region::SwapLine::SwapLine(Region* region, const Type& type, const Unit& position, const Interval& extention) +// **************************************************************************************************** +: _region(region), + _type(type), + _position(position), + _extention(extention), + _baseTile(NULL) +{ + if (!_region) + throw Error("Can't create " + _TName("Region::SwapLine") + " : null region"); + + if (!_region->IsEmpty()) { + switch (_type) { + case Type::VERTICAL : { + if (_extention.IsEmpty()) _extention = Interval(_region->GetYMin(), _region->GetYMax()); + _baseTile = _region->_GetTileAt(Point(_position, _extention.GetVMin())); + break; + } + case Type::HORIZONTAL : { + if (_extention.IsEmpty()) _extention = Interval(_region->GetXMin(), _region->GetXMax()); + _baseTile = _region->_GetTileAt(Point(_extention.GetVMin(), _position)); + break; + } + } + } +} + +Region::SwapLine::SwapLine(const SwapLine& swapLine) +// ************************************************* +: _region(swapLine._region), + _type(swapLine._type), + _position(swapLine._position), + _extention(swapLine._extention), + _baseTile(swapLine._baseTile) +{ +} + +Region::SwapLine::~SwapLine() +// ************************** +{ +} + +Region::SwapLine& Region::SwapLine::operator=(const SwapLine& swapLine) +// ******************************************************************** +{ + _region = swapLine._region; + _type = swapLine._type; + _position = swapLine._position; + _extention = swapLine._extention; + _baseTile = swapLine._baseTile; + return *this; +} + +Intervals Region::SwapLine::GetIntervals() const +// ********************************************* +{ + return Region_Intervals(this); +} + +void Region::SwapLine::Progress(int n) + // *************************** +{ + if (IsValid() && n) { + if (0 < n) { + switch (_type) { + case Type::VERTICAL : { + while (n--) { + Unit yMin = GetExtention().GetVMin(); + Unit yMax = GetExtention().GetVMax(); + Unit x = _region->GetXMax() + 1; + Region::Tile* tile = _baseTile; + while (tile) { + if (_position < tile->GetXMax()) + x = min(tile->GetXMax(), x); + else { + assert(tile->GetXMax() == _position); + Region::Tile* rightTile = tile->_rightTile; + while (rightTile && (yMax < rightTile->GetYMin())) + rightTile = rightTile->_bottomTile; + while (rightTile && (yMin < rightTile->GetYMax())) { + x = min(rightTile->GetXMax(), x); + rightTile = rightTile->_bottomTile; + } + } + tile = tile->GetTopTile(_position); + if (tile && (yMax < tile->GetYMin())) tile = NULL; + } + _position = x; + while (_baseTile && (_baseTile->GetXMax() <= x)) + _baseTile = _baseTile->GetRightTile(yMin); + } + break; + } + case Type::HORIZONTAL : { + while (n--) { + Unit xMin = GetExtention().GetVMin(); + Unit xMax = GetExtention().GetVMax(); + Unit y = _region->GetYMax() + 1; + Region::Tile* tile = _baseTile; + while (tile) { + if (_position < tile->GetYMax()) + y = min(tile->GetYMax(), y); + else { + assert(tile->GetYMax() == _position); + Region::Tile* topTile = tile->_topTile; + while (topTile && (xMax < topTile->GetXMin())) + topTile = topTile->_leftTile; + while (topTile && (xMin < topTile->GetXMax())) { + y = min(topTile->GetYMax(), y); + topTile = topTile->_leftTile; + } + } + tile = tile->GetRightTile(_position); + if (tile && (xMax < tile->GetXMin())) tile = NULL; + } + _position = y; + while (_baseTile && (_baseTile->GetYMax() <= y)) + _baseTile = _baseTile->GetTopTile(xMin); + } + break; + } + } + } + else { + throw Error("SORRY, NOT IMPLEMENTED TODAY !"); + } + } +} + +void Region::SwapLine::Translate(const Unit& quantity) +// *************************************************** +{ + if (quantity) SetPosition(GetPosition() + quantity); +} + +void Region::SwapLine::SetPosition(const Unit& position) +// ***************************************************** +{ + if (position != _position) { + _position = position; + switch (_type) { + case Type::VERTICAL : { + _baseTile = _region->_GetTileAt(Point(_position, _extention.GetVMin())); + break; + } + case Type::HORIZONTAL : { + _baseTile = _region->_GetTileAt(Point(_extention.GetVMin(), _position)); + break; + } + } + } +} + +string Region::SwapLine::_GetString() const +// **************************************** +{ + string s = "<" + _GetTypeName() + ">"; + if (IsValid()) { + s.insert(s.length() - 1, " " + GetString(_type)); + s.insert(s.length() - 1, " " + GetString(_position)); + s.insert(s.length() - 1, " " + GetString(_extention)); + } + return s; +} + +Record* Region::SwapLine::_GetRecord() const +// *********************************** +{ + Record* record = new Record(GetString(this)); + if (record) { + record->Add(GetSlot("Region", _region)); + record->Add(GetSlot("Type", &_type)); + record->Add(GetSlot("Position", &_position)); + record->Add(GetSlot("Extention", &_extention)); + record->Add(GetSlot("BaseTile", _baseTile)); + } + return record; +} + + + +// **************************************************************************************************** +// Region implementation +// **************************************************************************************************** + +Region::Region() +// ************* +: _bottomRightTile(NULL), + _topLeftTile(NULL) +{ +} + +Region::Region(const Box& box, bool isVoid) +// **************************************** +{ + _bottomRightTile = new Tile(box, isVoid); + _topLeftTile = _bottomRightTile; +} + +Region::Region(const Region& region) +// ********************************* +{ + // keep trace (as void tile) of the initial bounding box + Box initialBoundingBox = region.GetBoundingBox(); + if (! initialBoundingBox.IsEmpty()) { + _bottomRightTile = new Tile(region.GetBoundingBox(), true); + _topLeftTile = _bottomRightTile; + for_each_box(box, region.GetBoxes()) { + Fill(box); + end_for; + } + } +} + +Region::~Region() +// ************** +{ + Clear(); +} + +Region& Region::operator=(const Region& region) +// ******************************************** +{ + Clear(); + // keep trace (as void tile) of the initial bounding box + Box initialBoundingBox = region.GetBoundingBox(); + if (! initialBoundingBox.IsEmpty()) { + _bottomRightTile = new Tile (initialBoundingBox, true); + _topLeftTile = _bottomRightTile; + for_each_box(box, region.GetBoxes()) { + Fill(box); + end_for; + } + } + return *this; +} + +Box Region::GetBoundingBox() const +// ******************************* +{ + Box boundingBox; + if (_bottomRightTile) boundingBox = _bottomRightTile->GetBoundingBox(); + if (_topLeftTile) boundingBox.Merge(_topLeftTile->GetBoundingBox()); + return boundingBox; +} + +Unit Region::GetXMin() const +// ************************* +{ + return (_topLeftTile) ? _topLeftTile->GetXMin() : Unit(); +} + +Unit Region::GetYMin() const +// ************************* +{ + return (_bottomRightTile) ? _bottomRightTile->GetYMin() : Unit(); +} + +Unit Region::GetXMax() const +// ************************* +{ + return (_bottomRightTile) ? _bottomRightTile->GetXMax() : Unit(); +} + +Unit Region::GetYMax() const +// ************************* +{ + return (_topLeftTile) ? _topLeftTile->GetYMax() : Unit(); +} + +Boxes Region::GetBoxes() const +// *************************** +{ + return Region_BoxesUnder(this); +} + +Boxes Region::GetBoxesUnder(const Box& area) const +// *********************************************** +{ + return Region_BoxesUnder(this, area); +} + +Boxes Region::GetVoidBoxes() const +// ******************************* +{ + return Region_VoidBoxesUnder(this); +} + +Boxes Region::GetVoidBoxesUnder(const Box& area) const +// *************************************************** +{ + return Region_VoidBoxesUnder(this, area); +} + +Region::SwapLine Region::GetVerticalSwapLine(const Interval& extention) const +// ************************************************************************** +{ + return SwapLine((Region*)this, Region::SwapLine::Type::VERTICAL, extention); +} + +Region::SwapLine Region::GetVerticalSwapLine(const Unit& x, const Interval& extention) const +// ***************************************************************************************** +{ + return SwapLine((Region*)this, Region::SwapLine::Type::VERTICAL, x, extention); +} + +Region::SwapLine Region::GetHorizontalSwapLine(const Interval& extention) const +// **************************************************************************** +{ + return SwapLine((Region*)this, Region::SwapLine::Type::HORIZONTAL, extention); +} + +Region::SwapLine Region::GetHorizontalSwapLine(const Unit& y, const Interval& extention) const +// ******************************************************************************************* +{ + return SwapLine((Region*)this, Region::SwapLine::Type::HORIZONTAL, y, extention); +} + +bool Region::IsEmpty() const +// ************************* +{ + return Region_Tiles(this).GetSubSet(!Tile::GetIsVoidFilter()).IsEmpty(); +} + +bool Region::Contains(const Point& point) const +// ******************************************** +{ + return GetBoundingBox().Contains(point) && _GetNonVoidTileAt(point); +} + +bool Region::Contains(const Box& box) const +// **************************************** +{ + if (box.IsPonctual()) return Contains(box.GetCenter()); + return GetBoundingBox().Contains(box) && + Region_TilesUnder (this, Box(box).Inflate(-1)) + .GetSubSet(Tile::GetIsVoidFilter()).IsEmpty(); +} + +bool Region::Contains(const Region& region) const +// ********************************************** +{ + for_each_box(box, region.GetBoxesUnder(GetBoundingBox())) { + if (!Contains(box)) return false; + end_for; + } + return true; +} + +#if 0 // pas encore teste +bool Region::Intersect(const Box& box) const +// ***************************************** +{ + if (box.IsPonctual()) return Contains(box.GetCenter()); + if (! GetBoundingBox().Intersect(box)) return false; + if (! Region_TilesUnder (this, Box(box).Inflate(1)) + .GetSubSet(! Tile::GetIsVoidFilter()).IsEmpty()) return true; + return false; +} + +bool Region::Intersect(const Region& region) const +// *********************************************** +{ + for_each_box(box, region.GetBoxesUnder(GetBoundingBox())) { + if (Intersect(box)) return true; + end_for; + } + return false; +} +#endif + +Region& Region::Clear() +// ******************** +{ + stack tileStack; + + Tile* tile = _bottomRightTile; + while (tile) { + tileStack.push(tile); + tile = tile->_leftTile; + } + // AD (11Aug03) to avoid delete Tiles in the while loop, because + // topTile->_leftTile may have been already deleted + vector accumulate; + + while (!tileStack.empty()) { + tile = tileStack.top(); + tileStack.pop(); + Unit xMin = tile->GetXMin(); + Unit xMax = tile->GetXMax(); + + Tile* topTile = tile->_topTile; + while (topTile && (xMin < topTile->GetXMax())) { + if (topTile->GetXMax() <= xMax) tileStack.push(topTile); + topTile = topTile->_leftTile; + } + accumulate.push_back (tile); + //delete tile; + } + for_each_object (Tile*, t, GetCollection (accumulate)) { + delete t; + end_for; + } + _bottomRightTile = NULL; + _topLeftTile = NULL; + + return *this; +} + +Region& Region::Fill(const Box& box) +// ********************************* +{ + if (box.IsEmpty() || !box.GetWidth() || !box.GetHeight()) return *this; + + if (!_bottomRightTile) { + _bottomRightTile = new Tile(box); + _topLeftTile = _bottomRightTile; + return *this; + } + + if (!GetBoundingBox().Contains(box)) + _Update(box, false); + else { + Tile* startTile = _GetStartTile(_GetTileAt(Point(box.GetXMax(), box.GetYMin()))); + GenericCollection tiles = _GetTilesUnder(Box(box).Inflate(0, 0, -1, -1), startTile); + if (!tiles.GetSubSet(Tile::GetIsVoidFilter()).IsEmpty()) _Update(box, false, startTile); + } + + return *this; +} + +Region& Region::Fill(const Region& region) +// *************************************** +{ + for_each_box(box, region.GetBoxes()) { + Fill(box); + end_for; + } + return *this; +} + +Region& Region::GetUnion (const Region& region) +// ******************************************** +{ + return Fill(region); +} + +Region& Region::Groove(const Box& box) +// *********************************** +{ + if (!_bottomRightTile) return *this; + + Box correctedBox = GetBoundingBox().GetIntersection(box); + + if (correctedBox.IsEmpty() || !correctedBox.GetWidth() || !correctedBox.GetHeight()) return *this; + + Tile* startTile = _GetStartTile(_GetTileAt(Point(correctedBox.GetXMax(), correctedBox.GetYMin()))); + GenericCollection tiles = _GetTilesUnder(Box(correctedBox).Inflate(0, 0, -1, -1), startTile); + if (!tiles.GetSubSet(!Tile::GetIsVoidFilter()).IsEmpty()) _Update(box, true, startTile); + + return *this; +} + +Region& Region::Groove(const Region& region) +// ***************************************** +{ + Box boundingBox = GetBoundingBox(); + for_each_box(box, region.GetBoxesUnder(boundingBox)) { + Groove(box); + end_for; + } + return *this; +} + +Region& Region::GetIntersection (const Region& region) +// *************************************************** +{ + Box boundingBox = GetBoundingBox(); + for_each_box (box, region.GetVoidBoxesUnder (boundingBox)) { + //for_each_box (box, region.GetVoidBoxes ()) { + //if (! boundingBox.Intersect (box)) continue; + Groove (box); + end_for; + } + return *this; +} + +Region& Region::Inflate(const Unit& quantity) +// ****************************************** +{ + if (!IsEmpty()) { + if (0 < quantity) { + list boxList; + for_each_object(Tile*, tile, Region_Tiles(this).GetSubSet(!Tile::GetIsVoidFilter())) { + boxList.push_back(tile->GetBoundingBox()); + end_for; + } + for_each_box(box, GetCollection(boxList)) { + Fill(box.Inflate(quantity)); + end_for; + } + } + else if (quantity < 0) { + _GrowthToFit(GetBoundingBox().Inflate(GetUnit(1))); + list boxList; + for_each_object(Tile*, tile, Region_Tiles(this).GetSubSet(Tile::GetIsVoidFilter())) { + boxList.push_back(tile->GetBoundingBox()); + end_for; + } + for_each_box(box, GetCollection(boxList)) { + Groove(box.Inflate(-quantity)); + end_for; + } + } + } + + return *this; +} + +Region& Region::Translate(const Unit& dx, const Unit& dy) +// ****************************************************** +{ + if ((dx != 0) || (dy != 0)) { + set tileSet; + _GetTiles().Fill(tileSet); + for_each_object(Tile*, tile, GetCollection(tileSet)) { + tile->_boundingBox.Translate(dx, dy); + end_for; + } + } + return *this; +} + +string Region::_GetString() const +// ****************************** +{ + string s = "<" + _GetTypeName() + ">"; + return s; +} + +Record* Region::_GetRecord() const +// ************************* +{ + Record* record = new Record(GetString(this)); + if (record) { + record->Add(GetSlot("BottomRightTile", _bottomRightTile)); + record->Add(GetSlot("TopLeftTile", _topLeftTile)); + } + return record; +} + +Region_Tile* Region::_GetTileAt(const Point& point, Tile* startTile) const +// *********************************************************************** +{ + if (!GetBoundingBox().Contains(point)) return NULL; + + return (startTile) ? startTile->GetTileAt(point) : _bottomRightTile->GetTileAt(point); +} + +Region_Tile* Region::_GetNonVoidTileAt(const Point& point, Tile* startTile) const +// ****************************************************************************** +{ + if (!GetBoundingBox().Contains(point)) return NULL; + + return (startTile) ? startTile->GetNonVoidTileAt(point) : _bottomRightTile->GetNonVoidTileAt(point); +} + +Region_Tile* Region::_GetStartTile(Tile* tile) const +// ************************************************* +{ + Tile* startTile = NULL; + + if (tile) { + if (!startTile && tile->_rightTile) { + Unit y = tile->GetYMin(); + startTile = tile->_rightTile; + while (startTile && (y <= startTile->GetYMax())) startTile = startTile->_bottomTile; + } + if (!startTile && tile->_bottomTile) { + Unit x = tile->GetXMax(); + startTile = tile->_bottomTile; + while (startTile && (startTile->GetXMin() <= x)) startTile = startTile->_rightTile; + } + } + + return startTile; +} + +GenericCollection Region::_GetTiles() const +// ****************************************************** +{ + return Region_Tiles(this); +} + +GenericCollection Region::_GetTilesUnder(const Box& area, Tile* startTile) const +// ******************************************************************************************* +{ + return Region_TilesUnder(this, area, startTile); +} + +void Region::_Split(const Box& box) +// ******************************** +{ + if (GetBoundingBox().Intersect(box)) { + + Tile* startTile = _GetStartTile(_GetTileAt(Point(box.GetXMax(), box.GetYMin()))); + + list tileList; + Box line = Box(box.GetXMin(), box.GetYMin(), box.GetXMax() - 1, box.GetYMin()); + _GetTilesUnder(line, startTile).Fill(tileList); + for_each_object(Tile*, tile, GetCollection(tileList)) { + tile->SplitHorizontal(this, box.GetYMin()); + end_for; + } + + tileList.clear(); + line = Box(box.GetXMin(), box.GetYMax(), box.GetXMax() - 1, box.GetYMax()); + _GetTilesUnder(line, startTile).Fill(tileList); + for_each_object(Tile*, tile, GetCollection(tileList)) { + tile->SplitHorizontal(this, box.GetYMax()); + end_for; + } + + tileList.clear(); + line = Box(box.GetXMin(), box.GetYMin(), box.GetXMin(), box.GetYMax() - 1); + _GetTilesUnder(line, startTile).Fill(tileList); + for_each_object(Tile*, tile, GetCollection(tileList)) { + tile->SplitVertical(this, box.GetXMin()); + end_for; + } + + tileList.clear(); + line = Box(box.GetXMax(), box.GetYMin(), box.GetXMax(), box.GetYMax() - 1); + _GetTilesUnder(line, startTile).Fill(tileList); + for_each_object(Tile*, tile, GetCollection(tileList)) { + tile->SplitVertical(this, box.GetXMax()); + end_for; + } + } +} + +void Region::_GrowthToFit(const Box& box) +// ************************************** +{ + if (box.IsEmpty()) return; + + if (!_bottomRightTile) { + _bottomRightTile = new Tile(box, true); + _topLeftTile = _bottomRightTile; + return; + } + + if (GetBoundingBox().Contains(box)) return; + + if (box.GetYMin() < GetYMin()) { + Tile* newTile = new Tile(Box(GetXMin(), box.GetYMin(), GetXMax(), GetYMin()), true); + Tile* tile = _bottomRightTile; + while (tile) { + tile->_bottomTile = newTile; + tile = tile->_leftTile; + } + newTile->_topTile = _bottomRightTile; + _bottomRightTile = newTile; + } + + if (GetYMax() < box.GetYMax()) { + Tile* newTile = new Tile(Box(GetXMin(), GetYMax(), GetXMax(), box.GetYMax()), true); + Tile* tile = _topLeftTile; + while (tile) { + tile->_topTile = newTile; + tile = tile->_rightTile; + } + newTile->_bottomTile = _topLeftTile; + _topLeftTile = newTile; + } + + if (box.GetXMin() < GetXMin()) { + Tile* newTile = new Tile(Box(box.GetXMin(), GetYMin(), GetXMin(), GetYMax()), true); + Tile* tile = _topLeftTile; + while (tile) { + tile->_leftTile = newTile; + tile = tile->_bottomTile; + } + newTile->_rightTile = _topLeftTile; + _topLeftTile = newTile; + } + + if (GetXMax() < box.GetXMax()) { + Tile* newTile = new Tile(Box(GetXMax(), GetYMin(), box.GetXMax(), GetYMax()), true); + Tile* tile = _bottomRightTile; + while (tile) { + tile->_rightTile = newTile; + tile = tile->_topTile; + } + newTile->_leftTile = _bottomRightTile; + _bottomRightTile = newTile; + } +} + +void Region::_Update(const Box& box, bool isVoid, Tile* startTile) +// ************************************************************** +{ + if (box.IsEmpty() || !_bottomRightTile || !box.GetWidth() || !box.GetHeight()) return; + + if (!GetBoundingBox().Contains(box)) _GrowthToFit(box); + + _Split(box); + + Tile* newTile = new Tile(box, isVoid); + + list tileList; + _GetTilesUnder(Box(box).Inflate(0, 0, -1, -1), startTile).Fill(tileList); + for_each_object(Tile*, tile, GetCollection(tileList)) { + if (_topLeftTile == tile) _topLeftTile = newTile; + if (_bottomRightTile == tile) _bottomRightTile = newTile; + if (tile->GetXMin() == box.GetXMin()) { + if (tile->GetYMin() == box.GetYMin()) { + newTile->_leftTile = tile->_leftTile; + newTile->_bottomTile = tile->_bottomTile; + } + Tile* leftTile = tile->_leftTile; + while (leftTile && (leftTile->_rightTile == tile)) { + leftTile->_rightTile = newTile; + leftTile = leftTile->_topTile; + } + } + if (tile->GetYMin() == box.GetYMin()) { + Tile* bottomTile = tile->_bottomTile; + while (bottomTile && (bottomTile->_topTile == tile)) { + bottomTile->_topTile = newTile; + bottomTile = bottomTile->_rightTile; + } + } + if (tile->GetYMax() == box.GetYMax()) { + if (tile->GetXMax() == box.GetXMax()) { + newTile->_topTile = tile->_topTile; + newTile->_rightTile = tile->_rightTile; + } + Tile* topTile = tile->_topTile; + while (topTile && (topTile->_bottomTile == tile)) { + topTile->_bottomTile = newTile; + topTile = topTile->_leftTile; + } + } + if (tile->GetXMax() == box.GetXMax()) { + Tile* rightTile = tile->_rightTile; + while (rightTile && (rightTile->_leftTile == tile)) { + rightTile->_leftTile = newTile; + rightTile = rightTile->_bottomTile; + } + } + end_for; + } + for_each_object(Tile*, tile, GetCollection(tileList)) { + delete tile; + end_for; + } + + newTile->CleanNeighbours(this); + newTile->MergeNeighbours(this); +}; // Region::_Update + +bool +Region::VerticalEnhancement() +// ************************** +{ + bool modif = false; + Region result; + double minArea = 1.*GetUnit(5)*GetUnit(5); + do { + // Rechercher la box de plus grande surface + Box maxBox = Box(); + double area = minArea; + for_each_box (box, GetBoxes()) { + if (! box.IsEmpty()) { + double a = 1. * box.GetWidth() * box.GetHeight(); + if (area < a) { + area = a; + maxBox = box; + } + } + end_for; + } + if (maxBox.IsEmpty()) break; + Tile* tile = _GetTileAt (maxBox.GetCenter()); + if (maxBox.GetWidth() >= GetUnit(2)) { + modif = tile->VerticalEnhancement (this); + } + result.Fill (tile->GetBoundingBox()); + Groove (tile->GetBoundingBox()); + } while (! IsEmpty()); + Fill (result); + return modif; +}; // Region::VerticalEnhancement + + +bool +Region::VerticalEnhancement(Point point) +// *************************************** +// Amelioration de la tuile contenant point +{ + bool modif = false; + Tile* tile = _GetTileAt (point); + if (tile) modif = tile->VerticalEnhancement (this); + return modif; +}; // Region::VerticalEnhancement + + +bool +Region::HorizontalEnhancement() +// **************************** +{ + bool modif = false; + Region result; + double minArea = 1.*GetUnit(5)*GetUnit(5); + do { + // Rechercher la box de plus grande surface + Box maxBox = Box(); + double area = minArea; + for_each_box (box, GetBoxes()) { + if (! box.IsEmpty()) { + double a = 1. * box.GetWidth() * box.GetHeight(); + if (area < a) { + area = a; + maxBox = box; + } + } + end_for; + } + if (maxBox.IsEmpty()) break; + Tile* tile = _GetTileAt (maxBox.GetCenter()); + if (maxBox.GetWidth() >= GetUnit(2)) { + modif = tile->HorizontalEnhancement (this); + } + result.Fill (tile->GetBoundingBox()); + Groove (tile->GetBoundingBox()); + } while (! IsEmpty()); + Fill (result); + return modif; +}; // Region::HorizontalEnhancement + +bool +Region::HorizontalEnhancement(Point point) +// *************************************** +// Amelioration de la tuile contenant point +{ + bool modif = false; + Tile* tile = _GetTileAt (point); + if (tile) modif = tile->HorizontalEnhancement (this); + return modif; +}; // Region::HorizontalEnhancement + + +Interval +Region::TopBottomFacing (const Box box) const +// ********************************************** +// Retourne le Merge des intervales en vis a vis entre les boites +// dessus et dessous de box +{ + Interval result = Interval(); + if (box.IsEmpty()) return result; + Tile* tile = _GetTileAt (box.GetCenter()); + Interval it1 = tile->_GetTopNeighbour (); + Interval it2 = tile->_GetBottomNeighbour (); + return it1.GetIntersection (it2); +}; // Region::TopBottomFacing + +Interval +Region::LeftRightFacing (const Box box) const +// ********************************************** +// Retourne le Merge des intervales en vis a vis entre les boites +// a gauche et droite de box +{ + Interval result = Interval(); + if (box.IsEmpty()) return result; + Tile* tile = _GetTileAt (box.GetCenter()); + Interval it1 = tile->_GetLeftNeighbour (); + Interval it2 = tile->_GetRightNeighbour (); + return it1.GetIntersection (it2); +}; // Region::LeftRightFacing + + + +} // End of Hurricane namespace. + + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Region.h b/hurricane/src/hurricane/Region.h new file mode 100644 index 00000000..c678ac3e --- /dev/null +++ b/hurricane/src/hurricane/Region.h @@ -0,0 +1,229 @@ +// **************************************************************************************************** +// File: Region.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_REGION +#define HURRICANE_REGION + +#include "Boxes.h" +#include "Intervals.h" + +namespace Hurricane { + +class Region_Tile; // defined in file Region.cpp to hide the implementation + + + +// **************************************************************************************************** +// Region declaration +// **************************************************************************************************** + +class Region { +// ********* + +// Types +// ***** + + public: typedef Region_Tile Tile; + + public: class SwapLine { + // ******************* + + public: class Type { + // *************** + + public: enum Code {VERTICAL=0, HORIZONTAL=1}; + + private: Code _code; + + public: Type(const Code& code = VERTICAL); + public: Type(const Type& type); + + public: Type& operator=(const Type& type); + + public: operator const Code&() const {return _code;}; + + public: const Code& GetCode() const {return _code;}; + + public: string _GetTypeName() const { return _TName("Region::SwapLine::Type"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + }; + + // Attributes + // ********** + + private: Region* _region; + private: Type _type; + private: Unit _position; + private: Interval _extention; + private: Tile* _baseTile; + + // Constructors + // ************ + + public: SwapLine(); + public: SwapLine(Region* region, const Type& type, const Interval& extention = Interval()); + public: SwapLine(Region* region, const Type& type, const Unit& position, const Interval& extention = Interval()); + public: SwapLine(const SwapLine& swapLine); + + // Destructor + // ********** + + public: ~SwapLine(); + + // Operators + // ********* + + public: SwapLine& operator=(const SwapLine& swapLine); + + // Accessors + // ********* + + public: Region* GetRegion() const {return _region;}; + public: Type GetType() const {return _type;}; + public: const Unit& GetPosition() const {return _position;}; + public: const Interval& GetExtention() const {return _extention;}; + + public: Intervals GetIntervals() const; + + // Predicates + // ********** + + public: bool IsValid() const {return _baseTile;}; + + // Updators + // ******** + + public: void Progress(int n = 1); + public: void Translate(const Unit& quantity); + public: void SetPosition(const Unit& position); + + // Others + // ****** + + public: string _GetTypeName() const { return _TName("Region::SwapLine"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + public: Tile* _GetBaseTile() const {return _baseTile;}; + + }; + +// Attributes +// ********** + + private: Tile* _bottomRightTile; + private: Tile* _topLeftTile; + +// Constructors +// ************ + + public: Region(); + public: Region(const Box& box, bool isVoid = false); + public: Region(const Region& region); + +// Destructor +// ********** + + public: ~Region(); + +// Operators +// ********* + + public: Region& operator=(const Region& region); + +// Accessors +// ********* + + public: Box GetBoundingBox() const; + + public: Unit GetXMin() const; + public: Unit GetYMin() const; + public: Unit GetXMax() const; + public: Unit GetYMax() const; + + public: Boxes GetBoxes() const; + public: Boxes GetBoxesUnder(const Box& area) const; + + public: Boxes GetVoidBoxes() const; + public: Boxes GetVoidBoxesUnder(const Box& area) const; + + public: SwapLine GetVerticalSwapLine(const Interval& extention = Interval()) const; + public: SwapLine GetVerticalSwapLine(const Unit& x, const Interval& extention = Interval()) const; + + public: SwapLine GetHorizontalSwapLine(const Interval& extention = Interval()) const; + public: SwapLine GetHorizontalSwapLine(const Unit& y, const Interval& extention = Interval()) const; + +// Predicates +// ********** + + public: bool IsEmpty() const; + + public: bool Contains(const Point& point) const; + public: bool Contains(const Box& box) const; + public: bool Contains(const Region& region) const; +#if 0 // pas encore teste + public: bool Intersect(const Box& box) const; + public: bool Intersect(const Region& region) const; +#endif + +// Updators +// ******** + + public: Region& Clear(); + + public: Region& Fill(const Box& box); + public: Region& Fill(const Region& region); + public: Region& GetUnion(const Region& region); + + public: Region& Groove(const Box& box); + public: Region& Groove(const Region& region); + public: Region& GetIntersection(const Region& region); + + public: Region& Inflate(const Unit& quantity); + public: Region& Translate(const Unit& dx, const Unit& dy); + + public: bool VerticalEnhancement(); + public: bool VerticalEnhancement(Point point); + public: bool HorizontalEnhancement(); + public: bool HorizontalEnhancement(Point point); + public: Interval TopBottomFacing (const Box box) const; + public: Interval LeftRightFacing (const Box box) const; + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("Region"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + public: Tile* _GetBottomRightTile() const {return _bottomRightTile;}; + public: Tile* _GetTopLeftTile() const {return _topLeftTile;}; + public: Tile* _GetTileAt(const Point& point, Tile* startTile = NULL) const; + public: Tile* _GetNonVoidTileAt(const Point& point, Tile* startTile = NULL) const; + public: Tile* _GetStartTile(Tile* tile) const; + public: GenericCollection _GetTiles() const; + public: GenericCollection _GetTilesUnder(const Box& area, Tile* startTile = NULL) const; + + public: void _SetBottomRightTile(Tile* bottomRightTile) {_bottomRightTile = bottomRightTile;}; + public: void _SetTopLeftTile(Tile* topLeftTile) {_topLeftTile = topLeftTile;}; + public: void _Split(const Box& box); + public: void _GrowthToFit(const Box& box); + public: void _Update(const Box& box, bool isVoid, Tile* startTile = NULL); + +}; + + + + +} // End of Hurricane namespace. + + +#endif // HURRICANE_REGION + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Relation.cpp b/hurricane/src/hurricane/Relation.cpp new file mode 100644 index 00000000..fae8abf4 --- /dev/null +++ b/hurricane/src/hurricane/Relation.cpp @@ -0,0 +1,163 @@ +// **************************************************************************************************** +// File: Relation.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Relation.h" +#include "DBo.h" +#include "Error.h" + +#include "Filter.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Filters declaration & implementation +// **************************************************************************************************** + +class Relation_OwnerIsSlave : public Filter { +// ********************************************** + + private: const Relation* _relation; + + public: Relation_OwnerIsSlave(const Relation* relation) + // **************************************************** + : _relation(relation) + { + }; + + public: Relation_OwnerIsSlave(const Relation_OwnerIsSlave& filter) + // *************************************************************** + : _relation(filter._relation) + { + }; + + public: Relation_OwnerIsSlave& operator=(const Relation_OwnerIsSlave& filter) + // ************************************************************************** + { + _relation = filter._relation; + return *this; + }; + + public: virtual Filter* GetClone() const + // ******************************************* + { + return new Relation_OwnerIsSlave(*this); + }; + + public: virtual bool Accept(DBo* owner) const + // ****************************************** + { + return (owner != _relation->GetMasterOwner()); + }; + + public: virtual string _GetString() const + // ************************************** + { + return "<" + _TName("Relation::OwnerIsSlave") + " " + GetString(_relation) + ">"; + }; + +}; + + + +// **************************************************************************************************** +// Relation implementation +// **************************************************************************************************** + +Relation::Relation(DBo* masterOwner) +// ********************************* +: Inherit(), + _masterOwner(masterOwner) +{ + if (!_masterOwner) + throw Error("Can't create " + _TName("Relation") + " : null master owner"); +} + +DBos Relation::GetSlaveOwners() const +// ********************************** +{ + return GetOwners().GetSubSet(Relation_OwnerIsSlave(this)); +} + +void Relation::OnReleasedBy(DBo* owner) +// ************************************ +{ + _GetOwnerSet().erase(owner); + + if (owner == _masterOwner) Delete(); +} + +void Relation::_PostCreate() +// ************************* +{ + Inherit::_PostCreate(); + + _masterOwner->Put(this); +} + +string Relation::_GetString() const +// ******************************** +{ + return "<" + _TName("Relation") + " " + GetString(GetMasterOwner()) + " " + GetString(GetName()) + ">"; +} + +Record* Relation::_GetRecord() const +// *************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("MasterOwner", _masterOwner)); + } + return record; +} + + + +// **************************************************************************************************** +// StandardRelation implementation +// **************************************************************************************************** + +StandardRelation::StandardRelation(DBo* masterOwner, const Name& name) +// ******************************************************************* +: Inherit(masterOwner), + _name(name) +{ +} + +StandardRelation* StandardRelation::Create(DBo* masterOwner, const Name& name) +// *************************************************************************** +{ + StandardRelation* standardRelation = new StandardRelation(masterOwner, name); + + standardRelation->_PostCreate(); + + return standardRelation; +}; + +string StandardRelation::_GetString() const +// **************************************** +{ + return Inherit::_GetString(); +} + +Record* StandardRelation::_GetRecord() const +// *********************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Name", &_name)); + } + return record; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Relation.h b/hurricane/src/hurricane/Relation.h new file mode 100644 index 00000000..d053d3a3 --- /dev/null +++ b/hurricane/src/hurricane/Relation.h @@ -0,0 +1,111 @@ +// **************************************************************************************************** +// File: Relation.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_RELATION +#define HURRICANE_RELATION + +#include "Property.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Relation declaration +// **************************************************************************************************** + +class Relation : public SharedProperty { +// *********************************** + +// Types +// ***** + + public: typedef SharedProperty Inherit; + +// Attributes +// ********** + + private: DBo* _masterOwner; + +// Constructors +// ************ + + protected: Relation(DBo* masterOwner); + +// Accessors +// ********* + + public: DBo* GetMasterOwner() const {return _masterOwner;}; + public: DBos GetSlaveOwners() const; + +// Managers +// ******** + + public: virtual void OnReleasedBy(DBo* owner); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + public: virtual string _GetTypeName() const {return _TName("Relation");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + +}; + + + +// **************************************************************************************************** +// StandardRelation declaration +// **************************************************************************************************** + +class StandardRelation : public Relation { +// ************************************* + +// Types +// ***** + + public: typedef Relation Inherit; + +// Attributes +// ********** + + private: Name _name; + +// Constructors +// ************ + + protected: StandardRelation(DBo* masterOwner, const Name& name); + + public: static StandardRelation* Create(DBo* masterOwner, const Name& name); + +// Accessors +// ********* + + public: virtual Name GetName() const {return _name;}; + +// Others +// ****** + + public: virtual string _GetTypeName() const {return _TName("StandardRelation");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Relation) +SetNestedSlotAdapter(Hurricane::StandardRelation) + +#endif // HURRICANE_RELATION + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/RoutingPad.cpp b/hurricane/src/hurricane/RoutingPad.cpp new file mode 100644 index 00000000..4446df83 --- /dev/null +++ b/hurricane/src/hurricane/RoutingPad.cpp @@ -0,0 +1,475 @@ +// **************************************************************************************************** +// +// This file is part of the Coriolis Project. +// Copyright (c) 2001-2006 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: RoutingPad.cpp +// Authors: H.Clement, M.Sroka +// **************************************************************************************************** + +#include "RoutingPad.h" +#include "Net.h" +#include "NetExternalComponents.h" +#include "CompositeLayer.h" +#include "Plug.h" +#include "Pin.h" +#include "Segment.h" +#include "Horizontal.h" +#include "Vertical.h" +#include "Cell.h" +#include "Instance.h" +#include "Error.h" + +namespace Hurricane { + +// **************************************************************************************************** +// RoutingPad implementation +// **************************************************************************************************** + +RoutingPad::RoutingPad(Net* net, const Point& p, Occurrence occurrence ) +// ********************************************************************************** +: Inherit(net), + _x(p.GetX()), + _y(p.GetY()), + _occurrence(occurrence) +{ +} + + +RoutingPad* RoutingPad::Create(Net* net, Occurrence occurrence) +// *********************************************************** +{ + if (!net) + throw Error ("Can't create RoutingPad : NULL net"); + if (!occurrence.IsValid()) + throw Error ("Can't create RoutingPag : Invalid occurrence"); + + //TODO Gerer une contruction avec un composant externe, mais ce n'est pas prioritaire + Plug* plug = NULL; + Pin* pin = NULL; + Contact* contact = NULL; + Point position; + + if ( (plug = dynamic_cast(occurrence.GetEntity()) ) ) { + position = occurrence.GetPath().GetTransformation().GetPoint( plug->GetPosition() ); + } else if ( (pin = dynamic_cast(occurrence.GetEntity()) ) ) { + position = occurrence.GetPath().GetTransformation().GetPoint( pin->GetPosition() ); + } else if ( (contact = dynamic_cast(occurrence.GetEntity()) ) ) { + position = occurrence.GetPath().GetTransformation().GetPoint( contact->GetPosition() ); + } + + if ( !plug && !pin && !contact ) + throw Error ("Can't create RoutingPad : plug or pin occurrence *required*"); + + RoutingPad* routingPad = new RoutingPad(net, position, occurrence); + + routingPad->_PostCreate(); + + return routingPad; +} + +void RoutingPad::_PostCreate() +// **************************** +{ + Inherit::_PostCreate(); + + if (!_occurrence.GetPath().IsEmpty()) + _occurrence.GetMasterCell()->_AddSlaveEntity(_occurrence.GetEntity(),this); +} + +Unit RoutingPad::GetX() const +// *********************** +{ + return _x; +} + +Unit RoutingPad::GetY() const +// *********************** +{ + return _y; +} + +Box RoutingPad::GetBoundingBox() const +// ******************************** +{ + Component* component = _GetEntityAsComponent(); + if ( component ) { + return _occurrence.GetPath().GetTransformation().GetBox ( component->GetBoundingBox() ); + } + + return Box(GetPosition()); +} + +Box RoutingPad::GetBoundingBox(BasicLayer* basicLayer) const +// ****************************************************** +{ + Component* component = _GetEntityAsComponent(); + if ( component ) + return _occurrence.GetPath().GetTransformation().GetBox ( component->GetBoundingBox(basicLayer) ); + + return Box(GetPosition()); +} + +Layer* RoutingPad::GetLayer() const +// ****************************************************** +{ + Component* component = _GetEntityAsComponent(); + if ( component ) return component->GetLayer (); + + return NULL; +} + +Point RoutingPad::GetSourcePosition() const +// **************************************** +{ + Segment* segment = _GetEntityAsSegment(); + if ( segment ) + return _occurrence.GetPath().GetTransformation().GetPoint ( segment->GetSourcePosition() ); + + return GetPosition(); +} + +Point RoutingPad::GetTargetPosition() const +// **************************************** +{ + Segment* segment = _GetEntityAsSegment(); + if ( segment ) + return _occurrence.GetPath().GetTransformation().GetPoint ( segment->GetTargetPosition() ); + + return GetPosition(); +} + +Unit RoutingPad::GetSourceX() const +// ******************************** +{ + return GetSourcePosition().GetX(); +} + +Unit RoutingPad::GetSourceY() const +// ******************************** +{ + return GetSourcePosition().GetY(); +} + +Unit RoutingPad::GetTargetX() const +// ******************************** +{ + return GetTargetPosition().GetX(); +} + +Unit RoutingPad::GetTargetY() const +// ******************************** +{ + return GetTargetPosition().GetY(); +} + +Point RoutingPad::GetCenter() const +// **************************************** +{ + Segment* segment = _GetEntityAsSegment(); + if ( segment ) + return _occurrence.GetPath().GetTransformation().GetPoint ( segment->GetCenter() ); + + return GetPosition(); +} + + +void RoutingPad::Translate(const Unit& dx, const Unit& dy) +// **************************************************** +{ + if ((dx != 0) || (dy != 0)) { + Invalidate(true); + _x += dx; + _y += dy; + } +} + +void RoutingPad::SetX(const Unit& x) +// ****************************** +{ + SetPosition(x, GetY()); +} + +void RoutingPad::SetY(const Unit& y) +// ****************************** +{ + SetPosition(GetX(), y); +} + +void RoutingPad::SetPosition(const Unit& x, const Unit& y) +// **************************************************** +{ + SetOffset(x, y); +} + +void RoutingPad::SetPosition(const Point& position) +// ********************************************* +{ + SetPosition(position.GetX(), position.GetY()); +} + +void RoutingPad::SetOffset(const Unit& x, const Unit& y) +// **************************************************** +{ + Invalidate(true); + _x = x; + _y = y; +} + +void RoutingPad::_PreDelete() +// *********************** +{ +// trace << "entering RoutingPad::PreDelete: " << this << endl; +// trace_in(); + + + if (!_occurrence.GetPath().IsEmpty()) + _occurrence.GetMasterCell()->_RemoveSlaveEntity(_occurrence.GetEntity(),this); + Inherit::_PreDelete(); + +// trace << "exiting RoutingPad::PreDelete:" << endl; +// trace_out(); +} + +string RoutingPad::_GetString() const +// ******************************* +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " [" + GetValueString(GetX())); + s.insert(s.length() - 1, " " + GetValueString(GetY())); + s.insert(s.length() - 1, "] "); + s.insert(s.length() - 1, GetString(_occurrence)); + return s; +} + +Record* RoutingPad::_GetRecord() const +// ************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("X", &_x)); + record->Add(GetSlot("Y", &_y)); + record->Add(GetSlot("Occurrence",_occurrence)); + } + return record; +} + +Component* RoutingPad::_GetEntityAsComponent () const +// *************************************************** +{ + if ( _occurrence.IsValid() ) + return dynamic_cast( _occurrence.GetEntity() ); + + return NULL; +} + +Segment* RoutingPad::_GetEntityAsSegment () const +// *********************************************** +{ + if ( _occurrence.IsValid() ) + return dynamic_cast( _occurrence.GetEntity() ); + + return NULL; +} + +//bool RoutingPad::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +//// ****************************************************************************************** +//{ +// Layer* layer = GetLayer(); +// Box boundingBox ( GetBoundingBox() ); +// Box area ( point ); +// +// area.Inflate ( aperture ); +// +// for_each_basic_layer(basicLayer, layer->GetBasicLayers()) { +// if (view->IsVisible(basicLayer)) +// if (boundingBox.Intersect(area)) return true; +// end_for; +// } +// +// return false; +//} +// +// +//void RoutingPad::_Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) +//// **************************************************************************************************** +//{ +// Box boundingBox ( GetBoundingBox() ); +// BasicLayer* layer = GetLayer()->_GetSymbolicBasicLayer(); +// +// if ( basicLayer == layer ) { +// if ( 1 < view->GetScreenSize(boundingBox.GetWidth()) ) { +// view->DrawRectangle ( boundingBox ); +// } +// else +// view->DrawLine ( GetSourcePosition(), GetTargetPosition() ); +// } +//} +// +// +//void RoutingPad::_Highlight(View* view, const Box& updateArea, const Transformation& transformation) +//// ********************************************************************************************** +//{ +// BasicLayer* layer = GetLayer()->_GetSymbolicBasicLayer(); +// _Draw ( view, layer, updateArea, transformation ); +//} + + +void RoutingPad::SetExternalComponent(Component* component) +// ******************************************************** +{ + if (IsMaterialized()) Invalidate(false); + + Occurrence plugOccurrence = GetPlugOccurrence(); + Plug* plug= static_cast(plugOccurrence.GetEntity()); + if (plug->GetMasterNet() != component->GetNet()) + throw Error("Cannot Set External Component to Routing Pad : Inconsistant Net"); + + _occurrence.GetMasterCell()->_RemoveSlaveEntity(_occurrence.GetEntity(),this); + _occurrence = Occurrence(component,Path(plugOccurrence.GetPath(),plug->GetInstance())); + + Point position = _occurrence.GetPath().GetTransformation().GetPoint ( component->GetPosition() ); + + Horizontal* horizontal = dynamic_cast(component); + if ( horizontal ) { + SetX ( 0 ); + SetY ( position.GetY() ); + } else { + Vertical* vertical = dynamic_cast(component); + if ( vertical ) { + SetX ( position.GetX() ); + SetY ( 0 ); + } else + SetPosition ( position ); + } + + _occurrence.GetMasterCell()->_AddSlaveEntity(_occurrence.GetEntity(),this); + + if (!IsMaterialized()) { + Materialize(); + } +} + + +Occurrence RoutingPad::GetPlugOccurrence() +// *************************************** +{ + if (is_a(_occurrence.GetEntity())) + return _occurrence; + Component* component= static_cast(_occurrence.GetEntity()); + Net* net=component->GetNet(); + Path path=_occurrence.GetPath(); + if (path.IsEmpty()) + throw Error("Empty Path => not in an instance"); + Instance* instance=path.GetTailInstance(); + Plug* plug=instance->GetPlug(net); + return Occurrence(plug,path.GetHeadPath()); +} + + +void RoutingPad::RestorePlugOccurrence() +// ************************************* +{ + if (IsMaterialized()) Unmaterialize(); + + _occurrence=GetPlugOccurrence(); + SetPosition ( _occurrence.GetPath().GetTransformation().GetPoint + ( dynamic_cast(_occurrence.GetEntity())->GetPosition() ) ); +} + + + +#if 0 +// **************************************************************************************************** +// RoutingPad::Builder declaration +// **************************************************************************************************** + +RoutingPad::Builder::Builder(const string& token) +// ******************************************* +: Inherit(token), + _layer(NULL), + _x(0), + _y(0), + _width(0), + _height(0) +{ +} + +void RoutingPad::Builder::Scan(InputFile& inputFile, char*& arguments) +// **************************************************************** +{ + Inherit::Scan(inputFile, arguments); + + unsigned layerId; + unsigned n; + + + if (r != 6) + throw Error("Can't create RoutingPad : syntax error"); + + arguments = &arguments[n]; + + DBo* dbo = inputFile.GetDBo(layerId); + if (!dbo || !is_a(dbo)) + throw Error("Can't create RoutingPad : bad layer"); + + _layer = (Layer*)dbo; +} + +DBo* RoutingPad::Builder::CreateDBo() +// ******************************* +{ + return RoutingPad::Create(GetNet(), GetLayer(), GetX(), GetY(), GetWidth(), GetHeight()); +} + +RoutingPad::Builder ROUTINGPAD_BUILDER("RP"); +#endif + + +RoutingPad* CreateRoutingPad ( Net* net, Occurrence plugOccurrence ) +// ***************************************************************** +{ + Component* bestComponent = NULL; + Plug* plug = static_cast(plugOccurrence.GetEntity()); + + for_each_component ( component, GetExternalComponents(plug->GetMasterNet()) ) { + if ( !bestComponent ) { bestComponent = component; continue; } + if ( /* IsOnTop(component->GetLayer(),bestComponent->GetLayer()) + ||*/ ( GetArea(component) > GetArea(bestComponent) ) ) { + bestComponent = component; + } + end_for + } + + if ( !bestComponent ) { + string message = "CreateRoutingPad(): Cannot find external component of "; + message += GetString(plug->GetMasterNet()) + " in "; + message += GetString(plug->GetInstance()) + ".\n" ; + throw Error ( message ); + } + + RoutingPad* rp = RoutingPad::Create ( net, plugOccurrence ); + rp->SetExternalComponent ( bestComponent ); + + return rp; +} + +RoutingPad* CreateRoutingPad ( Pin* pin ) +// ************************************** +{ + Occurrence pinOccurrence ( pin, Path() ); + +# if 0 + for_each_routing_pad ( routingPad, pin->GetNet()->GetRoutingPads() ) { + if ( routingPad->GetOccurrence() == pinOccurrence ) + return routingPad; + end_for + } +# endif + + return RoutingPad::Create ( pin->GetNet(), pinOccurrence ); +} + + +} // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/RoutingPad.h b/hurricane/src/hurricane/RoutingPad.h new file mode 100644 index 00000000..28db0d4a --- /dev/null +++ b/hurricane/src/hurricane/RoutingPad.h @@ -0,0 +1,109 @@ +// **************************************************************************************************** +// +// This file is part of the Coriolis Project. +// Copyright (c) 2001-2006 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: RoutingPad.h +// Authors: H.Clement, M.Sroka +// **************************************************************************************************** + +#ifndef HURRICANE_ROUTINGPAD +#define HURRICANE_ROUTINGPAD + +#include "Component.h" +#include "Occurrence.h" +#include "Pin.h" + +namespace Hurricane { + + +class Segment; + + +// **************************************************************************************************** +// RoutingPad declaration +// **************************************************************************************************** + +class RoutingPad : public Component { +// ***************************** + +// Types +// ***** + + public: typedef Component Inherit; + + +// Attributes +// ********** + + private: Unit _x; + private: Unit _y; + private: Occurrence _occurrence; + + + +// Constructors +// ************ + + protected: RoutingPad(Net* net, const Point& p, Occurrence occurrence = Occurrence()); + public: static RoutingPad* Create(Net* net, Occurrence occurrence); + +// Accessors +// ********* + + //public: virtual Hooks GetHooks() const; + public: virtual Unit GetX() const; + public: virtual Unit GetY() const; + public: virtual Box GetBoundingBox() const; + public: virtual Layer* GetLayer() const; + public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const; + public: virtual Point GetCenter() const; + public: Occurrence GetOccurrence() const { return _occurrence; }; + public: Occurrence GetPlugOccurrence(); + public: Point GetSourcePosition() const; + public: Point GetTargetPosition() const; + public: Unit GetSourceX() const; + public: Unit GetSourceY() const; + public: Unit GetTargetX() const; + public: Unit GetTargetY() const; + +// Updators +// ******** + + public: virtual void Translate(const Unit& dx, const Unit& dy); + + public: void SetX(const Unit& x); + public: void SetY(const Unit& y); + public: void SetPosition(const Unit& x, const Unit& y); + public: void SetPosition(const Point& position); + public: void SetOffset(const Unit& x, const Unit& y); + public: void SetExternalComponent(Component* component); + public: void RestorePlugOccurrence(); + +// Others +// ****** + + protected: virtual void _PostCreate(); + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("RoutingPad");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: Component* _GetEntityAsComponent () const; + public: Segment* _GetEntityAsSegment () const; +// public: bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; +// public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation); +// public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + +RoutingPad* CreateRoutingPad ( Net* net, Occurrence plugOccurrence ); +RoutingPad* CreateRoutingPad ( Pin* pin ); + + +} // End of Hurricane namespace. + +#endif // HURRICANE_ROUTINGPAD diff --git a/hurricane/src/hurricane/RoutingPads.h b/hurricane/src/hurricane/RoutingPads.h new file mode 100644 index 00000000..130bd7e2 --- /dev/null +++ b/hurricane/src/hurricane/RoutingPads.h @@ -0,0 +1,66 @@ +// **************************************************************************************************** +// +// This file is part of the Coriolis Project. +// Copyright (c) 2001-2006 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: RoutingPads.h +// Authors: H.Clement M.Sroka +// **************************************************************************************************** + +#ifndef HURRICANE_ROUTINGPADS +#define HURRICANE_ROUTINGPADS + +#include "Collection.h" + +namespace Hurricane { + +class RoutingPad; + + + +// **************************************************************************************************** +// RoutingPads declaration +// **************************************************************************************************** + +typedef GenericCollection RoutingPads; + + + +// **************************************************************************************************** +// RoutingPadLocator declaration +// **************************************************************************************************** + +typedef GenericLocator RoutingPadLocator; + + + +// **************************************************************************************************** +// RoutingPadFilter declaration +// **************************************************************************************************** + +typedef GenericFilter RoutingPadFilter; + + + +// **************************************************************************************************** +// for_each_routing_pad declaration +// **************************************************************************************************** + +#define for_each_routing_pad(routingpad, routingpads)\ +/*********************************/\ +{\ + RoutingPadLocator _locator = routingpads.GetLocator();\ + while (_locator.IsValid()) {\ + RoutingPad* routingpad = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_ROUTINGPADS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Rubber.cpp b/hurricane/src/hurricane/Rubber.cpp new file mode 100644 index 00000000..a9976266 --- /dev/null +++ b/hurricane/src/hurricane/Rubber.cpp @@ -0,0 +1,440 @@ +// **************************************************************************************************** +// File: Rubber.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment BULL-LIP6 : Rubbers end at component center + +#include "Rubber.h" +#include "Net.h" +#include "Plug.h" +#include "Instance.h" +#include "Cell.h" +#include "Hook.h" +#include "Component.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Rubber implementation +// **************************************************************************************************** + +Rubber::Rubber(Net* net, Hook* hook) +// ********************************* +: Inherit(), + _net(net), + _hook(hook), + _count(0), + _boundingBox(), + _nextOfNetRubberSet(NULL) +{ + if (!_net) + throw Error("Can't create " + _TName("Rubber") + " : null net"); + + if (!_hook) + throw Error("Can't create " + _TName("Rubber") + " : null hook"); + + if (_hook->GetComponent()->GetNet() != _net) + throw Error("Can't create " + _TName("Rubber") + " : invalid hook"); +} + +void Rubber::Delete() +// ****************** +{ + throw Error("Abnormal deletion of " + _TName("Rubber")); +} + +Cell* Rubber::GetCell() const +// ************************** +{ + return _net->GetCell(); +} + +Point Rubber::GetCenter() const +// **************************** +{ + return GetBoundingBox().GetCenter(); +} + +Point Rubber::GetBarycenter() const +// ******************************** +{ + int n = GetHooks().GetSize(); + Unit x = 0; + Unit y = 0; + for_each_hook(hook, GetHooks()) { + Point position = hook->GetComponent()->GetBoundingBox().GetCenter(); + x += position.GetX() / n; + y += position.GetY() / n; + end_for; + } + return Point(x,y); +} + +Box Rubber::GetBoundingBox() const +// ******************************* +{ + if (_boundingBox.IsEmpty()) + { + Rubber* rubber = const_cast(this); + Box& boundingBox = rubber->_boundingBox; + for_each_hook(hook, GetHooks()) { + Point position = hook->GetComponent()->GetBoundingBox().GetCenter(); + boundingBox.Merge(position); + end_for; + } + } + return _boundingBox; +} + +Hooks Rubber::GetHooks() const +// *************************** +{ + return (_hook) ? _hook->GetHooks().GetSubSet(Hook::GetIsMasterFilter()) : Hooks(); +} + +void Rubber::Materialize() +// *********************** +{ + if (!IsMaterialized()) { + Cell* cell = GetCell(); + QuadTree* quadTree = cell->_GetQuadTree(); + quadTree->Insert(this); + cell->_Fit(quadTree->GetBoundingBox()); + } +} + +void Rubber::Unmaterialize() +// ************************* +{ + if (IsMaterialized()) { + Cell* cell = GetCell(); + cell->_Unfit(GetBoundingBox()); + cell->_GetQuadTree()->Remove(this); + } +} + +void Rubber::Translate(const Unit& dx, const Unit& dy) +// *************************************************** +{ +} + +Rubber* Rubber::_Create(Hook* hook) +// ******************************** +{ + if (!hook) + throw Error("Can't create " + _TName("Rubber") + " : null hook"); + + if (!hook->IsMaster()) + throw Error("Can't create " + _TName("Rubber") + " : not a master hook"); + + Net* net = hook->GetComponent()->GetNet(); + + if (!net) + throw Error("Can't create " + _TName("Rubber") + " : unconnected component"); + + Rubber* rubber = new Rubber(net, hook); + + rubber->_PostCreate(); + + return rubber; +} + +void Rubber::_PostCreate() +// *********************** +{ + _net->_GetRubberSet()._Insert(this); + + for_each_hook(hook, GetHooks()) { + hook->GetComponent()->_SetRubber(this); + end_for; + } + + Inherit::_PostCreate(); +} + +void Rubber::_Delete() +// ******************* +{ + _PreDelete(); + + delete this; +} + +void Rubber::_PreDelete() +// ********************** +{ +// trace << "entering Rubber::_PreDelete: " << this << endl; +// trace_in(); + + Inherit::_PreDelete(); + + _count = (unsigned)-1; // to avoid a new destruction + + for_each_hook(hook, GetHooks()) { + hook->GetComponent()->_SetRubber(NULL); + end_for; + } + + _net->_GetRubberSet()._Remove(this); + +// trace << "exiting Rubber::_PreDelete:" << endl; +// trace_out(); +} + +string Rubber::_GetString() const +// ****************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_net->GetName())); + s.insert(s.length() - 1, " " + GetString(_count)); + return s; +} + +Record* Rubber::_GetRecord() const +// ************************* +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Net", _net)); + record->Add(GetSlot("Hook", _hook)); + record->Add(GetSlot("Count", _count)); + record->Add(GetSlot("BoundingBox", _boundingBox)); + } + return record; +} + +void Rubber::_SetNet(Net* net) +// *************************** +{ + if (net != _net) { + if (_net) _net->_GetRubberSet()._Remove(this); + _net = net; + if (_net) _net->_GetRubberSet()._Insert(this); + } +} + +void Rubber::_SetHook(Hook* hook) +// ****************************** +{ + assert(hook->IsMaster()); + assert(hook->GetComponent()->GetNet() == GetNet()); + _hook = hook; +} + +void Rubber::_Capture() +// ******************** +{ + Invalidate(); + _count++; +} + +void Rubber::_Release() +// ******************** +{ + if (_count != ((unsigned)-1)) { // not in deletion + Invalidate(); + if ((--_count) == 1) _Delete(); + } +} + +void Rubber::Invalidate(bool propagateFlag) +// **************************************** +{ + Inherit::Invalidate(false); + _boundingBox.MakeEmpty(); +} + +//bool Rubber::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +//// ************************************************************************************** +//{ +// double x = GetValue(point.GetX()); +// double y = GetValue(point.GetY()); +// double a = GetValue(aperture); +// Point origin; +// +// switch (view->GetRubberDisplayType()) +// { +// case View::RubberDisplayType::GEOMETRIC: +// { +// origin = GetCenter(); +// break; +// } +// case View::RubberDisplayType::BARYCENTRIC: +// { +// origin = GetBarycenter(); +// break; +// } +// case View::RubberDisplayType::STEINER: +// { +// // XXX +// return false; +// break; +// } +// default: +// throw Error("Unknown RubberDisplayType"); +// } +// double xo = GetValue(origin.GetX()); +// double yo = GetValue(origin.GetY()); +// for_each_hook(hook, GetHooks()) { +// Point extremity = extremity = hook->GetComponent()->GetBoundingBox().GetCenter(); +// double xe = GetValue(extremity.GetX()); +// double ye = GetValue(extremity.GetY()); +// double xp = xo; +// double yp = yo; +// if (xo != xe) xp = (((xe - xo) / (ye - yo)) * (y - yo)) + xo; +// if (yo != ye) yp = (((ye - yo) / (xe - xo)) * (x - xo)) + yo; +// if ((abs(xp - x) <= a) || (abs(yp - y) <= a)) return true; +// end_for; +// } +// return false; +//} +// +// +//void Rubber::_Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) +//// **************************************************************************************************************** +//{ +// assert(!basicLayer); +// +// Point center; +// +// switch (view->GetRubberDisplayType()) +// { +// case View::RubberDisplayType::GEOMETRIC: +// { +// center = transformation.GetPoint(GetCenter()); +// for_each_hook(hook, GetHooks()) { +// Point position = hook->GetComponent()->GetBoundingBox().GetCenter(); +// view->DrawLine(center, transformation.GetPoint(position)); +// end_for; +// } +// break; +// } +// case View::RubberDisplayType::BARYCENTRIC: +// { +// center = transformation.GetPoint(GetBarycenter()); +// for_each_hook(hook, GetHooks()) { +// Point position = hook->GetComponent()->GetBoundingBox().GetCenter(); +// view->DrawLine(center, transformation.GetPoint(position)); +// end_for; +// } +// break; +// } +// case View::RubberDisplayType::STEINER: +// { +// center = transformation.GetPoint(GetBarycenter()); +// for_each_hook(hook, GetHooks()) { +// Point position = hook->GetComponent()->GetBoundingBox().GetCenter(); +// Point crosspoint (position.GetX(), center.GetY()); +// view->DrawLine(position, crosspoint); +// view->DrawLine(crosspoint, center); +// end_for; +// } +// +// break; +// } +// default: +// throw Error("Unknown RubberDisplayType"); +// } +// +//} +// +typedef struct pcmp_s { + bool operator() (const Point& p1, const Point& p2) const { + return (p1.GetX() < p2.GetX()) || ( (p1.GetX() == p2.GetX()) && (p1.GetY() < p2.GetY()) ); + } +} pcmp_t; + +//void Rubber::_Highlight(View* view, const Box& updateArea, const Transformation& transformation) +//// ********************************************************************************************** +//{ +// Point center; +// +// switch (view->GetRubberDisplayType()) +// { +// case View::RubberDisplayType::GEOMETRIC: +// { +// center = transformation.GetPoint(GetCenter()); +// for_each_hook(hook, GetHooks()) { +// Point position = hook->GetComponent()->GetBoundingBox().GetCenter(); +// view->DrawLine(center, transformation.GetPoint(position)); +// end_for; +// } +// break; +// } +// case View::RubberDisplayType::BARYCENTRIC: +// { +// center = transformation.GetPoint(GetBarycenter()); +// for_each_hook(hook, GetHooks()) { +// Point position = hook->GetComponent()->GetBoundingBox().GetCenter(); +// view->DrawLine(center, transformation.GetPoint(position)); +// end_for; +// } +// break; +// } +// case View::RubberDisplayType::STEINER: +// { +// set pset; +// for_each_hook (hook, GetHooks()) +// { +// Point position = hook->GetComponent()->GetBoundingBox().GetCenter(); +// pset.insert (position); +// end_for; +// } +// center = transformation.GetPoint(GetBarycenter()); +// Unit lastXup = center.GetX(); +// Unit lastXlo = center.GetX(); +// for ( +// set::iterator pit = pset.begin(); +// pit != pset.end(); +// pit++ +// ) +// { +// Point position (*pit); +// Point crosspoint (position.GetX(), center.GetY()); +// Point connxpoint (center); +// if (position.GetY() > center.GetY()) +// { +// // en haut +// if ( (position.GetX() - lastXup) < (position.GetY() - center.GetY()) ) +// { +// crosspoint.SetX (lastXup); +// crosspoint.SetY (position.GetY()); +// connxpoint.SetX (lastXup); +// } +// else +// lastXup = position.GetX(); +// } else { +// // en bas +// if ( (position.GetX() - lastXlo) < (center.GetY() - position.GetY()) ) +// { +// crosspoint.SetX (lastXlo); +// crosspoint.SetY (position.GetY()); +// connxpoint.SetX (lastXlo); +// } +// else +// lastXlo = position.GetX(); +// } +// +// +// view->DrawLine(position, crosspoint); +// view->DrawLine(crosspoint, connxpoint); +// } +// break; +// } +// default: +// throw Error("Unknown RubberDisplayType"); +// } +// +//} +// + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Rubber.h b/hurricane/src/hurricane/Rubber.h new file mode 100644 index 00000000..068b9f46 --- /dev/null +++ b/hurricane/src/hurricane/Rubber.h @@ -0,0 +1,109 @@ +// **************************************************************************************************** +// File: Rubber.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_RUBBER +#define HURRICANE_RUBBER + +#include "Go.h" +#include "Hooks.h" +#include "Rubbers.h" + +namespace Hurricane { + +class Net; + + + +// **************************************************************************************************** +// Rubber declaration +// **************************************************************************************************** + +class Rubber : public Go { +// ********************* + +// Types +// ***** + + public: typedef Go Inherit; + + +// Attributes +// ********** + + private: Net* _net; + private: Hook* _hook; + private: unsigned _count; + private: Box _boundingBox; + private: Rubber* _nextOfNetRubberSet; + +// Constructors +// ************ + + protected: Rubber(Net* net, Hook* hook); + +// Destructor +// ********** + + public: virtual void Delete(); + +// Accessors +// ********* + + public: virtual Cell* GetCell() const; + public: Net* GetNet() const {return _net;}; + public: Hook* GetHook() const {return _hook;}; + public: unsigned GetCount() const {return _count;}; + public: Point GetCenter() const; + public: Point GetBarycenter() const; + public: virtual Box GetBoundingBox() const; + public: Hooks GetHooks() const; + +// Updators +// ******** + + public: virtual void Materialize(); + public: virtual void Unmaterialize(); + public: virtual void Translate(const Unit& dx, const Unit& dy); + public: virtual void Invalidate(bool propagateFlag = true); + +// Others +// ****** + + public: static Rubber* _Create(Hook* hook); + protected: virtual void _PostCreate(); + + public: void _Delete(); + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("Rubber");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: Rubber* _GetNextOfNetRubberSet() const {return _nextOfNetRubberSet;}; + + public: void _SetNet(Net* net); + public: void _SetHook(Hook* hook); + public: void _SetNextOfNetRubberSet(Rubber* rubber) {_nextOfNetRubberSet = rubber;}; + + public: void _Capture(); + public: void _Release(); + + //public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; + //public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation); + //public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Rubber) + +#endif // HURRICANE_RUBBER + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Rubbers.h b/hurricane/src/hurricane/Rubbers.h new file mode 100644 index 00000000..40d87cc8 --- /dev/null +++ b/hurricane/src/hurricane/Rubbers.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Rubbers.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_RUBBERS +#define HURRICANE_RUBBERS + +#include "Collection.h" + +namespace Hurricane { + +class Rubber; + + + +// **************************************************************************************************** +// Rubbers declaration +// **************************************************************************************************** + +typedef GenericCollection Rubbers; + + + +// **************************************************************************************************** +// RubberLocator declaration +// **************************************************************************************************** + +typedef GenericLocator RubberLocator; + + + +// **************************************************************************************************** +// RubberFilter declaration +// **************************************************************************************************** + +typedef GenericFilter RubberFilter; + + + +// **************************************************************************************************** +// for_each_rubber declaration +// **************************************************************************************************** + +#define for_each_rubber(rubber, rubbers)\ +/***************************************/\ +{\ + RubberLocator _locator = rubbers.GetLocator();\ + while (_locator.IsValid()) {\ + Rubber* rubber = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_RUBBERS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Segment.cpp b/hurricane/src/hurricane/Segment.cpp new file mode 100644 index 00000000..0c36d7bd --- /dev/null +++ b/hurricane/src/hurricane/Segment.cpp @@ -0,0 +1,706 @@ +// **************************************************************************************************** +// File: Segment.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment BULL-LIP6 + +#include "Segment.h" +#include "BasicLayer.h" +#include "CompositeLayer.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Segment_Hooks declaration +// **************************************************************************************************** + +class Segment_Hooks : public Collection { +// ******************************************* + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ***************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Segment* _segment; + private: Hook* _hook; + + public: Locator(const Segment* segment = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Hook* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Segment* _segment; + +// Constructors +// ************ + + public: Segment_Hooks(const Segment* segment = NULL); + public: Segment_Hooks(const Segment_Hooks& hooks); + +// Operators +// ********* + + public: Segment_Hooks& operator=(const Segment_Hooks& hooks); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Segment_Anchors declaration +// **************************************************************************************************** + +class Segment_Anchors : public Collection { +// ************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Segment* _segment; + private: Component* _anchor; + + public: Locator(const Segment* segment = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Component* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Segment* _segment; + +// Constructors +// ************ + + public: Segment_Anchors(const Segment* segment = NULL); + public: Segment_Anchors(const Segment_Anchors& anchors); + +// Operators +// ********* + + public: Segment_Anchors& operator=(const Segment_Anchors& anchors); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Segment implementation +// **************************************************************************************************** + +Segment::Segment(Net* net, Component* source, Component* target, Layer* layer, const Unit& width) +// ********************************************************************************************** +: Inherit(net), + _sourceHook(this), + _targetHook(this), + _layer(layer), + _width(width) +{ + if (source) { + if (!source->GetNet()) + throw Error("Can't create " + _TName("Segment") + " : unconnected source"); + if (source->GetNet() != net) + throw Error("Can't create " + _TName("Segment") + " : incompatible source"); + } + + if (target) { + if (!target->GetNet()) + throw Error("Can't create " + _TName("Segment") + " : unconnected target"); + if (target->GetNet() != net) + throw Error("Can't create " + _TName("Segment") + " : incompatible target"); + } + + if (!_layer) + throw Error("Can't create " + _TName("Segment") + " : null layer"); + + if (source) _sourceHook.Attach(source->GetBodyHook()); + if (target) _targetHook.Attach(target->GetBodyHook()); +} + +Hooks Segment::GetHooks() const +// **************************** +{ + return Segment_Hooks(this); +} + +Hook* Segment::GetOppositeHook(const Hook* hook) const +// *************************************************** +{ + if (hook) { + if (hook == &_sourceHook) return (Hook*)&_targetHook; + if (hook == &_targetHook) return (Hook*)&_sourceHook; + } + return NULL; +} + +Component* Segment::GetSource() const +// ********************************** +{ + Hook* masterHook = _sourceHook.GetMasterHook(); + return (masterHook) ? masterHook->GetComponent() : NULL; +} + +Component* Segment::GetTarget() const +// ********************************** +{ + Hook* masterHook = _targetHook.GetMasterHook(); + return (masterHook) ? masterHook->GetComponent() : NULL; +} + +Components Segment::GetAnchors() const +// *********************************** +{ + return Segment_Anchors(this); +} + +Component* Segment::GetOppositeAnchor(Component* anchor) const +// *********************************************************** +{ + if (anchor) { + Component* source = GetSource(); + Component* target = GetTarget(); + if (anchor == source) return target; + if (anchor == target) return source; + } + return NULL; +} + +Point Segment::GetSourcePosition() const +// ************************************* +{ + return Point(GetSourceX(), GetSourceY()); +} + +Point Segment::GetTargetPosition() const +// ************************************* +{ + return Point(GetTargetX(), GetTargetY()); +} + +void Segment::SetLayer(Layer* layer) +// ********************************* +{ + if (!layer) + throw Error("Can't set layer : null layer"); + + if (layer != _layer) { + Invalidate(false); + _layer = layer; + } +} + +void Segment::SetWidth(const Unit& width) +// ************************************** +{ + if (width != _width) { + Invalidate(false); + _width = width; + } +} + +void Segment::Invert() +// ******************* +{ + Component* source = GetSource(); + Component* target = GetTarget(); + if (source && target && (target != source)) { + GetSourceHook()->Detach(); + GetTargetHook()->Detach(); + GetSourceHook()->Attach(target->GetBodyHook()); + GetTargetHook()->Attach(source->GetBodyHook()); + } +} + +void Segment::_PreDelete() +// *********************** +{ +// trace << "entering Segment::_PreDelete: " << this << endl; +// trace_in(); + + Inherit::_PreDelete(); + + _sourceHook.Detach(); + _targetHook.Detach(); + +// trace << "exiting Segment::_PreDelete:" << endl; +// trace_out(); +} + +string Segment::_GetString() const +// ******************************* +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_layer->GetName())); + s.insert(s.length() - 1, " [" + GetValueString(GetSourceX()) + " " + GetValueString(GetSourceY()) + "]"); + s.insert(s.length() - 1, " [" + GetValueString(GetTargetX()) + " " + GetValueString(GetTargetY()) + "]"); + s.insert(s.length() - 1, " " + GetValueString(_width)); + return s; +} + +Record* Segment::_GetRecord() const +// ************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("SourceHook", &_sourceHook)); + record->Add(GetSlot("Source", GetSource())); + record->Add(GetSlot("TargetHook", &_targetHook)); + record->Add(GetSlot("Target", GetTarget())); + record->Add(GetSlot("Layer", _layer)); + record->Add(GetSlot("Width", &_width)); + } + return record; +} + +Unit Segment::_GetSize() const +// *************************** +{ + Unit size = 0; + + Layer* layer = GetLayer(); + if (is_a(layer)) + size = ((CompositeLayer*)layer)->GetMaximalSegmentSize(); + + return size; +} + +Unit Segment::_GetExtention() const +// ******************************** +{ + Unit extention = 0; + + Layer* layer = GetLayer(); + if (is_a(layer)) + extention = ((CompositeLayer*)layer)->GetMaximalSegmentExtention(); + + return extention; +} + +Unit Segment::_GetSize(BasicLayer* basicLayer) const +// ************************************************* +{ + Layer* layer = GetLayer(); + + if (!layer->Contains(basicLayer)) return 0; + + Unit size = 0; + + if (is_a(layer)) + size = ((CompositeLayer*)layer)->GetSegmentSize(basicLayer); + + return size; +} + +Unit Segment::_GetExtention(BasicLayer* basicLayer) const +// ****************************************************** +{ + Layer* layer = GetLayer(); + + if (!layer->Contains(basicLayer)) return 0; + + Unit extention = 0; + + if (is_a(layer)) + extention = ((CompositeLayer*)layer)->GetSegmentExtention(basicLayer); + + return extention; +} + +//bool Segment::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +//// *************************************************************************************** +//{ +// Box area(point); +// area.Inflate(aperture); +// Layer* layer = GetLayer(); +// for_each_basic_layer(basicLayer, layer->GetBasicLayers()) { +// if (view->IsVisible(basicLayer)) +// if (GetBoundingBox(basicLayer).Intersect(area)) return true; +// end_for; +// } +// +// return false; +//} +// + +//void Segment::_Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) +//// **************************************************************************************************** +//{ +// if (1 < view->GetScreenSize(GetWidth())) +// basicLayer->_Fill(view, transformation.GetBox(GetBoundingBox(basicLayer))); +// else +// if (basicLayer == GetLayer()->_GetSymbolicBasicLayer()) +// view->DrawLine(transformation.GetPoint(GetSourcePosition()), +// transformation.GetPoint(GetTargetPosition())); +//} +// + +// **************************************************************************************************** +// Segment::SourceHook implementation +// **************************************************************************************************** + +static int SOURCE_HOOK_OFFSET = -1; + +Segment::SourceHook::SourceHook(Segment* segment) +// ********************************************** +: Inherit() +{ + if (!segment) + throw Error("Can't create " + _TName("Segment::SourceHook") + " (null segment)"); + + if (SOURCE_HOOK_OFFSET == -1) + SOURCE_HOOK_OFFSET = (unsigned long)this - (unsigned long)segment; +} + +Component* Segment::SourceHook::GetComponent() const +// ************************************************* +{ + return (Component*)((unsigned long)this - SOURCE_HOOK_OFFSET); +} + +string Segment::SourceHook::_GetString() const +// ******************************************* +{ + return "<" + _TName("Segment::SourceHook") + " " + GetString(GetComponent()) + ">"; +} + + + +// **************************************************************************************************** +// Segment::TargetHook implementation +// **************************************************************************************************** + +static int TARGET_HOOK_OFFSET = -1; + +Segment::TargetHook::TargetHook(Segment* segment) +// ********************************************** +: Inherit() +{ + if (!segment) + throw Error("Can't create " + _TName("Segment::TargetHook") + " (null segment)"); + + if (TARGET_HOOK_OFFSET == -1) + TARGET_HOOK_OFFSET = (unsigned long)this - (unsigned long)segment; +} + +Component* Segment::TargetHook::GetComponent() const +// ************************************************* +{ + return (Component*)((unsigned long)this - TARGET_HOOK_OFFSET); +} + +string Segment::TargetHook::_GetString() const +// ******************************************* +{ + return "<" + _TName("Segment::TargetHook") + " " + GetString(GetComponent()) + ">"; +} + +// **************************************************************************************************** +// Segment_Hooks implementation +// **************************************************************************************************** + +Segment_Hooks::Segment_Hooks(const Segment* segment) +// ************************************************* +: Inherit(), + _segment(segment) +{ +} + +Segment_Hooks::Segment_Hooks(const Segment_Hooks& hooks) +// ***************************************************** +: Inherit(), + _segment(hooks._segment) +{ +} + +Segment_Hooks& Segment_Hooks::operator=(const Segment_Hooks& hooks) +// **************************************************************** +{ + _segment = hooks._segment; + return *this; +} + +Collection* Segment_Hooks::GetClone() const +// *********************************************** +{ + return new Segment_Hooks(*this); +} + +Locator* Segment_Hooks::GetLocator() const +// ********************************************** +{ + return new Locator(_segment); +} + +string Segment_Hooks::_GetString() const +// ************************************* +{ + string s = "<" + _TName("Segment::Hooks"); + if (_segment) s += " " + GetString(_segment); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Segment_Hooks::Locator implementation +// **************************************************************************************************** + +Segment_Hooks::Locator::Locator(const Segment* segment) +// **************************************************** +: Inherit(), + _segment(segment), + _hook(NULL) +{ + if (_segment) _hook = ((Segment*)_segment)->GetBodyHook(); +} + +Segment_Hooks::Locator::Locator(const Locator& locator) +// **************************************************** +: Inherit(), + _segment(locator._segment), + _hook(locator._hook) +{ +} + +Segment_Hooks::Locator& Segment_Hooks::Locator::operator=(const Locator& locator) +// ****************************************************************************** +{ + _segment = locator._segment; + _hook = locator._hook; + return *this; +} + +Hook* Segment_Hooks::Locator::GetElement() const +// ********************************************* +{ + return _hook; +} + +Locator* Segment_Hooks::Locator::GetClone() const +// ***************************************************** +{ + return new Locator(*this); +} + +bool Segment_Hooks::Locator::IsValid() const +// ***************************************** +{ + return (_hook != NULL); +} + +void Segment_Hooks::Locator::Progress() +// ************************************ +{ + if (_hook) { + if (_hook == ((Segment*)_segment)->GetBodyHook()) + _hook = ((Segment*)_segment)->GetSourceHook(); + else { + if (_hook == ((Segment*)_segment)->GetSourceHook()) + _hook = ((Segment*)_segment)->GetTargetHook(); + else + _hook = NULL; + } + } +} + +string Segment_Hooks::Locator::_GetString() const +// ********************************************** +{ + string s = "<" + _TName("Segment::Hooks::Locator"); + if (_segment) s += " " + GetString(_segment); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Segment_Anchors implementation +// **************************************************************************************************** + +Segment_Anchors::Segment_Anchors(const Segment* segment) +// ***************************************************** +: Inherit(), + _segment(segment) +{ +} + +Segment_Anchors::Segment_Anchors(const Segment_Anchors& hooks) +// *********************************************************** +: Inherit(), + _segment(hooks._segment) +{ +} + +Segment_Anchors& Segment_Anchors::operator=(const Segment_Anchors& hooks) +// ********************************************************************** +{ + _segment = hooks._segment; + return *this; +} + +Collection* Segment_Anchors::GetClone() const +// ****************************************************** +{ + return new Segment_Anchors(*this); +} + +Locator* Segment_Anchors::GetLocator() const +// ***************************************************** +{ + return new Locator(_segment); +} + +string Segment_Anchors::_GetString() const +// *************************************** +{ + string s = "<" + _TName("Segment::Anchors"); + if (_segment) s += " " + GetString(_segment); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Segment_Anchors::Locator implementation +// **************************************************************************************************** + +Segment_Anchors::Locator::Locator(const Segment* segment) +// ****************************************************** +: Inherit(), + _segment(segment), + _anchor(NULL) +{ + if (_segment) { + _anchor = ((Segment*)_segment)->GetSource(); + if (!_anchor) _anchor = ((Segment*)_segment)->GetTarget(); + } +} + +Segment_Anchors::Locator::Locator(const Locator& locator) +// ****************************************************** +: Inherit(), + _segment(locator._segment), + _anchor(locator._anchor) +{ +} + +Segment_Anchors::Locator& Segment_Anchors::Locator::operator=(const Locator& locator) +// ********************************************************************************** +{ + _segment = locator._segment; + _anchor = locator._anchor; + return *this; +} + +Component* Segment_Anchors::Locator::GetElement() const +// **************************************************** +{ + return _anchor; +} + +Locator* Segment_Anchors::Locator::GetClone() const +// ************************************************************ +{ + return new Locator(*this); +} + +bool Segment_Anchors::Locator::IsValid() const +// ******************************************* +{ + return (_anchor != NULL); +} + +void Segment_Anchors::Locator::Progress() +// ************************************** +{ + if (_anchor) { + if (_anchor == ((Segment*)_segment)->GetTarget()) + _anchor = NULL; + else + _anchor = ((Segment*)_segment)->GetTarget(); + } +} + +string Segment_Anchors::Locator::_GetString() const +// ************************************************ +{ + string s = "<" + _TName("Segment::Anchors::Locator"); + if (_segment) s += " " + GetString(_segment); + s += ">"; + return s; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Segment.h b/hurricane/src/hurricane/Segment.h new file mode 100644 index 00000000..5f65f5a4 --- /dev/null +++ b/hurricane/src/hurricane/Segment.h @@ -0,0 +1,137 @@ +// **************************************************************************************************** +// File: Segment.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_SEGMENT +#define HURRICANE_SEGMENT + +#include "Component.h" +#include "Segments.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Segment declaration +// **************************************************************************************************** + +class Segment : public Component { +// ***************************** + +// Types +// ***** + + public: typedef Component Inherit; + + public: class SourceHook : public Hook { + // *********************************** + + friend class Segment; + + public: typedef Hook Inherit; + + private: SourceHook(Segment* segment); + + public: virtual Component* GetComponent() const; + + public: virtual bool IsMaster() const {return false;}; + + public: virtual string _GetTypeName() const { return _TName("Segment::SourceHook"); }; + public: virtual string _GetString() const; + }; + + public: class TargetHook : public Hook { + // *********************************** + + friend class Segment; + + public: typedef Hook Inherit; + + private: TargetHook(Segment* segment); + + public: virtual Component* GetComponent() const; + + public: virtual bool IsMaster() const {return false;}; + + public: virtual string _GetTypeName() const { return _TName("Segment::TargetHook"); }; + public: virtual string _GetString() const; + }; + +// Attributes +// ********** + + private: SourceHook _sourceHook; + private: TargetHook _targetHook; + private: Layer* _layer; + private: Unit _width; + +// Constructors +// ************ + + protected: Segment(Net* net, Component* source, Component* target, Layer* layer, const Unit& width = 0); + +// Accessors +// ********* + + public: virtual Hooks GetHooks() const; + public: virtual Unit GetX() const {return 0;}; + public: virtual Unit GetY() const {return 0;}; + public: virtual Layer* GetLayer() const {return _layer;}; + public: Hook* GetSourceHook() {return &_sourceHook;}; + public: Hook* GetTargetHook() {return &_targetHook;}; + public: Hook* GetOppositeHook(const Hook* hook) const; + public: Component* GetSource() const; + public: Component* GetTarget() const; + public: Components GetAnchors() const; + public: Component* GetOppositeAnchor(Component* anchor) const; + public: const Unit& GetWidth() const {return _width;}; + public: Unit GetHalfWidth() const {return (_width / 2);}; + public: virtual Unit GetSourceX() const = 0; + public: virtual Unit GetSourceY() const = 0; + public: virtual Point GetSourcePosition() const; + public: virtual Unit GetTargetX() const = 0; + public: virtual Unit GetTargetY() const = 0; + public: virtual Point GetTargetPosition() const; + public: virtual Unit GetLength() const = 0; + +// Updators +// ******** + + public: void SetLayer(Layer* layer); + public: void SetWidth(const Unit& width); + public: void Invert(); + +// Others +// ****** + + protected: virtual void _PreDelete(); + + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: Unit _GetSize() const; + public: Unit _GetExtention() const; + public: Unit _GetSize(BasicLayer* basicLayer) const; + public: Unit _GetExtention(BasicLayer* basicLayer) const; + +// public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; +// public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Segment) +SetNestedSlotAdapter(Hurricane::Segment::SourceHook) +SetNestedSlotAdapter(Hurricane::Segment::TargetHook) + +#endif // HURRICANE_SEGMENT + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Segments.h b/hurricane/src/hurricane/Segments.h new file mode 100644 index 00000000..c68a3cca --- /dev/null +++ b/hurricane/src/hurricane/Segments.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Segments.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_SEGMENTS +#define HURRICANE_SEGMENTS + +#include "Collection.h" + +namespace Hurricane { + +class Segment; + + + +// **************************************************************************************************** +// Segments declaration +// **************************************************************************************************** + +typedef GenericCollection Segments; + + + +// **************************************************************************************************** +// SegmentLocator declaration +// **************************************************************************************************** + +typedef GenericLocator SegmentLocator; + + + +// **************************************************************************************************** +// SegmentFilter declaration +// **************************************************************************************************** + +typedef GenericFilter SegmentFilter; + + + +// **************************************************************************************************** +// for_each_segment declaration +// **************************************************************************************************** + +#define for_each_segment(segment, segments)\ +/******************************************/\ +{\ + SegmentLocator _locator = segments.GetLocator();\ + while (_locator.IsValid()) {\ + Segment* segment = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_SEGMENTS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Selectors.h b/hurricane/src/hurricane/Selectors.h new file mode 100644 index 00000000..a20ccfbc --- /dev/null +++ b/hurricane/src/hurricane/Selectors.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Selectors.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_SELECTORS +#define HURRICANE_SELECTORS + +#include "Collection.h" + +namespace Hurricane { + +class Selector; + + + +// **************************************************************************************************** +// Selectors declaration +// **************************************************************************************************** + +typedef GenericCollection Selectors; + + + +// **************************************************************************************************** +// SelectorLocator declaration +// **************************************************************************************************** + +typedef GenericLocator SelectorLocator; + + + +// **************************************************************************************************** +// SelectorFilter declaration +// **************************************************************************************************** + +typedef GenericFilter SelectorFilter; + + + +// **************************************************************************************************** +// for_each_selector declaration +// **************************************************************************************************** + +#define for_each_selector(selector, selectors)\ +/*********************************************/\ +{\ + SelectorLocator _locator = selectors.GetLocator();\ + while (_locator.IsValid()) {\ + Selector* selector = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_SELECTORS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/SetCollection.h b/hurricane/src/hurricane/SetCollection.h new file mode 100644 index 00000000..4ce185de --- /dev/null +++ b/hurricane/src/hurricane/SetCollection.h @@ -0,0 +1,215 @@ +// **************************************************************************************************** +// File: SetCollection.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_SET_COLLECTION +#define HURRICANE_SET_COLLECTION + +#include "Commons.h" + +#include "Tabulation.h" +#include "Record.h" +#include "Slot.h" + + +namespace Hurricane { + + + +// **************************************************************************************************** +// SetCollection declaration +// **************************************************************************************************** + +template > + class SetCollection : public Collection { +// ************************************************ + +// Types +// ***** + + public: typedef Collection Inherit; + + public: typedef set ElementSet; + + public: class Locator : public Hurricane::Locator { + // ******************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const ElementSet* _elementSet; + private: typename ElementSet::const_iterator _iterator; // AD + + public: Locator(const ElementSet* elementSet) + // ****************************************** + : Inherit(), + _elementSet(elementSet), + _iterator() + { + if (_elementSet) _iterator = _elementSet->begin(); + }; + + public: virtual Element GetElement() const + // *************************************** + { + return (IsValid()) ? *_iterator : Element(); + }; + + public: virtual Hurricane::Locator* GetClone() const + // ********************************************************** + { + return new Locator(_elementSet); + }; + + public: virtual bool IsValid() const + // ********************************* + { + return (_elementSet && (_iterator != _elementSet->end())); + }; + + public: virtual void Progress() + // **************************** + { + ++_iterator; + }; + + }; + +// Attributes +// ********** + + private: const ElementSet* _elementSet; + +// Constructors +// ************ + + public: SetCollection(const ElementSet* elementSet = NULL) + // ******************************************************* + : Inherit(), + _elementSet(elementSet) + { + }; + + public: SetCollection(const ElementSet& elementSet) + // ************************************************ + : Inherit(), + _elementSet(&elementSet) + { + }; + + public: SetCollection(const SetCollection& setCollection) + // ****************************************************** + : Inherit(), + _elementSet(setCollection._elementSet) + { + }; + +// Operators +// ********* + + public: SetCollection& operator=(const SetCollection& setCollection) + // ***************************************************************** + { + _elementSet = setCollection._elementSet; + return *this; + }; + +// Accessors +// ********* + + public: virtual Collection* GetClone() const + // ************************************************** + { + return new SetCollection(*this); + } + + public: virtual Hurricane::Locator* GetLocator() const + // ************************************************************ + { + // return (_elementSet) ? new Locator(_elementSet) : NULL; + // V3 + return (_elementSet) ? new Locator(_elementSet) : NULL; + } + + public: virtual unsigned GetSize() const + // ************************************* + { + return (_elementSet) ? _elementSet->size() : 0; + }; + +// Others +// ****** + + public: virtual string _GetTypeName() const + // ************************************** + { + return _TName("SetCollection"); + }; + + public: virtual string _GetString() const + // ************************************** + { + if (!_elementSet) + return "<" + _GetTypeName() + " unbound>"; + else { + if (_elementSet->empty()) + return "<" + _GetTypeName() + " empty>"; + else + return "<" + _GetTypeName() + " " + GetString(_elementSet->size()) + ">"; + } + }; + + Record* _GetRecord() const + // ***************** + { + Record* record = NULL; + if (!_elementSet->empty()) { + record = new Record(_GetString()); + unsigned n = 1; + typename set::const_iterator iterator = _elementSet->begin(); // AD + while (iterator != _elementSet->end()) { + record->Add(GetSlot(GetString(n++), *iterator)); + ++iterator; + } + } + return record; + } + +}; + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +template + inline GenericCollection GetCollection(const set& elementSet) +// **************************************************************************************** +{ + return SetCollection(elementSet); +} + +template + inline GenericCollection GetCollection(const set* elementSet) +// **************************************************************************************** +{ + return SetCollection(elementSet); +} + + + +} // End of Hurricane namespace. + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +#endif // HURRICANE_SET_COLLECTION + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/SharedName.cpp b/hurricane/src/hurricane/SharedName.cpp new file mode 100644 index 00000000..0b5d7d97 --- /dev/null +++ b/hurricane/src/hurricane/SharedName.cpp @@ -0,0 +1,79 @@ +// **************************************************************************************************** +// File: SharedName.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "SharedName.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// SharedName implementation +// **************************************************************************************************** + +SharedName::SharedNameMap* SharedName::_SHARED_NAME_MAP = NULL; + +SharedName::SharedName(const string& s) +// ************************************ +: _count(0), + _string(s) +{ + if (!_SHARED_NAME_MAP) _SHARED_NAME_MAP = new SharedNameMap(); + (*_SHARED_NAME_MAP)[&_string] = this; +} + +SharedName::~SharedName() +// ********************** +{ + _SHARED_NAME_MAP->erase(&_string); +} + +void SharedName::Capture() +// *********************** +{ + _count++; +} + +void SharedName::Release() +// *********************** +{ + if (!--_count) delete this; +} + +string SharedName::_GetString() const +// ********************************** +{ + return "<" + _TName("SharedName") + " " + GetString(_count) + " " + _string + ">"; +} + +Record* SharedName::_GetRecord() const +// ***************************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Count", &_count)); + record->Add(GetSlot("String", &_string)); + return record; +} + + + +// **************************************************************************************************** +// SharedName::SharedNameMapComparator +// **************************************************************************************************** + +bool SharedName::SharedNameMapComparator::operator()(string* s1, string* s2) const +// ******************************************************************************* +{ + return (*s1) < (*s2); +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/SharedName.h b/hurricane/src/hurricane/SharedName.h new file mode 100644 index 00000000..7d003c40 --- /dev/null +++ b/hurricane/src/hurricane/SharedName.h @@ -0,0 +1,91 @@ +// **************************************************************************************************** +// File: SharedName.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_SHARED_NAME +#define HURRICANE_SHARED_NAME + +#include "Commons.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// SharedName declaration +// **************************************************************************************************** + +class SharedName { +// ************* + +// Friends +// ******* + + friend class Name; + +// Types +// ***** + + private: struct SharedNameMapComparator { + // ************************************ + + bool operator()(string* s1, string* s2) const; + + }; + + private: typedef map SharedNameMap; + +// Attributes +// ********** + + private: static SharedNameMap* _SHARED_NAME_MAP; + + private: int _count; + private: string _string; + +// Constructors +// ************ + + private: SharedName(const string& s); + + private: SharedName(const SharedName& sharedName); + // not implemented to forbid copy construction + +// Destructor +// ********** + + private: ~SharedName(); + +// Operators +// ********* + + private: SharedName& operator=(const SharedName& sharedName); + // not implemented to forbid assignment + +// Updators +// ******** + + private: void Capture(); + private: void Release(); + +// Others +// ****** + + public: const string &_GetSString () const { return _string; }; + public: string _GetTypeName() const { return _TName("SharedName"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + +}; + + +} // End of Hurricane namespace. + + +#endif // HURRICANE_SHARED_NAME + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/SharedPath.cpp b/hurricane/src/hurricane/SharedPath.cpp new file mode 100644 index 00000000..32a48f09 --- /dev/null +++ b/hurricane/src/hurricane/SharedPath.cpp @@ -0,0 +1,372 @@ +// **************************************************************************************************** +// File: SharedPath.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "SharedPath.h" +#include "Instance.h" +#include "Cell.h" +#include "Quark.h" +#include "Error.h" + +namespace Hurricane { + + +// **************************************************************************************************** +// SharedPath_Instances declaration +// **************************************************************************************************** + +class SharedPath_Instances : public Collection { +// ****************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ********************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const SharedPath* _sharedPath; + + public: Locator(const SharedPath* sharedPath = NULL); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual Instance* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + }; + +// Attributes +// ********** + + private: const SharedPath* _sharedPath; + +// Constructors +// ************ + + public: SharedPath_Instances(const SharedPath* sharedPath = NULL); + public: SharedPath_Instances(const SharedPath_Instances& instances); + +// Operators +// ********* + + public: SharedPath_Instances& operator=(const SharedPath_Instances& instances); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// SharedPath implementation +// **************************************************************************************************** + +static char NAME_SEPARATOR = '.'; + +SharedPath::SharedPath(Instance* headInstance, SharedPath* tailSharedPath) +// *********************************************************************** +: _headInstance(headInstance), + _tailSharedPath(tailSharedPath), + _quarkMap(), + _nextOfInstanceSharedPathMap(NULL) +{ + if (!_headInstance) + throw Error("Can't create " + _TName("SharedPath") + " : null head instance"); + + if (_headInstance->_GetSharedPath(_tailSharedPath)) + throw Error("Can't create " + _TName("SharedPath") + " : already exists"); + + if (_tailSharedPath && (_tailSharedPath->GetOwnerCell() != _headInstance->GetMasterCell())) + throw Error("Can't create " + _TName("SharedPath") + " : incompatible tail path"); + + _headInstance->_GetSharedPathMap()._Insert(this); +} + +SharedPath::~SharedPath() +// ********************** +{ + for_each_quark(quark, _GetQuarks()) quark->Delete(); end_for; + + Cell* cell = _headInstance->GetCell(); + for_each_instance(instance, cell->GetSlaveInstances()) { + SharedPath* sharedPath = instance->_GetSharedPath(this); + if (sharedPath) delete sharedPath; + end_for; + } + _headInstance->_GetSharedPathMap()._Remove(this); +} + +SharedPath* SharedPath::GetHeadSharedPath() const +// ********************************************** +{ + if (!_tailSharedPath) return NULL; + + SharedPath* tailSharedPath = _tailSharedPath->GetHeadSharedPath(); + + SharedPath* headSharedPath = _headInstance->_GetSharedPath(tailSharedPath); + + if (!headSharedPath) headSharedPath = new SharedPath(_headInstance, tailSharedPath); + + return headSharedPath; +} + +Instance* SharedPath::GetTailInstance() const +// ****************************************** +{ + return (_tailSharedPath) ? _tailSharedPath->GetTailInstance() : _headInstance; +} + +char SharedPath::GetNameSeparator() +// ******************************** +{ + return NAME_SEPARATOR; +} + +string SharedPath::GetName() const +// ******************************* +{ + string name = ""; + string nameSeparator = ""; + SharedPath* sharedPath = (SharedPath*)this; + while (sharedPath) { + name += nameSeparator + GetString(sharedPath->GetHeadInstance()->GetName()); + nameSeparator = GetString(GetNameSeparator()); + sharedPath = sharedPath->GetTailSharedPath(); + } + return name; +} + +Cell* SharedPath::GetOwnerCell() const +// *********************************** +{ + return _headInstance->GetCell(); +} + +Cell* SharedPath::GetMasterCell() const +// ************************************ +{ + Cell* masterCell = NULL; + SharedPath* sharedPath = (SharedPath*)this; + while (sharedPath) { + masterCell = sharedPath->GetHeadInstance()->GetMasterCell(); + sharedPath = sharedPath->GetTailSharedPath(); + } + return masterCell; +} + +Instances SharedPath::GetInstances() const +// *************************************** +{ + return SharedPath_Instances(this); +} + +Transformation SharedPath::GetTransformation(const Transformation& transformation) const +// ************************************************************************************* +{ + Transformation headTransformation = _headInstance->GetTransformation(); + Transformation tailTransformation = + (!_tailSharedPath) ? transformation : _tailSharedPath->GetTransformation(transformation); + return headTransformation.GetTransformation(tailTransformation); +} + +void SharedPath::SetNameSeparator(char nameSeparator) +// ************************************************** +{ + NAME_SEPARATOR = nameSeparator; +} + +string SharedPath::_GetString() const +// ********************************** +{ + string s = "<" + _TName("SharedPath"); + string name = GetName(); + if (!name.empty()) s += " " + name; + s += ">"; + return s; +} + +Record* SharedPath::_GetRecord() const +// ***************************** +{ + Record* record = new Record(GetString(this)); + if (record) { + record->Add(GetSlot("HeadInstance", _headInstance)); + record->Add(GetSlot("TailSharedPath", _tailSharedPath)); + record->Add(GetSlot("Quarks", &_quarkMap)); + } + return record; +} + + + +// **************************************************************************************************** +// SharedPath::QuarkMap implementation +// **************************************************************************************************** + +SharedPath::QuarkMap::QuarkMap() +// ***************************** +: Inherit() +{ +} + +const Entity* SharedPath::QuarkMap::_GetKey(Quark* quark) const +// ************************************************************ +{ + return quark->GetOccurrence().GetEntity(); +} + +unsigned SharedPath::QuarkMap::_GetHashValue(const Entity* entity) const +// ********************************************************************* +{ + return ( (unsigned int)( (unsigned long)entity ) ) / 8; +} + +Quark* SharedPath::QuarkMap::_GetNextElement(Quark* quark) const +// ************************************************************* +{ + return quark->_GetNextOfSharedPathQuarkMap(); +} + +void SharedPath::QuarkMap::_SetNextElement(Quark* quark, Quark* nextQuark) const +// ***************************************************************************** +{ + quark->_SetNextOfSharedPathQuarkMap(nextQuark); +} + + + +// **************************************************************************************************** +// SharedPath_Instances implementation +// **************************************************************************************************** + +SharedPath_Instances::SharedPath_Instances(const SharedPath* sharedPath) +// ********************************************************************* +: Inherit(), + _sharedPath(sharedPath) +{ +} + +SharedPath_Instances::SharedPath_Instances(const SharedPath_Instances& instances) +// ****************************************************************************** +: Inherit(), + _sharedPath(instances._sharedPath) +{ +} + +SharedPath_Instances& SharedPath_Instances::operator=(const SharedPath_Instances& instances) +// ***************************************************************************************** +{ + _sharedPath = instances._sharedPath; + return *this; +} + +Collection* SharedPath_Instances::GetClone() const +// ********************************************************** +{ + return new SharedPath_Instances(*this); +} + +Locator* SharedPath_Instances::GetLocator() const +// ********************************************************* +{ + return new Locator(_sharedPath); +} + +string SharedPath_Instances::_GetString() const +// ******************************************** +{ + string s = "<" + _TName("SharedPath::Instances"); + if (_sharedPath) s += " " + GetString(_sharedPath); + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// SharedPath_Instances::Locator implementation +// **************************************************************************************************** + +SharedPath_Instances::Locator::Locator(const SharedPath* sharedPath) +// ***************************************************************** +: Inherit(), + _sharedPath(sharedPath) +{ +} + +SharedPath_Instances::Locator::Locator(const Locator& locator) +// *********************************************************** +: Inherit(), + _sharedPath(locator._sharedPath) +{ +} + +SharedPath_Instances::Locator& SharedPath_Instances::Locator::operator=(const Locator& locator) +// ******************************************************************************************** +{ + _sharedPath = locator._sharedPath; + return *this; +} + +Instance* SharedPath_Instances::Locator::GetElement() const +// ******************************************************** +{ + return (_sharedPath) ? _sharedPath->GetHeadInstance() : NULL; +} + +Locator* SharedPath_Instances::Locator::GetClone() const +// **************************************************************** +{ + return new Locator(*this); +} + +bool SharedPath_Instances::Locator::IsValid() const +// ************************************************ +{ + return (_sharedPath != NULL); +} + +void SharedPath_Instances::Locator::Progress() +// ******************************************* +{ + if (_sharedPath) _sharedPath = _sharedPath->GetTailSharedPath(); +} + +string SharedPath_Instances::Locator::_GetString() const +// ***************************************************** +{ + string s = "<" + _TName("SharedPath::Instances::Locator"); + if (_sharedPath) s += " " + GetString(_sharedPath); + s += ">"; + return s; +} + + + +} // End of Hurricane namespace. + + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/SharedPath.h b/hurricane/src/hurricane/SharedPath.h new file mode 100644 index 00000000..47f06dd5 --- /dev/null +++ b/hurricane/src/hurricane/SharedPath.h @@ -0,0 +1,120 @@ +// **************************************************************************************************** +// File: SharedPath.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_SHARED_PATH +#define HURRICANE_SHARED_PATH + +#include "Instances.h" +#include "SharedPathes.h" +#include "Quark.h" +#include "Transformation.h" +#include "IntrusiveMap.h" + +namespace Hurricane { + +class Cell; +class Entity; + + + +// **************************************************************************************************** +// SharedPath declaration +// **************************************************************************************************** + +class SharedPath { +// ************* + +// Types +// ***** + + public: class QuarkMap : public IntrusiveMap { + // *************************************************************** + + public: typedef IntrusiveMap Inherit; + + public: QuarkMap(); + + public: virtual const Entity* _GetKey(Quark* quark) const; + public: virtual unsigned _GetHashValue(const Entity* entity) const; + public: virtual Quark* _GetNextElement(Quark* quark) const; + public: virtual void _SetNextElement(Quark* quark, Quark* nextQuark) const; + + }; + +// Attributes +// ********** + + private: Instance* _headInstance; + private: SharedPath* _tailSharedPath; + private: QuarkMap _quarkMap; + private: SharedPath* _nextOfInstanceSharedPathMap; + +// Constructors +// ************ + + public: SharedPath(Instance* headInstance, SharedPath* tailSharedPath = NULL); + + private: SharedPath(const SharedPath& sharedPath); + // not implemented to forbid copy construction + +// Destructor +// ********** + + public: ~SharedPath(); + +// Operators +// ********* + + private: SharedPath& operator=(const SharedPath& sharedPath); + // not implemented to forbid assignment + +// Accessors +// ********* + + public: static char GetNameSeparator(); + + public: Instance* GetHeadInstance() const {return _headInstance;}; + public: SharedPath* GetTailSharedPath() const {return _tailSharedPath;}; + public: SharedPath* GetHeadSharedPath() const; + public: Instance* GetTailInstance() const; + public: string GetName() const; + public: Cell* GetOwnerCell() const; + public: Cell* GetMasterCell() const; + public: Instances GetInstances() const; + public: Transformation GetTransformation(const Transformation& transformation = Transformation()) const; + +// Updators +// ******** + + public: static void SetNameSeparator(char nameSeparator); + +// Accessors +// ********* + + public: string _GetTypeName() const { return _TName("SharedPath"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + public: Quark* _GetQuark(const Entity* entity) const {return _quarkMap.GetElement(entity);}; + public: Quarks _GetQuarks() const {return _quarkMap.GetElements();}; + public: QuarkMap& _GetQuarkMap() {return _quarkMap;}; + public: SharedPath* _GetNextOfInstanceSharedPathMap() const {return _nextOfInstanceSharedPathMap;}; + + public: void _SetNextOfInstanceSharedPathMap(SharedPath* sharedPath) {_nextOfInstanceSharedPathMap = sharedPath;}; + +}; + + + +} // End of Hurricane namespace. + + + +#endif // HURRICANE_SHARED_PATH + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/SharedPathes.h b/hurricane/src/hurricane/SharedPathes.h new file mode 100644 index 00000000..9cbb78ff --- /dev/null +++ b/hurricane/src/hurricane/SharedPathes.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: SharedPathes.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_SHARED_PATHES +#define HURRICANE_SHARED_PATHES + +#include "Collection.h" + +namespace Hurricane { + +class SharedPath; + + + +// **************************************************************************************************** +// SharedPathes declaration +// **************************************************************************************************** + +typedef GenericCollection SharedPathes; + + + +// **************************************************************************************************** +// SharedPathLocator declaration +// **************************************************************************************************** + +typedef GenericLocator SharedPathLocator; + + + +// **************************************************************************************************** +// SharedPathFilter declaration +// **************************************************************************************************** + +typedef GenericFilter SharedPathFilter; + + + +// **************************************************************************************************** +// for_each_shared_path declaration +// **************************************************************************************************** + +#define for_each_shared_path(sharedPath, sharedPathes)\ +/*****************************************************/\ +{\ + SharedPathLocator _locator = sharedPathes.GetLocator();\ + while (_locator.IsValid()) {\ + SharedPath* sharedPath = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_SHARED_PATHES + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Slice.cpp b/hurricane/src/hurricane/Slice.cpp new file mode 100644 index 00000000..48e5921d --- /dev/null +++ b/hurricane/src/hurricane/Slice.cpp @@ -0,0 +1,134 @@ +// **************************************************************************************************** +// File: Slice.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Slice.h" +#include "Cell.h" +#include "Component.h" +#include "Marker.h" +#include "Layer.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Slice implementation +// **************************************************************************************************** + +Slice::Slice(Cell* cell, Layer* layer) +// *********************************** +: _cell(cell), + _layer(layer), + _quadTree(), + _nextOfCellSliceMap(NULL) +{ + if (!_cell) + throw Error("Can't create " + _TName("Slice") + " : null cell"); + + if (!_layer) + throw Error("Can't create " + _TName("Slice") + " : null layer"); + + if (_cell->GetSlice(_layer)) + throw Error("Can't create " + _TName("Slice") + " : already exists"); + + _cell->_GetSliceMap()._Insert(this); +} + +Slice::~Slice() +// ************ +{ + _cell->_GetSliceMap()._Remove(this); +} + +Components Slice::GetComponents() const +// ************************************ +{ + // return _quadTree.GetGos().GetSubSet(); + return SubTypeCollection(_quadTree.GetGos()); +} + +Components Slice::GetComponentsUnder(const Box& area) const +// ******************************************************** +{ + // return _quadTree.GetGosUnder(area).GetSubSet(); + return SubTypeCollection(_quadTree.GetGosUnder(area)); +} + +Markers Slice::GetMarkers() const +// ****************************** +{ + // return _quadTree.GetGos().GetSubSet(); + return SubTypeCollection(_quadTree.GetGos()); +} + +Markers Slice::GetMarkersUnder(const Box& area) const +// ************************************************** +{ + // return _quadTree.GetGosUnder(area).GetSubSet(); + return SubTypeCollection(_quadTree.GetGosUnder(area)); +} + +Slice* Slice::_Create(Cell* cell, Layer* layer) +// ******************************************** +{ + Slice* slice = new Slice(cell, layer); + + return slice; +} + +void Slice::_Delete() +// ****************** +{ + delete this; +} + +string Slice::_GetString() const +// ***************************** +{ + string s = "<" + _TName("Slice"); + // s += " " + GetString(_cell->GetName()); + s += " " + GetString(_layer->GetName()); + s += ">"; + return s; +} + +Record* Slice::_GetRecord() const +// ************************ +{ + Record* record = new Record(GetString(this)); + if (record) { + record->Add(GetSlot("Cell", _cell)); + record->Add(GetSlot("Layer", _layer)); + record->Add(GetSlot("QuadTree", &_quadTree)); + } + return record; +} + +//void Slice::_Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) +//// **************************************************************************************************** +//{ +// assert(view); +// assert(basicLayer); +// if (_layer->Contains(basicLayer)) { +// if (GetBoundingBox().Intersect(updateArea)) { +// if ((basicLayer == _layer->_GetSymbolicBasicLayer()) || (3 < view->GetScale())) { +// for_each_go(go, GetGosUnder(updateArea)) { +// go->_Draw(view, basicLayer, updateArea, transformation); +// end_for; +// } +// } +// } +// } +//} +// + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Slice.h b/hurricane/src/hurricane/Slice.h new file mode 100644 index 00000000..43ce55c1 --- /dev/null +++ b/hurricane/src/hurricane/Slice.h @@ -0,0 +1,99 @@ +// **************************************************************************************************** +// File: Slice.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_SLICE +#define HURRICANE_SLICE + +#include "QuadTree.h" +#include "Components.h" +#include "Markers.h" +#include "Transformation.h" + +namespace Hurricane { + +class Cell; +class Layer; +class BasicLayer; + + + +// **************************************************************************************************** +// Slice declaration +// **************************************************************************************************** + +class Slice { +// ******** + +// Attributes +// ********** + + private: Cell* _cell; + private: Layer* _layer; + private: QuadTree _quadTree; + private: Slice* _nextOfCellSliceMap; + +// Constructors +// ************ + + protected: Slice(Cell* cell, Layer* layer); + + private: Slice(const Slice& slice); // not implemented to forbid copy construction + +// Destructor +// ********** + + protected: ~Slice(); + +// Operators +// ********* + + private: Slice& operator=(const Slice& slice); // not implemented to forbid assignment + +// Accessors +// ********* + + public: Cell* GetCell() const {return _cell;}; + public: Layer* GetLayer() const {return _layer;}; + public: const Box& GetBoundingBox() const {return _quadTree.GetBoundingBox();}; + public: Gos GetGos() const {return _quadTree.GetGos();}; + public: Gos GetGosUnder(const Box& area) const {return _quadTree.GetGosUnder(area);}; + public: Components GetComponents() const; + public: Components GetComponentsUnder(const Box& area) const; + public: Markers GetMarkers() const; + public: Markers GetMarkersUnder(const Box& area) const; + +// Predicates +// ********** + + public: bool IsEmpty() const {return _quadTree.IsEmpty();}; + +// Others +// ****** + + public: static Slice* _Create(Cell* cell, Layer* layer); + + public: void _Delete(); + + public: string _GetTypeName() const { return _TName("Slice"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + public: QuadTree* _GetQuadTree() {return &_quadTree;}; + public: Slice* _GetNextOfCellSliceMap() const {return _nextOfCellSliceMap;}; + + public: void _SetNextOfCellSliceMap(Slice* slice) {_nextOfCellSliceMap = slice;}; + + //public: void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation); + +}; + + +} // End of Hurricane namespace. + +#endif // HURRICANE_SLICE + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Slices.h b/hurricane/src/hurricane/Slices.h new file mode 100644 index 00000000..4e90ad7d --- /dev/null +++ b/hurricane/src/hurricane/Slices.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Slices.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_SLICES +#define HURRICANE_SLICES + +#include "Collection.h" + +namespace Hurricane { + +class Slice; + + + +// **************************************************************************************************** +// Slices declaration +// **************************************************************************************************** + +typedef GenericCollection Slices; + + + +// **************************************************************************************************** +// SliceLocator declaration +// **************************************************************************************************** + +typedef GenericLocator SliceLocator; + + + +// **************************************************************************************************** +// SliceFilter declaration +// **************************************************************************************************** + +typedef GenericFilter SliceFilter; + + + +// **************************************************************************************************** +// for_each_slice declaration +// **************************************************************************************************** + +#define for_each_slice(slice, slices)\ +/************************************/\ +{\ + SliceLocator _locator = slices.GetLocator();\ + while (_locator.IsValid()) {\ + Slice* slice = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_SLICES + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Slot.cpp b/hurricane/src/hurricane/Slot.cpp new file mode 100644 index 00000000..dfc87443 --- /dev/null +++ b/hurricane/src/hurricane/Slot.cpp @@ -0,0 +1,37 @@ + +// -*- C++ -*- +// +// This file is part of the Hurricane Software. +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// +// =================================================================== +// +// $Id: Slot.cpp,v 1.9 2007/07/29 15:25:00 jpc Exp $ +// +// x-----------------------------------------------------------------x +// | | +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Module : "./Slot.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + + + +#include "Commons.h" + + + + +namespace Hurricane { + + + +} // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/Slot.h b/hurricane/src/hurricane/Slot.h new file mode 100644 index 00000000..561166e3 --- /dev/null +++ b/hurricane/src/hurricane/Slot.h @@ -0,0 +1,150 @@ + +// -*- C++ -*- +// +// This file is part of the Hurricane Software. +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// +// =================================================================== +// +// $Id: Slot.h,v 1.9 2007/07/29 15:25:00 jpc Exp $ +// +// x-----------------------------------------------------------------x +// | | +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Remy Escassut | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./Slot.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + + + +# ifndef __HURRICANE_SLOT__ +# define __HURRICANE_SLOT__ + + +# ifndef __HURRICANE_COMMONS__ +# error "Slot.h musn't be included alone, please uses Commons.h." +# endif + + + + +namespace Hurricane { + + +// ------------------------------------------------------------------- +// Class : "Slot". + + class Slot : public NestedSlotAdapter { + + // Attributes + protected: + const string _name; + const SlotAdapter* _data; + + // Constructors + protected: + Slot ( const string& name, const SlotAdapter* data ) : _name(name), _data(data) {}; + private: + Slot ( const Slot& slot ); // Not implemented to forbid copy. + + // Destructor + public: + virtual ~Slot () {}; + + // Operators + private: + Slot& operator= ( const Slot& slot ); // Not implemented to forbid assignment. + + // Accessors + public: + const string& GetName () const { return _name; }; + virtual string GetDataString () const { return _data->_GetString(); }; + virtual Record* GetDataRecord () const { return _data->_GetRecord(); }; + + // Inspector Managment. + public: + virtual string _GetString () const + { + return "<" + _GetTypeName() + + " " + GetName() + " " + + _data->_GetString() + ">"; + }; + +}; + + + + +// ------------------------------------------------------------------- +// Class : "PointerSlot". +// +// The SlotAdapter is not duplicated, it is for objects in which +// it's directly integrated (inheritance). This is used for Hurricane +// objects with virtual functions. +// +// This is default behavior of Slot, so PointerSlot doesn't change +// it, but it's more clear for developpers. + + class PointerSlot : public Slot { + + // Constructors + public: + PointerSlot ( const string& name, const SlotAdapter* data ) : Slot(name,data) {}; + + // Destructor. + public: + virtual ~PointerSlot () {}; + + + // Accessors + public: + virtual string _GetTypeName () const { return _TName("PointerSlot"); }; + + }; + + + + +// ------------------------------------------------------------------- +// Class : "ValueSlot". +// +// The SlotAdapter is duplicated. It's for objects coming from +// external libraries or that do not have virtual functions (like +// Points or Boxes). + + class ValueSlot : public Slot { + + // Constructors + public: + ValueSlot (const string& name, const SlotAdapter* data ) : Slot(name,data) {}; + + // Destructor. + public: + virtual ~ValueSlot () { delete _data; }; + + // Accessors + public: + virtual string _GetTypeName () const { return _TName("ValueSlot"); }; + + }; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Slot) +SetNestedSlotAdapter(Hurricane::PointerSlot) +SetNestedSlotAdapter(Hurricane::ValueSlot) + + + + +#endif diff --git a/hurricane/src/hurricane/SlotAdapter.cpp b/hurricane/src/hurricane/SlotAdapter.cpp new file mode 100644 index 00000000..77d2fcc4 --- /dev/null +++ b/hurricane/src/hurricane/SlotAdapter.cpp @@ -0,0 +1,66 @@ + + +// -*- C++ -*- +// +// This file is part of the Coriolis Project. +// Copyright (C) Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie +// +// Main contributors : +// Christophe Alexandre +// Hugo Clément +// Jean-Paul Chaput +// Christian Masson +// +// The Coriolis Project is free software; you can redistribute it +// and/or modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// The Coriolis Project is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with the Coriolis Project; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA +// +// License-Tag +// Authors-Tag +// =================================================================== +// +// $Id: SlotAdapter.cpp,v 1.1 2007/07/29 15:25:01 jpc Exp $ +// +// x-----------------------------------------------------------------x +// | | +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Module : "./DataSlotAdapter.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + + + +# include +# include "Commons.h" + + + +namespace Hurricane { + + +// x-----------------------------------------------------------------x +// | DataSlotAdapter Global Variables | +// x-----------------------------------------------------------------x + + +} // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/SlotAdapter.h b/hurricane/src/hurricane/SlotAdapter.h new file mode 100644 index 00000000..bd99ebb7 --- /dev/null +++ b/hurricane/src/hurricane/SlotAdapter.h @@ -0,0 +1,904 @@ + + +// -*- C++ -*- +// +// This file is part of the Coriolis Project. +// Copyright (C) Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie +// +// Main contributors : +// Christophe Alexandre +// Hugo Clément +// Jean-Paul Chaput +// Christian Masson +// +// The Coriolis Project is free software; you can redistribute it +// and/or modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// The Coriolis Project is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with the Coriolis Project; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA +// +// License-Tag +// Authors-Tag +// =================================================================== +// +// $Id: SlotAdapter.h,v 1.7 2007/07/30 14:44:45 jpc Exp $ +// +// x-----------------------------------------------------------------x +// | | +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Header : "./SlotAdapter.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + + + +# ifndef __SLOT_ADAPTER__ +# define __SLOT_ADAPTER__ + + +# ifndef __HURRICANE_COMMONS__ +# error "SlotAdapter.h musn't be included alone, please uses Commons.h." +# endif + + + +# include + + + +namespace Hurricane { + + + using namespace std; + + + + +// ------------------------------------------------------------------- +// Template Functions : "Proxy...()". + +template + inline string ProxyTypeName ( const Type* object ) { return object->_GetTypeName(); } + +template + inline string ProxyString ( const Type* object ) { return object->_GetString(); } + +template + inline Record* ProxyRecord ( const Type* object ) { return object->_GetRecord(); } + + + + +// ------------------------------------------------------------------- +// SlotAdapter Type Identification by Template. + + +template + class IsNestedSlotAdapter { + public: + enum { True=0, False=1 }; + }; + + +template + class IsNestedSlotAdapter { + public: + enum { True=0, False=1 }; + }; + + + + +// ------------------------------------------------------------------- +// Class : "SlotAdapter". + + class SlotAdapter { + + // Destructor. + public: + virtual ~SlotAdapter () {}; + + // Slot Management. + public: + virtual string _GetTypeName () const = 0; + virtual string _GetString () const { return "SlotAdapter::_GetString()"; }; + virtual Record* _GetRecord () const { return NULL; }; + inline virtual Slot* _GetSlot ( const string& name ) const; + + }; + + + + +// ------------------------------------------------------------------- +// Class : "NestedSlotAdapter". + + class NestedSlotAdapter : public SlotAdapter { + + // Destructor. + public: + virtual ~NestedSlotAdapter () {}; + + // Slot Management. + public: + inline virtual Slot* _GetSlot ( const string& name ) const; + + }; + + + + +# define SetNestedSlotAdapter(T) \ + namespace Hurricane { \ + template<> \ + class IsNestedSlotAdapter { \ + protected: \ + const T* t; \ + public: \ + const NestedSlotAdapter* _CheckInheritance () const \ + { return static_cast(t); } \ + public: \ + enum { True=1, False=0 }; \ + }; \ + } + + + + +// ------------------------------------------------------------------- +// Templates Class : "PointerSlotAdapter". + +template + class PointerSlotAdapter : public SlotAdapter { + + // Attributes. + protected: + Type* _object; + + // Constructors. + public: + PointerSlotAdapter ( Type* o ) : SlotAdapter(), _object(o) {}; + + // Destructor. + public: + virtual ~PointerSlotAdapter () {}; + + // Slot Management. + public: + virtual string _GetTypeName () const { return ProxyTypeName(_object); }; + virtual string _GetString () const { return ProxyString (_object); }; + virtual Record* _GetRecord () const { return ProxyRecord (_object); }; + + }; + + + + +// ------------------------------------------------------------------- +// Templates Class : "ValueSlotAdapter". + +template + class ValueSlotAdapter : public SlotAdapter { + + // Attributes. + protected: + Type _object; + + // Constructors. + public: + ValueSlotAdapter ( Type o ) : SlotAdapter(), _object(o) {}; + + // Destructor. + public: + virtual ~ValueSlotAdapter () {}; + + // Slot Management. + public: + virtual string _GetTypeName () const { return ProxyTypeName(&_object); }; + virtual string _GetString () const { return ProxyString (&_object); }; + virtual Record* _GetRecord () const { return ProxyRecord (&_object); }; + + }; + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName ( const string* object ) { return ">"; } + +template<> + inline string ProxyString ( const string* object ) { return *object; } + +template<> + inline Record* ProxyRecord ( const string* object ) { return NULL; } + + + + +// ------------------------------------------------------------------- +// Class : "PointerSlotAdapter". + +template<> + inline string ProxyTypeName ( const char* object ) { return ">"; } + +template<> + inline string ProxyString ( const char* object ) { return object; } + +template<> + inline Record* ProxyRecord ( const char* object ) { return NULL; } + + + + +// ------------------------------------------------------------------- +// Class : "ValueSlotAdapter". + +template<> + class ValueSlotAdapter : public SlotAdapter { + + // Attributes. + protected: + const char _c; + + // Constructor. + public: + ValueSlotAdapter ( const char c ) : _c(c) {}; + + // Destructor. + public: + virtual ~ValueSlotAdapter () {}; + + // Slot Management. + public: + virtual string _GetTypeName () const { return ">"; }; + virtual string _GetString () const { return string(1,_c); }; + }; + + + + +// ------------------------------------------------------------------- +// Class : "ValueSlotAdapter". + +template<> + class ValueSlotAdapter : public SlotAdapter { + + // Attributes. + protected: + const char _c; + + // Constructor. + public: + ValueSlotAdapter ( const char c ) : _c(c) {}; + + // Destructor. + public: + virtual ~ValueSlotAdapter () {}; + + // Slot Management. + public: + virtual string _GetTypeName () const { return ">"; }; + virtual string _GetString () const { return string(1,_c); }; + }; + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName ( const bool* object ) { return ">"; } + +template<> + inline string ProxyString ( const bool* object ) { return (*object)?"True":"False" ; } + +template<> + inline Record* ProxyRecord ( const bool* object ) { return NULL; } + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName ( const void* object ) { return ">"; } + +template<> + inline string ProxyString ( const void* object ) + { + static ostringstream os; + os.str ( "0x" ); + os << hex << object; + return os.str(); + } + +template<> + inline Record* ProxyRecord ( const void* object ) { return NULL; } + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName ( const int* object ) { return ">"; } + +template<> + inline string ProxyString ( const int* object ) + { + static ostringstream os; + os.str ( "" ); + os << *object; + return os.str(); + } + +template<> + inline Record* ProxyRecord ( const int* object ) { return NULL; } + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName ( const long* object ) { return ">"; } + +template<> + inline string ProxyString ( const long* object ) + { + static ostringstream os; + os.str ( "" ); + os << *object; + return os.str(); + } + +template<> + inline Record* ProxyRecord ( const long* object ) { return NULL; } + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName ( const unsigned int* object ) { return ">"; } + +template<> + inline string ProxyString ( const unsigned int* object ) + { + static ostringstream os; + os.str ( "" ); + os << *object; + return os.str(); + } + +template<> + inline Record* ProxyRecord ( const unsigned int* object ) { return NULL; } + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName ( const unsigned long* object ) { return ">"; } + +template<> + inline string ProxyString ( const unsigned long* object ) + { + static ostringstream os; + os.str ( "" ); + os << *object; + return os.str(); + } + +template<> + inline Record* ProxyRecord ( const unsigned long* object ) { return NULL; } + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName ( const unsigned long long* object ) { return ">"; } + +template<> + inline string ProxyString ( const unsigned long long* object ) + { + static ostringstream os; + os.str ( "" ); + os << *object; + return os.str(); + } + +template<> + inline Record* ProxyRecord ( const unsigned long long* object ) { return NULL; } + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName ( const unsigned short int* object ) { return ">"; } + +template<> + inline string ProxyString ( const unsigned short int* object ) + { + static ostringstream os; + os.str ( "" ); + os << *object; + return os.str(); + } + +template<> + inline Record* ProxyRecord ( const unsigned short int* object ) { return NULL; } + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName ( const float* object ) { return ">"; } + +template<> + inline string ProxyString ( const float* object ) + { + static ostringstream os; + os.str ( "" ); + os << *object; + return os.str(); + } + +template<> + inline Record* ProxyRecord ( const float* object ) { return NULL; } + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName ( const double* object ) { return ">"; } + +template<> + inline string ProxyString ( const double* object ) + { + static ostringstream os; + os.str ( "" ); + os << *object; + return os.str(); + } + +template<> + inline Record* ProxyRecord ( const double* object ) { return NULL; } + + + + +} // End of Hurricane namespace. + + + + +// x-----------------------------------------------------------------x +// | Generic Functions for Slot Managment | +// x-----------------------------------------------------------------x + +// Note 1: we are outside the Hurricane namespace. +// Note 2: thoses templates manage all types. + + +template + inline Hurricane::Record* GetRecord ( T* t ) + { + if ( !t ) return NULL; + if ( Hurricane::IsNestedSlotAdapter::True ) + return ((const Hurricane::SlotAdapter*)((const void*)t))->_GetRecord(); + + return Hurricane::PointerSlotAdapter(t)._GetRecord(); + } + + +template + inline Hurricane::Record* GetRecord ( T t ) + { + if ( Hurricane::IsNestedSlotAdapter::True ) + return ((const Hurricane::SlotAdapter*)((const void*)&t))->_GetRecord(); + + return Hurricane::ValueSlotAdapter(t)._GetRecord(); + } + + +template + inline string GetString ( T* t ) + { + if ( !t ) return "NULL"; + if ( Hurricane::IsNestedSlotAdapter::True ) + return ((const Hurricane::SlotAdapter*)((const void*)t))->_GetString(); + + return Hurricane::PointerSlotAdapter(t)._GetString(); + } + + +template + inline string GetString ( T t ) + { + if ( Hurricane::IsNestedSlotAdapter::True ) + return ((const Hurricane::SlotAdapter*)((void*)&t))->_GetString(); + + return Hurricane::ValueSlotAdapter(t)._GetString(); + } + + +template + inline Hurricane::Slot* GetSlot ( const string& name, T* t ) + { + if ( !t ) return GetSlot ( name, "NULL pointer" ); + if ( Hurricane::IsNestedSlotAdapter::True ) + return ((const Hurricane::SlotAdapter*)((const void*)t))->_GetSlot(name); + + return (new Hurricane::PointerSlotAdapter(t))->_GetSlot(name); + } + + +template + inline Hurricane::Slot* GetSlot ( const string& name, T t ) + { + if ( Hurricane::IsNestedSlotAdapter::True ) + return ((const Hurricane::SlotAdapter*)((const void*)&t))->_GetSlot(name); + + return (new Hurricane::ValueSlotAdapter(t))->_GetSlot(name); + } + + +# define PointerIOStreamSupport(Type) \ + inline ostream& operator<< ( ostream& stream, const Type* t ) \ + { \ + if ( !t ) return stream << "NULL"; \ + if ( Hurricane::IsNestedSlotAdapter::True ) \ + return stream << "&" << ((const Hurricane::SlotAdapter*)((const void*)t))->_GetString(); \ + \ + return stream << "&" << Hurricane::PointerSlotAdapter(t)._GetString(); \ + } + + +# define ValueIOStreamSupport(Type) \ + inline ostream& operator<< ( ostream& stream, const Type& t ) \ + { \ + if ( Hurricane::IsNestedSlotAdapter::True ) \ + return stream << ((const Hurricane::SlotAdapter*)((const void*)&t))->_GetString(); \ + \ + return stream << Hurricane::ValueSlotAdapter(t)._GetString(); \ + } + + + +# include "Record.h" +# include "Slot.h" + + +namespace Hurricane { + + + inline Slot* SlotAdapter::_GetSlot ( const string& name ) const + { + return new ValueSlot(name,this); + }; + + + inline Slot* NestedSlotAdapter::_GetSlot ( const string& name ) const + { + return new PointerSlot(name,this); + }; + + + + +// Re-Entering Hurricane namespace, but now we can make use of +// GetString(), GetRecord() & GetSlot() for containers templates. + + +// ------------------------------------------------------------------- +// Class : "PointerSlotAdapter>". + +template + class PointerSlotAdapter > : public SlotAdapter { + + // Attributes. + protected: + const vector* _v; + + // Constructor. + public: + PointerSlotAdapter ( const vector* v ) : SlotAdapter(), _v(v) {}; + + // Destructor. + public: + virtual ~PointerSlotAdapter () {}; + + // Slot Management. + public: + virtual string _GetTypeName () const { return ">"; }; + virtual string _GetString () const; + virtual Record* _GetRecord () const; + }; + + +template + inline string PointerSlotAdapter >::_GetString () const + { + string name = "vector:"; + return name + GetString(_v->size()); + } + + +template + inline Record* PointerSlotAdapter >::_GetRecord () const + { + Record* record = NULL; + if ( !_v->empty() ) { + record = new Record ( "vector" ); + unsigned n = 1; + typename vector::const_iterator iterator = _v->begin(); + while ( iterator != _v->end() ) { + record->Add ( GetSlot(GetString(n++), *iterator) ); + ++iterator; + } + } + return record; + } + + + + +// ------------------------------------------------------------------- +// Class : "PointerSlotAdapter>". + +template + class PointerSlotAdapter > : public SlotAdapter { + + // Attributes. + protected: + const list* _l; + + // Constructor. + public: + PointerSlotAdapter ( const list* l ) : SlotAdapter(), _l(l) {}; + + // Destructor. + public: + virtual ~PointerSlotAdapter () {}; + + // Slot Management. + public: + virtual string _GetTypeName () const { return ">"; }; + virtual string _GetString () const; + virtual Record* _GetRecord () const; + }; + + +template + inline string PointerSlotAdapter >::_GetString () const + { + string name = "list:"; + return name + GetString(_l->size()); + } + + +template + inline Record* PointerSlotAdapter >::_GetRecord () const + { + Record* record = NULL; + if ( !_l->empty() ) { + record = new Record ( "list" ); + unsigned n = 1; + typename list::const_iterator iterator = _l->begin(); + while ( iterator != _l->end() ) { + record->Add ( GetSlot(GetString(n++), *iterator) ); + ++iterator; + } + } + return record; + } + + + + +// ------------------------------------------------------------------- +// Class : "PointerSlotAdapter>. + +template + class PointerSlotAdapter > : public SlotAdapter { + + // Attributes. + protected: + const map* _m; + + // Constructor. + public: + PointerSlotAdapter ( const map* m ) : _m(m) {}; + + // Destructor. + public: + virtual ~PointerSlotAdapter () {}; + + // Slot Management. + public: + virtual string _GetTypeName () const { return ">"; }; + virtual string _GetString () const; + virtual Record* _GetRecord () const; + }; + + +template + inline string PointerSlotAdapter >::_GetString () const + { + string name = "map:"; + return name + GetString(_m->size()); + } + + +template + inline Record* PointerSlotAdapter >::_GetRecord () const + { + Record* record = NULL; + if ( !_m->empty() ) { + record = new Record ( "map" ); + typename map::const_iterator iterator = _m->begin(); + while ( iterator != _m->end() ) { + record->Add ( GetSlot(GetString(iterator->first), iterator->second) ); + ++iterator; + } + } + return record; + } + + + + +// ------------------------------------------------------------------- +// Class : "SlotAdapterSet". + +template + class PointerSlotAdapter > : public SlotAdapter { + + // Attributes. + protected: + const set* _s; + + // Constructor. + public: + PointerSlotAdapter ( const set* m ) : _s(m) {}; + + // Destructor. + public: + virtual ~PointerSlotAdapter () {}; + + // Slot Management. + public: + virtual string _GetTypeName () const { return ">"; }; + virtual string _GetString () const; + virtual Record* _GetRecord () const; + }; + + +template + inline string PointerSlotAdapter >::_GetString () const + { + string name = "set:"; + return name + GetString(_s->size()); + } + + +template + inline Record* PointerSlotAdapter >::_GetRecord () const + { + Record* record = NULL; + if ( !_s->empty() ) { + record = new Record ( "set" ); + unsigned n = 1; + typename set::const_iterator iterator = _s->begin(); + while ( iterator != _s->end() ) { + record->Add ( GetSlot(GetString(n++), *iterator) ); + ++iterator; + } + } + return record; + } + + + + +// ------------------------------------------------------------------- +// Class : "SlotAdapterMultiSet". + +template + class PointerSlotAdapter > : public SlotAdapter { + + // Attributes. + protected: + const multiset* _s; + + // Constructor. + public: + PointerSlotAdapter ( const multiset* m ) : _s(m) {}; + + // Destructor. + public: + virtual ~PointerSlotAdapter () {}; + + // Slot Management. + public: + virtual string _GetTypeName () const { return ">"; }; + virtual string _GetString () const; + virtual Record* _GetRecord () const; + }; + + +template + inline string PointerSlotAdapter >::_GetString () const + { + string name = "multiset:"; + return name + GetString(_s->size()); + } + + +template + inline Record* PointerSlotAdapter >::_GetRecord () const + { + Record* record = NULL; + if ( !_s->empty() ) { + record = new Record ( "multiset" ); + unsigned n = 1; + typename multiset::const_iterator iterator = _s->begin(); + while ( iterator != _s->end() ) { + record->Add ( GetSlot(GetString(n++), *iterator) ); + ++iterator; + } + } + return record; + } + + + + +} // End of Hurricane namespace. + + + + +# endif diff --git a/hurricane/src/hurricane/Symbols.h b/hurricane/src/hurricane/Symbols.h new file mode 100644 index 00000000..3eddf7dc --- /dev/null +++ b/hurricane/src/hurricane/Symbols.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Symbols.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_SYMBOLS +#define HURRICANE_SYMBOLS + +#include "Collection.h" + +namespace Hurricane { + +class Symbol; + + + +// **************************************************************************************************** +// Symbols declaration +// **************************************************************************************************** + +typedef GenericCollection Symbols; + + + +// **************************************************************************************************** +// SymbolLocator declaration +// **************************************************************************************************** + +typedef GenericLocator SymbolLocator; + + + +// **************************************************************************************************** +// SymbolFilter declaration +// **************************************************************************************************** + +typedef GenericFilter SymbolFilter; + + + +// **************************************************************************************************** +// for_each_symbol declaration +// **************************************************************************************************** + +#define for_each_symbol(symbol, symbols)\ +/***************************************/\ +{\ + SymbolLocator _locator = symbols.GetLocator();\ + while (_locator.IsValid()) {\ + Symbol* symbol = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_SYMBOLS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/TO_BE_DONE b/hurricane/src/hurricane/TO_BE_DONE new file mode 100644 index 00000000..d9abf481 --- /dev/null +++ b/hurricane/src/hurricane/TO_BE_DONE @@ -0,0 +1,7 @@ +Materialisation + Un fois une cellule dematerialisee, les objets de la cellule ne sont plus materialisables. + idem pour les nets. + +Quelque soit le nombe d'UpdateSession assurer que tous les objets d'une cellule ou d'un net se + rematerialisent avand la fermeture de la session (pour etre sur de prendre tout le monde lors + des parcours under. diff --git a/hurricane/src/hurricane/Tabulation.cpp b/hurricane/src/hurricane/Tabulation.cpp new file mode 100644 index 00000000..450f2e31 --- /dev/null +++ b/hurricane/src/hurricane/Tabulation.cpp @@ -0,0 +1,97 @@ +// **************************************************************************************************** +// File: Tabulation.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Tabulation.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Tabulation implementation +// **************************************************************************************************** + +Tabulation::Tabulation(const string& s) +// ************************************ +: _s(s), + _n(0) +{ +} + +Tabulation::Tabulation(const Tabulation& tabulation) +// ************************************************* +: _s(tabulation._s), + _n(tabulation._n) +{ +} + +Tabulation::~Tabulation() +// ********************** +{ +} + +Tabulation& Tabulation::operator=(const Tabulation& tabulation) +// ************************************************************ +{ + _s = tabulation._s; + _n = tabulation._n; + return *this; +} + +Tabulation& Tabulation::operator++() +// ********************************* +{ + if (_n < 100) _n++; + return *this; +} + +Tabulation Tabulation::operator++(int) +// *********************************** +{ + Tabulation tabulation = *this; + if (_n < 100) _n++; + return tabulation; +} + +Tabulation& Tabulation::operator--() +// ********************************* +{ + if (0 < _n) _n--; + return *this; +} + +Tabulation Tabulation::operator--(int) +// *********************************** +{ + Tabulation tabulation = *this; + if (0 < _n) _n--; + return tabulation; +} + +string Tabulation::_GetString() const +// ********************************** +{ + string s = ""; + unsigned n = _n; + while (n--) s += _s; + return s; +} + + + +// **************************************************************************************************** +// Variables +// **************************************************************************************************** + +Tabulation tab(" "); + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Tabulation.h b/hurricane/src/hurricane/Tabulation.h new file mode 100644 index 00000000..cbc21fe0 --- /dev/null +++ b/hurricane/src/hurricane/Tabulation.h @@ -0,0 +1,85 @@ +// **************************************************************************************************** +// File: Tabulation.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_TABULATION +#define HURRICANE_TABULATION + +#include "Commons.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Tabulation declaration +// **************************************************************************************************** + +class Tabulation { +// ************* + +// Attributes +// ********** + + private: string _s; + private: unsigned _n; + +// Constructors +// ************ + + public: Tabulation(const string& s = " "); + + public: Tabulation(const Tabulation& tabulation); + +// Destructor +// ********** + + public: ~Tabulation(); + +// Operators +// ********* + + public: Tabulation& operator=(const Tabulation& tabulation); + + public: Tabulation& operator++(); + public: Tabulation operator++(int); + public: Tabulation& operator--(); + public: Tabulation operator--(int); + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("Tabulation"); }; + public: string _GetString() const; + public: Record* _GetRecord() const { return NULL; }; + public: Slot* _GetSlot() const { return NULL; }; + +}; + + + +// **************************************************************************************************** +// Variables +// **************************************************************************************************** + +extern Tabulation tab; + + + +} // End of Hurricane namespace. + + +ValueIOStreamSupport(Hurricane::Tabulation) + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +#endif // HURRICANE_TABULATION + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Tag.cpp b/hurricane/src/hurricane/Tag.cpp new file mode 100644 index 00000000..90b0019d --- /dev/null +++ b/hurricane/src/hurricane/Tag.cpp @@ -0,0 +1,157 @@ +// **************************************************************************************************** +// File: Tag.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Tag.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Utilitarians +// **************************************************************************************************** + +static bool Read(FILE* file, unsigned& rank, string& name, string& argument) +// ************************************************************************* +{ + rank = 0; + name = ""; + argument = ""; + + char c = fgetc(file); + + if (c == EOF) return false; + + while ((c != EOF) && (c == '\t')) { + rank++; + c = fgetc(file); + } + + if (c == '#') { + while ((c != EOF) && (c != '\n')) c = fgetc(file); + return true; + } + + while ((c != EOF) && ((c == '\t') || (c == ' '))) + c = fgetc(file); + + while ((c != EOF) && (c != '\t') && (c != ' ') && (c != '\n')) { + name += c; + c = fgetc(file); + } + + while ((c != EOF) && ((c == '\t') || (c == ' '))) + c = fgetc(file); + + while ((c != EOF) && (c != '\n')) { + argument += c; + c = fgetc(file); + } + + return true; +} + + + +// **************************************************************************************************** +// Tag implementation +// **************************************************************************************************** + +Tag::Tag(Tag* tag, unsigned line, unsigned rank, const string& name, const string& argument) +// ***************************************************************************************** +: _tag(tag), + _line(line), + _rank(rank), + _name(name), + _argument(argument), + _tagList() +{ + if (_tag) _tag->_tagList.push_back(this); +} + +Tag::Tag(const string& filePathName, const string& name) +// ***************************************************** +: _tag(NULL), + _line(0), + _rank(0), + _name(name), + _argument(filePathName), + _tagList() +{ + if (filePathName.empty()) + throw Error("Can't create " + _TName("Tag") + " from file : empty file pathname"); + + FILE* file = fopen(filePathName.c_str(), "r"); + if (!file) + throw Error("Can't create " + _TName("Tag") + ", unreadable file : " + filePathName); + + unsigned rank; + string token; + string argument; + unsigned line = 1; + + while (Read(file, rank, token, argument)) { + if (!token.empty()) new Tag(this, line, rank, token, argument); + line++; + } + fclose(file); + + stack tagStack; + TagList::iterator it = _tagList.begin(); + while (it != _tagList.end()) { + Tag* tag = *it++; + unsigned rank = tag->_rank; + while (!tagStack.empty() && (rank <= tagStack.top()->_rank)) tagStack.pop(); + Tag* parent = (tagStack.empty()) ? NULL : tagStack.top(); + if (parent && (parent->_rank != (rank - 1))) parent = NULL; + if (!parent) { + if (rank) + throw Error("Syntax error : bad indentation (line " + GetString(tag->_line) + ")"); + } + else { + _tagList.remove(tag); + tag->_tag = parent; + parent->_tagList.push_back(tag); + } + tagStack.push(tag); + } +} + +Tag::~Tag() +// ******** +{ + if (_tag) _tag->_tagList.remove(this); + + while (!_tagList.empty()) delete *_tagList.begin(); +} + +string Tag::_GetString() const +// *************************** +{ + return "<" + _TName("Tag") + " " + _name + " " + _argument + ">"; +} + +Record* Tag::_GetRecord() const +// ********************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Tag", _tag)); + record->Add(GetSlot("Line", &_line)); + record->Add(GetSlot("Rank", &_rank)); + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("Argument", &_argument)); + record->Add(GetSlot("Tags", &_tagList)); + return record; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Tag.h b/hurricane/src/hurricane/Tag.h new file mode 100644 index 00000000..fa55826a --- /dev/null +++ b/hurricane/src/hurricane/Tag.h @@ -0,0 +1,92 @@ +// **************************************************************************************************** +// File: Tag.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_TAG +#define HURRICANE_TAG + +#include "Tags.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Tag declaration +// **************************************************************************************************** + +class Tag { +// ****** + +// Types +// ***** + + public: typedef list TagList; + +// Attributes +// ********** + + private: Tag* _tag; + private: unsigned _line; + private: unsigned _rank; + private: string _name; + private: string _argument; + private: TagList _tagList; + +// Constructors +// ************ + + private: Tag(Tag* tag, unsigned line, unsigned rank, const string& name, const string& argument); + + public: Tag(const string& filePathName, const string& name); + + private: Tag(const Tag& tag); // not implemented to forbid copy + +// Destructor +// ********** + + public: ~Tag(); + +// Operators +// ********* + + private: Tag& operator=(const Tag& tag); // not implemented to forbid assignment + +// Accessors +// ********* + + public: Tag* GetTag() const {return _tag;}; + public: unsigned GetLine() const {return _line;}; + public: unsigned GetRank() const {return _rank;}; + public: const string& GetName() const {return _name;}; + public: const string& GetArgument() const {return _argument;}; + public: Tags GetTags() const {return GetCollection(_tagList);}; + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("Tag"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + public: TagList& _GetTagList() {return _tagList;}; + +}; + + + +} // End of Hurricane namespace. + + + +// **************************************************************************************************** +// Globals +// **************************************************************************************************** + + +#endif // HURRICANE_TAG + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Tags.h b/hurricane/src/hurricane/Tags.h new file mode 100644 index 00000000..c98bf0f3 --- /dev/null +++ b/hurricane/src/hurricane/Tags.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Tags.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_TAGS +#define HURRICANE_TAGS + +#include "Collection.h" + +namespace Hurricane { + +class Tag; + + + +// **************************************************************************************************** +// Tags declaration +// **************************************************************************************************** + +typedef GenericCollection Tags; + + + +// **************************************************************************************************** +// TagLocator declaration +// **************************************************************************************************** + +typedef GenericLocator TagLocator; + + + +// **************************************************************************************************** +// TagFilter declaration +// **************************************************************************************************** + +typedef GenericFilter TagFilter; + + + +// **************************************************************************************************** +// for_each_tag declaration +// **************************************************************************************************** + +#define for_each_tag(tag, tags)\ +/******************************/\ +{\ + TagLocator _locator = tags.GetLocator();\ + while (_locator.IsValid()) {\ + Tag* tag = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_TAGS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Technology.cpp b/hurricane/src/hurricane/Technology.cpp new file mode 100644 index 00000000..e555abc0 --- /dev/null +++ b/hurricane/src/hurricane/Technology.cpp @@ -0,0 +1,653 @@ +// **************************************************************************************************** +// File: Technology.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Technology.h" +#include "DataBase.h" +#include "Layer.h" +#include "BasicLayer.h" +#include "CompositeLayer.h" +#include "Tag.h" +#include "Error.h" + + + +namespace Hurricane { + + + +// **************************************************************************************************** +// Technology_BasicLayers declaration +// **************************************************************************************************** + +class Technology_BasicLayers : public Collection { +// ********************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // *********************************************************** + + public: typedef Hurricane::Locator Inherit; + + private: const Technology* _technology; + private: Layer::Mask _mask; + private: BasicLayerLocator _basicLayerLocator; + + public: Locator(); + public: Locator(const Technology* technology, const Layer::Mask& mask); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual BasicLayer* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Technology* _technology; + private: Layer::Mask _mask; + +// Constructors +// ************ + + public: Technology_BasicLayers(); + public: Technology_BasicLayers(const Technology* technology, const Layer::Mask& mask); + public: Technology_BasicLayers(const Technology_BasicLayers& basicLayers); + +// Operators +// ********* + + public: Technology_BasicLayers& operator=(const Technology_BasicLayers& basicLayers); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + + + +// **************************************************************************************************** +// Utilitarians +// **************************************************************************************************** + +static void Abort(Tag* tag, const string& reason) +// ********************************************** +{ + Tag* topTag = tag; + while (topTag->GetTag()) topTag = topTag->GetTag(); + + throw Error("Can't load technology : " + reason + + " : " + topTag->GetArgument() + " (line " + GetString(tag->GetLine()) + ")"); + +} + +static void CreateBasicLayerFromTag(Technology* technology, Tag* tag) +// ****************************************************************** +{ + Name name = tag->GetArgument(); + + if (name.IsEmpty()) + Abort(tag, "undefined basic layer name"); + + if (technology->GetLayer(name)) + Abort(tag, "layer " + GetString(name) + " already exists"); + + BasicLayer::Type type; + unsigned extractNumber = 0; + Unit minimalSize = 0; + Unit minimalSpacing = 0; + unsigned short redValue = 255; + unsigned short greenValue = 255; + unsigned short blueValue = 255; + string fillPattern = "FFFFFFFFFFFFFFFF"; + double displayThreshold = 0.0; + + for_each_tag(childTag, tag->GetTags()) { + if (childTag->GetName() == "type") { + if (!::Scan(childTag->GetArgument(), type)) + Abort(tag, "invalid type"); + } + else if (childTag->GetName() == "extract-number") { + if (!::Scan(childTag->GetArgument(), extractNumber)) + Abort(tag, "invalid extract-number"); + } + else if (childTag->GetName() == "minimal-size") { + if (!::Scan(childTag->GetArgument(), minimalSize)) + Abort(tag, "invalid minimal-size"); + } + else if (childTag->GetName() == "minimal-spacing") { + if (!::Scan(childTag->GetArgument(), minimalSpacing)) + Abort(tag, "invalid minimal-spacing"); + } + else if (childTag->GetName() == "color") { + if (!::Scan(childTag->GetArgument(), redValue, greenValue, blueValue)) + Abort(tag, "invalid color"); + } + else if (childTag->GetName() == "pattern") { + if (!::Scan(childTag->GetArgument(), fillPattern)) + Abort(tag, "invalid pattern"); + } + else if (childTag->GetName() == "display-threshold") { + if (!::Scan(childTag->GetArgument(), displayThreshold)) + Abort(tag, "invalid display-threshold"); + } + end_for; + } + + BasicLayer* basicLayer = + BasicLayer::Create(technology, name, type, extractNumber, minimalSize, minimalSpacing); + + basicLayer->SetColor(redValue, greenValue, blueValue); + basicLayer->SetFillPattern(fillPattern); + basicLayer->SetDisplayThreshold(displayThreshold); +} + +void AddBasicLayerFromTag(CompositeLayer* compositeLayer, Tag* tag) +// **************************************************************** +{ + Name name = tag->GetArgument(); + + if (name.IsEmpty()) + Abort(tag, "undefined basic layer name"); + + BasicLayer* basicLayer = compositeLayer->GetTechnology()->GetBasicLayer(name); + + if (!basicLayer) + Abort(tag, "undefined basic layer " + GetString(name)); + + if (compositeLayer->Contains(basicLayer)) compositeLayer->Remove(basicLayer); + + Unit contactSize = 0; + Unit segmentSize = 0; + Unit segmentExtention = 0; + Unit padSize = 0; + + for_each_tag(childTag, tag->GetTags()) { + if (childTag->GetName() == "contact-size") { + if (!::Scan(childTag->GetArgument(), contactSize)) + Abort(tag, "invalid contact-size"); + } + else if (childTag->GetName() == "segment-size") { + if (!::Scan(childTag->GetArgument(), segmentSize)) + Abort(tag, "invalid segment-size"); + } + else if (childTag->GetName() == "segment-extention") { + if (!::Scan(childTag->GetArgument(), segmentExtention)) + Abort(tag, "invalid segment-extention"); + } + else if (childTag->GetName() == "pad-size") { + if (!::Scan(childTag->GetArgument(), padSize)) + Abort(tag, "invalid pad-size"); + } + end_for; + } + + compositeLayer->Add(basicLayer, contactSize, segmentSize, segmentExtention, padSize); +} + +void AddCompositeLayerFromTag(CompositeLayer* compositeLayer, Tag* tag) +// ******************************************************************** +{ + Name name = tag->GetArgument(); + + CompositeLayer* childCompositeLayer = compositeLayer->GetTechnology()->GetCompositeLayer(name); + + if (!childCompositeLayer) + Abort(tag, "unknown composite-layer " + GetString(name)); + + for_each_basic_layer(basicLayer, childCompositeLayer->GetBasicLayers()) { + Unit contactSize = + max(childCompositeLayer->GetContactSize(basicLayer), + compositeLayer->GetContactSize(basicLayer)); + Unit segmentSize = + max(childCompositeLayer->GetSegmentSize(basicLayer), + compositeLayer->GetSegmentSize(basicLayer)); + Unit segmentExtention = + max(childCompositeLayer->GetSegmentExtention(basicLayer), + compositeLayer->GetSegmentExtention(basicLayer)); + Unit padSize = + max(childCompositeLayer->GetPadSize(basicLayer), + compositeLayer->GetPadSize(basicLayer)); + if (compositeLayer->Contains(basicLayer)) compositeLayer->Remove(basicLayer); + compositeLayer->Add(basicLayer, contactSize, segmentSize, segmentExtention, padSize); + Unit minimalSize = max(compositeLayer->GetMinimalSize(), childCompositeLayer->GetMinimalSize()); + compositeLayer->SetMinimalSize(minimalSize); + end_for; + } +} + +static void CreateCompositeLayerFromTag(Technology* technology, Tag* tag) +// ********************************************************************** +{ + Name name = tag->GetArgument(); + + if (name.IsEmpty()) + Abort(tag, "undefined composite layer name"); + + if (technology->GetLayer(name)) + Abort(tag, "layer " + GetString(name) + " already exists"); + + CompositeLayer::Type type; + Unit minimalSize = 0; + Unit minimalSpacing = 0; + + for_each_tag(childTag, tag->GetTags()) { + if (childTag->GetName() == "type") { + if (!::Scan(childTag->GetArgument(), type)) + Abort(tag, "invalid type"); + } + else if (childTag->GetName() == "minimal-size") { + if (!::Scan(childTag->GetArgument(), minimalSize)) + Abort(tag, "invalid minimal-size"); + } + else if (childTag->GetName() == "minimal-spacing") { + if (!::Scan(childTag->GetArgument(), minimalSpacing)) + Abort(tag, "invalid minimal-spacing"); + } + end_for; + } + + CompositeLayer* compositeLayer = + CompositeLayer::Create(technology, name, type, minimalSize, minimalSpacing); + + for_each_tag(childTag, tag->GetTags()) { + if (childTag->GetName() == "basic-layer") + AddBasicLayerFromTag(compositeLayer, childTag); + if (childTag->GetName() == "composite-layer") + AddCompositeLayerFromTag(compositeLayer, childTag); + end_for; + } +} + +static Technology* CreateTechnologyFromTag(DataBase* dataBase, Tag* tag) +// ********************************************************************* +{ + Name name; + unsigned precision; + unsigned gridStep = 1; + + for_each_tag(childTag, tag->GetTags()) { + if (childTag->GetName() == "name") { + name = childTag->GetArgument(); + } + else if (childTag->GetName() == "precision") { + if (!::Scan(childTag->GetArgument(), precision)) + Abort(tag, "invalid precision"); + if (GetMaximalPrecisionAllowed() < precision) + Abort(childTag, "too big precision (not allowed)"); + } + else if (childTag->GetName() == "grid-step") { + if (!::Scan(childTag->GetArgument(), gridStep)) + Abort(tag, "invalid grid-step"); + if (!gridStep) + Abort(childTag, "too small grid step (not allowed)"); + } + end_for; + } + + if (name.IsEmpty()) + Abort(tag, "undefined technology name"); + + Technology* technology = Technology::Create(dataBase, name); + + SetPrecision(precision); + SetGridStep(gridStep); + + for_each_tag(childTag, tag->GetTags()) { + if (childTag->GetName() == "basic-layer") + CreateBasicLayerFromTag(technology, childTag); + else if (childTag->GetName() == "composite-layer") + CreateCompositeLayerFromTag(technology, childTag); + end_for; + } + + return technology; +} + + + +// **************************************************************************************************** +// Technology implementation +// **************************************************************************************************** + +Technology::Technology(DataBase* dataBase, const Name& name) +// ********************************************************* +: Inherit(), + _dataBase(dataBase), + _name(name), + _layerMap(), + _layerList() +{ + if (!_dataBase) + throw Error("Can't create " + _TName("Technology") + " : null data base"); + + if (_dataBase->GetTechnology()) + throw Error("Can't create " + _TName("Technology") + " : already exists"); + + if (_name.IsEmpty()) + throw Error("Can't create " + _TName("Technology") + " : empty name"); +} + +Technology* Technology::Create(DataBase* dataBase, const Name& name) +// ***************************************************************** +{ + Technology* technology = new Technology(dataBase, name); + + technology->_PostCreate(); + + return technology; +} + +Technology* Technology::CreateFromFile(DataBase* dataBase, const string& filePathName) +// *********************************************************************************** +{ + Tag* tag = NULL; + Technology* technology = NULL; + + try { + tag = new Tag(filePathName, "technology"); + technology = CreateTechnologyFromTag(dataBase, tag); + delete tag; + } + catch (...) { + if (technology) technology->Delete(); + if (tag) delete tag; + throw; + } + + return technology; +} + +BasicLayer* Technology::GetBasicLayer(const Name& name) const +// ********************************************************** +{ + Layer* layer = GetLayer(name); + return (layer && is_a(layer)) ? (BasicLayer*)layer : NULL; +} + +CompositeLayer* Technology::GetCompositeLayer(const Name& name) const +// ****************************************************************** +{ + Layer* layer = GetLayer(name); + return (layer && is_a(layer)) ? (CompositeLayer*)layer : NULL; +} + +BasicLayers Technology::GetBasicLayers() const +// ******************************************* +{ + // return GetLayers().GetSubSet(); + return SubTypeCollection(GetLayers()); +} + +BasicLayers Technology::GetBasicLayers(const Layer::Mask& mask) const +// ****************************************************************** +{ + return Technology_BasicLayers(this, mask); +} + +CompositeLayers Technology::GetCompositeLayers() const +// *************************************************** +{ + // return GetLayers().GetSubSet(); + return SubTypeCollection(GetLayers()); +} + +void Technology::SetName(const Name& name) +// *************************************** +{ + if (name != _name) { + if (name.IsEmpty()) + throw Error("Can't change technology name : empty name"); + + _name = name; + } +} + +void Technology::_PostCreate() +// *************************** +{ + Inherit::_PostCreate(); + + _dataBase->_SetTechnology(this); +} + +void Technology::_PreDelete() +// ************************** +{ + Inherit::_PreDelete(); + + for_each_layer(layer, GetLayers()) layer->Delete(); end_for; + + _dataBase->_SetTechnology(NULL); +} + +string Technology::_GetString() const +// ********************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_name)); + return s; +} + +Record* Technology::_GetRecord() const +// ***************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("DataBase", _dataBase)); + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("Layers", &_layerList)); + } + return record; +} + +// **************************************************************************************************** +// Technology::LayerMap implementation +// **************************************************************************************************** + +Technology::LayerMap::LayerMap() +// ***************************** +: Inherit() +{ +} + +Name Technology::LayerMap::_GetKey(Layer* layer) const +// *************************************************** +{ + return layer->GetName(); +} + +unsigned Technology::LayerMap::_GetHashValue(Name name) const +// ********************************************************** +{ + return ( (unsigned int)( (unsigned long)name._GetSharedName() ) ) / 8; +} + +Layer* Technology::LayerMap::_GetNextElement(Layer* layer) const +// ************************************************************* +{ + return layer->_GetNextOfTechnologyLayerMap(); +} + +void Technology::LayerMap::_SetNextElement(Layer* layer, Layer* nextLayer) const +// ***************************************************************************** +{ + layer->_SetNextOfTechnologyLayerMap(nextLayer); +}; + + + +// **************************************************************************************************** +// Technology_BasicLayers implementation +// **************************************************************************************************** + +Technology_BasicLayers::Technology_BasicLayers() +// ********************************************* +: Inherit(), + _technology(NULL), + _mask(0) +{ +} + +Technology_BasicLayers::Technology_BasicLayers(const Technology* technology, const Layer::Mask& mask) +// ************************************************************************************************** +: Inherit(), + _technology(technology), + _mask(mask) +{ +} + +Technology_BasicLayers::Technology_BasicLayers(const Technology_BasicLayers& basicLayers) +// ************************************************************************************** +: Inherit(), + _technology(basicLayers._technology), + _mask(basicLayers._mask) +{ +} + +Technology_BasicLayers& Technology_BasicLayers::operator=(const Technology_BasicLayers& basicLayers) +// ************************************************************************************************* +{ + _technology = basicLayers._technology; + _mask = basicLayers._mask; + return *this; +} + +Collection* Technology_BasicLayers::GetClone() const +// ************************************************************** +{ + return new Technology_BasicLayers(*this); +} + +Locator* Technology_BasicLayers::GetLocator() const +// ************************************************************* +{ + return new Locator(_technology, _mask); +} + +string Technology_BasicLayers::_GetString() const +// ********************************************** +{ + string s = "<" + _TName("Technology::BasicLayers"); + if (_technology) { + s += " " + GetString(_technology); + s += " " + GetString(_mask); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// Technology_BasicLayers::Locator implementation +// **************************************************************************************************** + +Technology_BasicLayers::Locator::Locator() +// *************************************** +: Inherit(), + _technology(NULL), + _mask(0), + _basicLayerLocator() +{ +} + +Technology_BasicLayers::Locator::Locator(const Technology* technology, const Layer::Mask& mask) +// ******************************************************************************************** +: Inherit(), + _technology(technology), + _mask(mask), + _basicLayerLocator() +{ + if (_technology) { + _basicLayerLocator = _technology->GetBasicLayers().GetLocator(); + while (_basicLayerLocator.IsValid() && !(_basicLayerLocator.GetElement()->GetMask() & _mask)) + _basicLayerLocator.Progress(); + } +} + +Technology_BasicLayers::Locator::Locator(const Locator& locator) +// ************************************************************* +: Inherit(), + _technology(locator._technology), + _mask(locator._mask), + _basicLayerLocator(locator._basicLayerLocator) +{ +} + +Technology_BasicLayers::Locator& Technology_BasicLayers::Locator::operator=(const Locator& locator) +// ************************************************************************************************ +{ + _technology = locator._technology; + _mask = locator._mask; + _basicLayerLocator = locator._basicLayerLocator; + return *this; +} + +BasicLayer* Technology_BasicLayers::Locator::GetElement() const +// ************************************************************ +{ + return _basicLayerLocator.GetElement(); +} + +Locator* Technology_BasicLayers::Locator::GetClone() const +// ******************************************************************** +{ + return new Locator(*this); +} + +bool Technology_BasicLayers::Locator::IsValid() const +// ************************************************** +{ + return _basicLayerLocator.IsValid(); +} + +void Technology_BasicLayers::Locator::Progress() +// ********************************************* +{ + do { + _basicLayerLocator.Progress(); + } + while (_basicLayerLocator.IsValid() && !(_basicLayerLocator.GetElement()->GetMask() & _mask)); +} + +string Technology_BasicLayers::Locator::_GetString() const +// ******************************************************* +{ + string s = "<" + _TName("Technology::BasicLayers::Locator"); + if (_technology) { + s += " " + GetString(_technology); + s += " " + GetString(_mask); + } + s += ">"; + return s; +} + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Technology.h b/hurricane/src/hurricane/Technology.h new file mode 100644 index 00000000..1287fa7b --- /dev/null +++ b/hurricane/src/hurricane/Technology.h @@ -0,0 +1,111 @@ +// **************************************************************************************************** +// File: Technology.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_TECHNOLOGY +#define HURRICANE_TECHNOLOGY + +#include "DBo.h" +#include "Layer.h" +#include "BasicLayers.h" +#include "CompositeLayers.h" +#include "IntrusiveMap.h" + +namespace Hurricane { + +class DataBase; +class BasicLayer; +class CompositeLayer; + + + +// **************************************************************************************************** +// Technology declaration +// **************************************************************************************************** + +class Technology : public DBo { +// ************************** + +// Types +// ***** + + public: typedef DBo Inherit; + + public: class LayerMap : public IntrusiveMap { + // ****************************************************** + + public: typedef IntrusiveMap Inherit; + + public: LayerMap(); + + public: virtual Name _GetKey(Layer* layer) const; + public: virtual unsigned _GetHashValue(Name name) const; + public: virtual Layer* _GetNextElement(Layer* layer) const; + public: virtual void _SetNextElement(Layer* layer, Layer* nextLayer) const; + + }; + + public: typedef list LayerList; + +// Attributes +// ********** + + private: DataBase* _dataBase; + private: Name _name; + private: LayerMap _layerMap; + private: LayerList _layerList; + +// Constructors +// ************ + + protected: Technology(DataBase* dataBase, const Name& name); + + public: static Technology* Create(DataBase* dataBase, const Name& name); + public: static Technology* CreateFromFile(DataBase* dataBase, const string& filePathName); + +// Accessors +// ********* + + public: DataBase* GetDataBase() const {return _dataBase;}; + public: const Name& GetName() const {return _name;}; + public: Layer* GetLayer(const Name& name) const {return _layerMap.GetElement(name);}; + public: BasicLayer* GetBasicLayer(const Name& name) const; + public: CompositeLayer* GetCompositeLayer(const Name& name) const; + public: Layers GetLayers() const {return GetCollection(_layerList);}; + public: BasicLayers GetBasicLayers() const; + public: BasicLayers GetBasicLayers(const Layer::Mask& mask) const; + public: CompositeLayers GetCompositeLayers() const; + +// Updators +// ******** + + public: void SetName(const Name& name); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("Technology");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: LayerMap& _GetLayerMap() {return _layerMap;}; + public: LayerList& _GetLayerList() {return _layerList;}; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Technology) + +#endif // HURRICANE_TECHNOLOGY + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Timer.cpp b/hurricane/src/hurricane/Timer.cpp new file mode 100644 index 00000000..daeea290 --- /dev/null +++ b/hurricane/src/hurricane/Timer.cpp @@ -0,0 +1,85 @@ +// **************************************************************************************************** +// File: Timer.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Timer.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Timer implementation +// **************************************************************************************************** + +Timer::Timer() +// *********** +: _time(time(NULL)) +{ +} + +Timer::Timer(const Timer& timer) +// ***************************** +: _time(timer._time) +{ +} + +Timer& Timer::operator=(const Timer& timer) +// **************************************** +{ + _time = timer._time; + return *this; +} + +string Timer::_GetString() const +// ***************************** +{ + unsigned seconds = time(NULL) - _time; + + string s = ""; + + if (86400 <= seconds) { + unsigned days = seconds / 86400; + seconds -= 96400 * days; + s += GetString(days) + "d"; + } + + if (3600 <= seconds) { + unsigned hours = seconds / 3600; + seconds -= 3600 * hours; + if (!s.empty()) s += " "; + s += GetString(hours) + "h"; + } + + if (60 <= seconds) { + unsigned minutes = seconds / 60; + seconds -= 60 * minutes; + if (!s.empty()) s += " "; + s += GetString(minutes) + "m"; + } + + if ((1 <= seconds) || s.empty()) { + if (!s.empty()) s += " "; + s += GetString(seconds) + "s"; + } + + return s; +} + +Record* Timer::_GetRecord() const +// ************************ +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Time", &_time)); + return record; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Timer.h b/hurricane/src/hurricane/Timer.h new file mode 100644 index 00000000..6b3d2a77 --- /dev/null +++ b/hurricane/src/hurricane/Timer.h @@ -0,0 +1,61 @@ +// **************************************************************************************************** +// File: Timer.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_TIMER +#define HURRICANE_TIMER + +#include "Commons.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Timer declaration +// **************************************************************************************************** + +class Timer { +// ******** + +// Attributes +// ********** + + private: time_t _time; + +// Constructors +// ************ + + public: Timer(); + + public: Timer(const Timer& timer); + +// Operators +// ********* + + public: Timer& operator=(const Timer& timer); + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("Timer"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + +}; + + + +} // End of Hurricane namespace. + + +ValueIOStreamSupport(Hurricane::Timer) + + +#endif // HURRICANE_TIMER + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Transformation.cpp b/hurricane/src/hurricane/Transformation.cpp new file mode 100644 index 00000000..ccc66f04 --- /dev/null +++ b/hurricane/src/hurricane/Transformation.cpp @@ -0,0 +1,290 @@ +// **************************************************************************************************** +// File: Transformation.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Transformation.h" + +namespace Hurricane { + +#define TO Transformation::Orientation + + + +// **************************************************************************************************** +// Variables +// **************************************************************************************************** + +static const int A[8] = {1, 0, -1, 0, -1, 0, 1, 0}; +static const int B[8] = {0, -1, 0, 1, 0, -1, 0, 1}; +static const int C[8] = {0, 1, 0, -1, 0, -1, 0, 1}; +static const int D[8] = {1, 0, -1, 0, 1, 0, -1, 0}; + +static const Transformation::Orientation INVERT[8] = + {TO::ID, TO::R3, TO::R2, TO::R1, TO::MX, TO::XR, TO::MY, TO::YR}; + +static const int DISCREMINENT[8] = {1, 1, 1, 1, -1, -1, -1, -1}; + +static const Transformation::Orientation COMPOSE[] = { + TO::ID, TO::R1, TO::R2, TO::R3, TO::MX, TO::XR, TO::MY, TO::YR, + TO::R1, TO::R2, TO::R3, TO::ID, TO::XR, TO::MY, TO::YR, TO::MX, + TO::R2, TO::R3, TO::ID, TO::R1, TO::MY, TO::YR, TO::MX, TO::XR, + TO::R3, TO::ID, TO::R1, TO::R2, TO::YR, TO::MX, TO::XR, TO::MY, + TO::MX, TO::YR, TO::MY, TO::XR, TO::ID, TO::R3, TO::R2, TO::R1, + TO::XR, TO::MX, TO::YR, TO::MY, TO::R1, TO::ID, TO::R3, TO::R2, + TO::MY, TO::XR, TO::MX, TO::YR, TO::R2, TO::R1, TO::ID, TO::R3, + TO::YR, TO::MY, TO::XR, TO::MX, TO::R3, TO::R2, TO::R1, TO::ID +}; + + + +// **************************************************************************************************** +// Transformation implementation +// **************************************************************************************************** + +Transformation::Transformation() +// ***************************** +: _tx(0), + _ty(0), + _orientation() +{ +} + +Transformation::Transformation(const Unit& tx, const Unit& ty, const Orientation& orientation) +// ******************************************************************************************* +: _tx(tx), + _ty(ty), + _orientation(orientation) +{ +} + +Transformation::Transformation(const Point& translation, const Orientation& orientation) +// ************************************************************************************* +: _tx(translation.GetX()), + _ty(translation.GetY()), + _orientation(orientation) +{ +} + +Transformation::Transformation(const Transformation& transformation) +// ***************************************************************** +: _tx(transformation._tx), + _ty(transformation._ty), + _orientation(transformation._orientation) +{ +} + +Transformation& Transformation::operator=(const Transformation& transformation) +// **************************************************************************** +{ + _tx = transformation._tx; + _ty = transformation._ty; + _orientation = transformation._orientation; + return *this; +} + +bool Transformation::operator==(const Transformation& transformation) const +// ************************************************************************ +{ + return ((_tx == transformation._tx) && + (_ty == transformation._ty) && + (_orientation == transformation._orientation)); +} + +bool Transformation::operator!=(const Transformation& transformation) const +// ************************************************************************ +{ + return ((_tx != transformation._tx) || + (_ty != transformation._ty) || + (_orientation != transformation._orientation)); +} + +Unit Transformation::GetX(const Unit& x, const Unit& y) const +// ********************************************************** +{ + return (x * A[_orientation]) + (y * B[_orientation]) + _tx; +} + +Unit Transformation::GetY(const Unit& x, const Unit& y) const +// ********************************************************** +{ + return (x * C[_orientation]) + (y * D[_orientation]) + _ty; +} + +Unit Transformation::GetX(const Point& point) const +// ************************************************ +{ + return GetX(point.GetX(), point.GetY()); +} + +Unit Transformation::GetY(const Point& point) const +// ************************************************ +{ + return GetY(point.GetX(), point.GetY()); +} + +Unit Transformation::GetDx(const Unit& dx, const Unit& dy) const +// ************************************************************* +{ + return (dx * A[_orientation]) + (dy * B[_orientation]); +} + +Unit Transformation::GetDy(const Unit& dx, const Unit& dy) const +// ************************************************************* +{ + return (dx * C[_orientation]) + (dy * D[_orientation]); +} + +Point Transformation::GetPoint(const Unit& x, const Unit& y) const +// *************************************************************** +{ + return Point(GetX(x, y), GetY(x, y)); +} + +Point Transformation::GetPoint(const Point& point) const +// ***************************************************** +{ + return GetPoint(point.GetX(), point.GetY()); +} + +Box Transformation::GetBox(const Unit& x1, const Unit& y1, const Unit& x2, const Unit& y2) const +// ********************************************************************************************* +{ + return Box(GetX(x1, y1), GetY(x1, y1), GetX(x2, y2), GetY(x2, y2)); +} + +Box Transformation::GetBox(const Point& point1, const Point& point2) const +// *********************************************************************** +{ + return GetBox(point1.GetX(), point1.GetY(), point2.GetX(), point2.GetY()); +} + +Box Transformation::GetBox(const Box& box) const +// ********************************************* +{ + if (box.IsEmpty()) return box; + return GetBox(box.GetXMin(), box.GetYMin(), box.GetXMax(), box.GetYMax()); +} + +Transformation Transformation::GetTransformation(const Transformation& transformation) const +// ***************************************************************************************** +{ + Unit x = transformation._tx; + Unit y = transformation._ty; + + return Transformation( + (x * A[_orientation]) + (y * B[_orientation]) + _tx, + (x * C[_orientation]) + (y * D[_orientation]) + _ty, + COMPOSE[(_orientation * 8) + transformation._orientation]); +} + +Transformation Transformation::GetInvert() const +// ********************************************* +{ + Transformation transformation = *this; + return transformation.Invert(); +} + +Transformation& Transformation::Invert() +// ************************************* +{ + return operator=( + Transformation( + ((_ty * B[_orientation]) - (_tx * D[_orientation])) * DISCREMINENT[_orientation], + ((_tx * C[_orientation]) - (_ty * A[_orientation])) * DISCREMINENT[_orientation], + INVERT[_orientation])); +} + +void Transformation::ApplyOn(Unit& x, Unit& y) const +// ************************************************* +{ + Unit xi = x, yi = y; + x = GetX(xi, yi); + y = GetY(xi, yi); +} + +void Transformation::ApplyOn(Point& point) const +// ********************************************* +{ + point = GetPoint(point); +} + +void Transformation::ApplyOn(Box& box) const +// ***************************************** +{ + box = GetBox(box); +} + +void Transformation::ApplyOn(Transformation& transformation) const +// *************************************************************** +{ + transformation = GetTransformation(transformation); +} + +string Transformation::_GetString() const +// ************************************** +{ + return "<" + _TName("Transformation") + " " + + GetValueString(_tx) + " " + + GetValueString(_ty) + " " + + GetString(_orientation) + + ">"; +} + +Record* Transformation::_GetRecord() const +// ********************************* +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("X", &_tx)); + record->Add(GetSlot("Y", &_ty)); + record->Add(GetSlot("Orientation", _orientation)); + return record; +} + + + +// **************************************************************************************************** +// Transformation::Orientation implementation +// **************************************************************************************************** + +Transformation::Orientation::Orientation(const Code& code) +// ******************************************************* +: _code(code) +{ +} + +Transformation::Orientation::Orientation(const Orientation& orientation) +// ********************************************************************* +: _code(orientation._code) +{ +} + +Transformation::Orientation& Transformation::Orientation::operator=(const Orientation& orientation) +// ************************************************************************************************ +{ + _code = orientation._code; + return *this; +} + +string Transformation::Orientation::_GetString() const +// *************************************************** +{ + return GetString(&_code); +} + +Record* Transformation::Orientation::_GetRecord() const +// ********************************************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Code", &_code)); + return record; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Transformation.h b/hurricane/src/hurricane/Transformation.h new file mode 100644 index 00000000..38162e28 --- /dev/null +++ b/hurricane/src/hurricane/Transformation.h @@ -0,0 +1,178 @@ +// **************************************************************************************************** +// File: Transformation.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_TRANSFORMATION +#define HURRICANE_TRANSFORMATION + +#include "Box.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Transformation declaration +// **************************************************************************************************** + +class Transformation { +// ***************** + +// Types +// ***** + + public: class Orientation { + // ********************** + + public: enum Code {ID=0, R1=1, R2=2, R3=3, MX=4, XR=5, MY=6, YR=7}; + + private: Code _code; + + public: Orientation(const Code& code = ID); + public: Orientation(const Orientation& orientation); + + public: Orientation& operator=(const Orientation& orientation); + + public: operator const Code&() const {return _code;}; + + public: const Code& GetCode() const {return _code;}; + + public: string _GetTypeName() const { return _TName("Transformation::Orientation"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + }; + +// Attributes +// ********** + + private: Unit _tx; + private: Unit _ty; + private: Orientation _orientation; + +// Constructors +// ************ + + public: Transformation(); + + public: Transformation(const Unit& tx, const Unit& ty, const Orientation& orientation = Orientation::ID); + public: Transformation(const Point& translation, const Orientation& orientation = Orientation::ID); + + public: Transformation(const Transformation& transformation); + +// Operators +// ********* + + public: Transformation& operator=(const Transformation& transformation); + + public: bool operator==(const Transformation& transformation) const; + public: bool operator!=(const Transformation& transformation) const; + +// Accessors +// ********* + + public: const Unit& GetTx() const {return _tx;}; + public: const Unit& GetTy() const {return _ty;}; + public: Point GetTranslation() const {return Point(_tx, _ty);}; + public: const Orientation& GetOrientation() const {return _orientation;}; + + public: Unit GetX(const Unit& x, const Unit& y) const; + public: Unit GetY(const Unit& x, const Unit& y) const; + + public: Unit GetX(const Point& point) const; + public: Unit GetY(const Point& point) const; + + public: Unit GetDx(const Unit& dx, const Unit& dy) const; + public: Unit GetDy(const Unit& dx, const Unit& dy) const; + + public: Point GetPoint(const Unit& x, const Unit& y) const; + public: Point GetPoint(const Point& point) const; + + public: Box GetBox(const Unit& x1, const Unit& y1, const Unit& x2, const Unit& y2) const; + public: Box GetBox(const Point& point1, const Point& point2) const; + public: Box GetBox(const Box& box) const; + + public: Transformation GetTransformation(const Transformation& transformation) const; + + public: Transformation GetInvert() const; + +// Predicates +// ********** + + public: bool IsEven() const {return !(_orientation.GetCode() & 1);}; + public: bool IsOdd() const {return (_orientation.GetCode() & 1);}; + +// Updators +// ******** + + public: Transformation& Invert(); + +// Manipulators +// ************ + + public: void ApplyOn(Unit& x, Unit& y) const; + public: void ApplyOn(Point& point) const; + public: void ApplyOn(Box& box) const; + public: void ApplyOn(Transformation& transformation) const; + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("Transformation"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + +}; + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +template<> + inline string ProxyTypeName + ( const Transformation::Orientation::Code* object ) + { return ">"; } + +template<> + inline string ProxyString + ( const Transformation::Orientation::Code* object ) + { + switch ( *object ) { + case Transformation::Orientation::ID: return "ID"; + case Transformation::Orientation::R1: return "R1"; + case Transformation::Orientation::R2: return "R2"; + case Transformation::Orientation::R3: return "R3"; + case Transformation::Orientation::MX: return "MX"; + case Transformation::Orientation::XR: return "XR"; + case Transformation::Orientation::MY: return "MY"; + case Transformation::Orientation::YR: return "YR"; + } + return "ABNORMAL"; + } + +template<> + inline Record* ProxyRecord + ( const Transformation::Orientation::Code* object ) + { + Record* record = new Record(GetString(object)); + record->Add(GetSlot("Code", (unsigned int*)object)); + return record; + } + + + +} // End of Hurricane namespace. + + +ValueIOStreamSupport(Hurricane::Transformation) + + +#endif // HURRICANE_TRANSFORMATION + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Unit.cpp b/hurricane/src/hurricane/Unit.cpp new file mode 100644 index 00000000..15dced7e --- /dev/null +++ b/hurricane/src/hurricane/Unit.cpp @@ -0,0 +1,186 @@ +// **************************************************************************************************** +// File: Unit.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Unit.h" +#include "Error.h" + +#include + +namespace Hurricane { + + + +// **************************************************************************************************** +// Constants & Variables +// **************************************************************************************************** + +static const unsigned MAXIMAL_PRECISION_ALLOWED = 3; + +static unsigned PRECISION = 0; +static double RESOLUTION = 1; + +static Unit GRID_STEP = 1; + + + +// **************************************************************************************************** +// Precision managers +// **************************************************************************************************** + +unsigned GetPrecision() +// ******************** +{ + return PRECISION; +} + +unsigned GetMaximalPrecisionAllowed() +// ********************************** +{ + return MAXIMAL_PRECISION_ALLOWED; +} + +void SetPrecision(unsigned precision) +// ********************************** +{ + if (MAXIMAL_PRECISION_ALLOWED < precision) + throw Error("Can't set precision : not allowed"); + + PRECISION = precision; + + RESOLUTION = 1; + while (precision--) RESOLUTION /= 10; + + SetGridStep(GetUnit(1)); +} + + + +// **************************************************************************************************** +// Resolution managers +// **************************************************************************************************** + +double GetResolution() +// ******************* +{ + return RESOLUTION; +} + + + +// **************************************************************************************************** +// Grid managers +// **************************************************************************************************** + +const Unit& GetGridStep() +// ********************** +{ + return GRID_STEP; +} + +void SetGridStep(const Unit& gridStep) +// *********************************** +{ + if (!gridStep) throw Error("Can't set grid step : invalid value"); + + GRID_STEP = gridStep; +} + +bool IsOnGrid(const Unit& unit, int n) +// *********************************** +{ + if (n <= 0) throw Error("Can't compute : invalid value"); + + n *= GRID_STEP; + + return (((abs(unit) / n) * n) == abs(unit)); +} + +Unit GetOnGridUnit(const Unit& unit, int s) +// **************************************** +{ + switch (s) { + case -1 : { + if (0 < unit) return (unit / GRID_STEP) * GRID_STEP; + else if (unit < 0) return ((unit / GRID_STEP) - 1) * GRID_STEP; + return unit; + } + case 0 : { + int g1 = (unit / GRID_STEP) * GRID_STEP; + int g2 = ((g1 < unit) ? (g1 + GRID_STEP) : (g1 - GRID_STEP)); + return (abs(g1 - unit) <= abs(g2 - unit)) ? g1 : g2; + } + case +1 : { + if (0 < unit) return ((unit / GRID_STEP) + 1) * GRID_STEP; + else if (unit < 0) return (unit / GRID_STEP) * GRID_STEP; + return unit; + } + } + throw Error("Can't get on grid unit : invalid parameter s (should be -1, 0 or +1)"); + return 0; +} + + + +// **************************************************************************************************** +// Others +// **************************************************************************************************** + +Unit GetUnit(double value) +// *********************** +{ + return (int)rint(value / RESOLUTION); +} + +double GetValue(const Unit& unit) +// ****************************** +{ + return (unit * RESOLUTION); +} + +string GetValueString(const Unit& unit) +// ************************************ +{ + if (unit == 0) return "0"; + + char buffer[32]; + unsigned length = sprintf(buffer, "%ld", abs(unit)); + if (length <= PRECISION) { + unsigned offset = PRECISION - length + 1; + for (int i = length; 0 <= i; i--) buffer[i + offset] = buffer[i]; + for (unsigned i = 0; i < offset; i++) buffer[i] = '0'; + length += offset; + } + for (unsigned i = 0; i <= PRECISION; i++) + buffer[length - i + 1] = buffer[length - i]; + buffer[length - PRECISION] = '.'; + while (buffer[length] == '0') buffer[length--] = '\0'; + if (buffer[length] == '.') buffer[length--] = '\0'; + if (0 < unit) + return buffer; + else + return "-" + string(buffer); +} + + + +} // End of Hurricane namespace. + + + +bool Scan(const string& s, H::Unit& unit) +// *********************************** +{ + double d; + if (Scan(s, d)) { + unit = H::GetUnit(d); + return true; + } + return false; +} + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Unit.h b/hurricane/src/hurricane/Unit.h new file mode 100644 index 00000000..ed7a6dc4 --- /dev/null +++ b/hurricane/src/hurricane/Unit.h @@ -0,0 +1,106 @@ +// **************************************************************************************************** +// File: Unit.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_UNIT +#define HURRICANE_UNIT + +#include "Commons.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Unit declaration +// **************************************************************************************************** + +typedef long Unit; + +# define UNIT_MAX LONG_MAX +# define UNIT_MIN LONG_MIN + + + +// **************************************************************************************************** +// Precision managers (precision defines the maximal number of decimals allowed) +// **************************************************************************************************** + +unsigned GetPrecision(); + +unsigned GetMaximalPrecisionAllowed(); + +void SetPrecision(unsigned precision); +// Should be called only once at the beginning of the program + + + +// **************************************************************************************************** +// Resolution managers (the value associate to the unit 1) +// **************************************************************************************************** + +double GetResolution(); + + + +// **************************************************************************************************** +// Grid managers +// **************************************************************************************************** + +const Unit& GetGridStep(); + +void SetGridStep(const Unit& gridStep); + +bool IsOnGrid(const Unit& unit, int n = 1); + +Unit GetOnGridUnit(const Unit& unit, int s = 0); + + + +// **************************************************************************************************** +// Others +// **************************************************************************************************** + +Unit GetUnit(double value); + +double GetValue(const Unit& unit); + +string GetValueString(const Unit& unit); + + + + +// ------------------------------------------------------------------- +// Class : "Proxy...". + +/* template<> */ +/* inline string ProxyTypeName ( const Unit* object ) */ +/* { return ">"; } */ + +/* template<> */ +/* inline string ProxyString ( const Unit* object ) */ +/* { return GetValueString(); } */ + +/* template<> */ +/* inline Record* ProxyRecord ( const Unit* object ) */ +/* { */ +/* Record* record = new Record(GetString(object)); */ +/* record->Add(GetSlot("Unit", (unsigned int*)_object)); */ +/* return record; */ +/* } */ + + + +} // End of Hurricane namespace. + + + +bool Scan(const string& s, H::Unit& unit); + +#endif // HURRICANE_UNIT + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/UpdateSession.cpp b/hurricane/src/hurricane/UpdateSession.cpp new file mode 100644 index 00000000..3810f54c --- /dev/null +++ b/hurricane/src/hurricane/UpdateSession.cpp @@ -0,0 +1,191 @@ +// **************************************************************************************************** +// File: UpdateSession.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "UpdateSession.h" +#include "Go.h" +#include "Cell.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// UpdateSession implementation +// **************************************************************************************************** + +stack* UPDATOR_STACK = NULL; + +UpdateSession::UpdateSession() +// *************************** +: Inherit() +{ +} + +void UpdateSession::Delete() +// ************************* +{ + throw Error("Abnormal deletion of " + _TName("UpdateSession")); +} + +const Name& UpdateSession::GetPropertyName() +// ***************************************** +{ + static Name NAME = _PName("UpdateSession"); + return NAME; +} + +UpdateSession* UpdateSession::_Create() +// ************************************ +{ + UpdateSession* updateSession = new UpdateSession(); + + updateSession->_PostCreate(); + + return updateSession; +} + +void UpdateSession::_PostCreate() +// ****************************** +{ + Inherit::_PostCreate(); + + if (!UPDATOR_STACK) UPDATOR_STACK = new stack(); + + UPDATOR_STACK->push(this); +} + +void UpdateSession::_Delete() +// ************************** +{ + Inherit::Delete(); +} + +void UpdateSession::_PreDelete() +// ***************************** +{ + if (!UPDATOR_STACK || UPDATOR_STACK->empty()) + throw Error("Invalid update session deletion : empty stack"); + + if (UPDATOR_STACK->top() != this) + throw Error("Invalid update session deletion : not on top"); + + UPDATOR_STACK->pop(); + + for_each_dbo(owner, GetOwners()) { + if (is_a(owner)) ((Go*)owner)->Materialize(); + end_for; + } + + Inherit::_PreDelete(); +} + +string UpdateSession::_GetString() const +// ************************************* +{ + return "<" + _TName("UpdateSession") + ">"; +} + +Record* UpdateSession::_GetRecord() const +// ******************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + } + return record; +} + +void UpdateSession::OnCapturedBy(DBo* owner) +// ***************************************** +{ + if (!is_a(owner)) + throw Error("Bad update session capture : not a graphic object"); + + Inherit::OnCapturedBy(owner); +} + +void UpdateSession::OnNotOwned() +// ***************************** +{ +} + + + +// **************************************************************************************************** +// Go::Invalidate implementation : located here to access UPDATOR_STACK variable +// **************************************************************************************************** + +void Go::Invalidate(bool propagateFlag) +// ************************************ +{ +// trace << "Invalidate(" << this << ")" << endl; +// trace_in(); + + if (!UPDATOR_STACK || UPDATOR_STACK->empty()) + throw Error("Can't invalidate go : empty update session stack"); + + Property* property = GetProperty(UpdateSession::GetPropertyName()); + + if (property) { + if (!is_a(property)) + throw Error("Can't invalidate go : bad update session type"); + } + else { + SlaveEntityMap::iterator it; + SlaveEntityMap::iterator end; + GetCell()->_GetSlaveEntities(this,it,end); + for(; it != end ; it++) { + Go* go = dynamic_cast(it->second); + if (go) go->Invalidate(propagateFlag); + } + + if (IsMaterialized()) { + Unmaterialize(); + Put(UPDATOR_STACK->top()); + } + } +// trace << "done" << endl; +// trace_out(); +} + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +void OpenUpdateSession() +// ********************* +{ +// trace << "OpenUpdateSession()" << endl; +// trace_in(); + UpdateSession::_Create(); +} + +void CloseUpdateSession() +// ********************** +{ +// trace << "CloseUpdateSession()" << endl; +// trace_in(); + + if (!UPDATOR_STACK || UPDATOR_STACK->empty()) + throw Error("Can't end update : empty update session stack"); + + UPDATOR_STACK->top()->_Delete(); + +// trace << "done" << endl; +// trace_out(); +// trace << "done" << endl; +// trace_out(); +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/UpdateSession.h b/hurricane/src/hurricane/UpdateSession.h new file mode 100644 index 00000000..96b9db04 --- /dev/null +++ b/hurricane/src/hurricane/UpdateSession.h @@ -0,0 +1,84 @@ +// **************************************************************************************************** +// File: UpdateSession.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_UPDATE_SESSION +#define HURRICANE_UPDATE_SESSION + +#include "Property.h" + +namespace Hurricane { + +class Go; + + + +// **************************************************************************************************** +// UpdateSession declaration +// **************************************************************************************************** + +class UpdateSession : public SharedProperty { +// **************************************** + +// Types +// ***** + + public: typedef SharedProperty Inherit; + +// Constructors +// ************ + + protected: UpdateSession(); + + public: virtual void Delete(); + +// Accessors +// ********* + + public: static const Name& GetPropertyName(); + public: virtual Name GetName() const {return GetPropertyName();}; + +// Managers +// ******** + + public: virtual void OnCapturedBy(DBo* owner); + public: virtual void OnNotOwned(); + +// Ohers +// ***** + + public: static UpdateSession* _Create(); + protected: virtual void _PostCreate(); + + public: void _Delete(); + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("UpdateSession");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + +}; + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +void OpenUpdateSession(); + +void CloseUpdateSession(); + + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::UpdateSession) + +#endif // HURRICANE_UPDATE_SESSION + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/UserGo.cpp b/hurricane/src/hurricane/UserGo.cpp new file mode 100644 index 00000000..6f031979 --- /dev/null +++ b/hurricane/src/hurricane/UserGo.cpp @@ -0,0 +1,306 @@ +// **************************************************************************************************** +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: UserGo.cpp +// Authors: C. Alexandre +// **************************************************************************************************** + +#include "Cell.h" +#include "UserGo.h" + +namespace Hurricane { + + +// **************************************************************************************************** +// UserGo_CellUserGos implementation +// **************************************************************************************************** + +class UserGo_CellUserGos : public Collection { +// ************************************************** + +// Types +// ***** + + public: typedef Collection Inherit; + + public: class Locator : public Hurricane::Locator { + // ******************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const Cell* _cell; + private: DisplaySlotLocator _displaySlotLocator; + private: UserGoLocator _userGoLocator; + + public: Locator(); + public: Locator(const Cell* cell); + public: Locator(const Locator& locator); + + public: Locator& operator=(const Locator& locator); + + public: virtual UserGo* GetElement() const; + public: virtual Hurricane::Locator* GetClone() const; + + public: virtual bool IsValid() const; + + public: virtual void Progress(); + + public: virtual string _GetString() const; + + }; + +// Attributes +// ********** + + private: const Cell* _cell; + +// Constructors +// ************ + + public: UserGo_CellUserGos(); + public: UserGo_CellUserGos(const Cell* cell); + public: UserGo_CellUserGos(const UserGo_CellUserGos& cellusergos); + +// Operators +// ********* + + public: UserGo_CellUserGos& operator=(const UserGo_CellUserGos& usergos); + +// Accessors +// ********* + + public: virtual Collection* GetClone() const; + public: virtual Hurricane::Locator* GetLocator() const; + +// Others +// ****** + + public: virtual string _GetString() const; + +}; + +// **************************************************************************************************** +// UserGo implementation +// **************************************************************************************************** + +UserGo::UserGo(DisplaySlot* displaySlot) +// ************************************* + : Inherit() + , _displaySlot(displaySlot) +{ + if (!_displaySlot) + throw Error("Can't Create " + _TName("UserGo") + " null displaySlot"); +} + +void UserGo::Materialize() +// *********************** +{ + if (!IsMaterialized()) { + QuadTree& quadTree = _displaySlot->_GetQuadTree(); + quadTree.Insert(this); + GetCell()->_Fit(quadTree.GetBoundingBox()); + } +} + +void UserGo::Unmaterialize() +// ************************* +{ + if (IsMaterialized()) { + QuadTree& quadTree = _displaySlot->_GetQuadTree(); + GetCell()->_Unfit(GetBoundingBox()); + quadTree.Remove(this); + } +} + +void UserGo::_PostCreate() +// *********************** +{ + Inherit::_PostCreate(); +} + +void UserGo::_PreDelete() +// ********************** +{ + Inherit::_PreDelete(); +} + +string UserGo::_GetString() const +// ****************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_displaySlot->GetName())); + return s; +} + +Record* UserGo::_GetRecord() const +// ************************* +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("DisplaySlot", _displaySlot)); + } + return record; +} + +UserGos GetUserGos(const Cell* cell) +// ********************************* +{ + if (!cell) + throw Error("Null pointer on cell while getting usergos"); + return UserGo_CellUserGos(cell); +} + +// **************************************************************************************************** +// UserGo_CellUserGos implementation +// **************************************************************************************************** + +UserGo_CellUserGos::UserGo_CellUserGos() +// ************************************* +: Inherit(), + _cell(NULL) +{ +} + +UserGo_CellUserGos::UserGo_CellUserGos(const Cell* cell) +// ***************************************************** +: Inherit(), + _cell(cell) +{ +} + +UserGo_CellUserGos::UserGo_CellUserGos(const UserGo_CellUserGos& usergos) +// ********************************************************************** +: Inherit(), + _cell(usergos._cell) +{ +} + +UserGo_CellUserGos& UserGo_CellUserGos::operator=(const UserGo_CellUserGos& usergos) +// ********************************************************************************* +{ + _cell = usergos._cell; + return *this; +} + +Collection* UserGo_CellUserGos::GetClone() const +// ****************************************************** +{ + return new UserGo_CellUserGos(*this); +} + +Locator* UserGo_CellUserGos::GetLocator() const +// ***************************************************** +{ + return new Locator(_cell); +} + +string UserGo_CellUserGos::_GetString() const +// ****************************************** +{ + string s = "<" + _TName("Cell::UserGos"); + if (_cell) { + s += " " + GetString(_cell); + } + s += ">"; + return s; +} + + + +// **************************************************************************************************** +// UserGo_CellUserGos::Locator implementation +// **************************************************************************************************** + +UserGo_CellUserGos::Locator::Locator() +// **************************** +: Inherit(), + _cell(NULL), + _displaySlotLocator(), + _userGoLocator() +{ +} + +UserGo_CellUserGos::Locator::Locator(const Cell* cell) +// *************************************************** +: Inherit(), + _cell(cell), + _displaySlotLocator(), + _userGoLocator() +{ + if (_cell) { + _displaySlotLocator = GetDisplaySlots(cell).GetLocator(); + if (_displaySlotLocator.IsValid()) + { + DisplaySlot* displaySlot = _displaySlotLocator.GetElement(); + _userGoLocator = displaySlot->GetUserGos().GetLocator(); + } + } +} + +UserGo_CellUserGos::Locator::Locator(const Locator& locator) +// ************************************************** +: Inherit(), + _cell(locator._cell), + _displaySlotLocator(locator._displaySlotLocator), + _userGoLocator(locator._userGoLocator) +{ +} + +UserGo_CellUserGos::Locator& UserGo_CellUserGos::Locator::operator=(const Locator& locator) +// **************************************************************************************** +{ + _cell = locator._cell; + _displaySlotLocator = locator._displaySlotLocator; + _userGoLocator =locator._userGoLocator; + return *this; +} + +UserGo* UserGo_CellUserGos::Locator::GetElement() const +// ******************************************** +{ + return _userGoLocator.GetElement(); +} + +Locator* UserGo_CellUserGos::Locator::GetClone() const +// ************************************************************ +{ + return new Locator(*this); +} + +bool UserGo_CellUserGos::Locator::IsValid() const +// *************************************** +{ + return _userGoLocator.IsValid(); +} + +void UserGo_CellUserGos::Locator::Progress() +// ***************************************** +{ + if (_userGoLocator.IsValid()) { + _userGoLocator.Progress(); + } + else if (_displaySlotLocator.IsValid()) { + _displaySlotLocator.Progress(); + if (_displaySlotLocator.IsValid()) + { + DisplaySlot* displaySlot = _displaySlotLocator.GetElement(); + _userGoLocator = displaySlot->GetUserGos().GetLocator(); + } + } +} + +string UserGo_CellUserGos::Locator::_GetString() const +// ******************************************** +{ + string s = "<" + _TName("Cell::UserGos::Locator"); + if (_cell) { + s += " " + GetString(_cell); + } + s += ">"; + return s; +} + +} // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/UserGo.h b/hurricane/src/hurricane/UserGo.h new file mode 100644 index 00000000..7a7bb137 --- /dev/null +++ b/hurricane/src/hurricane/UserGo.h @@ -0,0 +1,68 @@ +// **************************************************************************************************** +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: UserGo.h +// Authors: C. Alexandre +// **************************************************************************************************** + +#ifndef HURRICANE_USER_GO +#define HURRICANE_USER_GO + +#include "Go.h" +#include "UserGos.h" +#include "DisplaySlot.h" + +namespace Hurricane { + +// **************************************************************************************************** +// UserGo declaration +// **************************************************************************************************** + +class UserGo : public Go { +// ********************* + +// Types +// ***** + + public: typedef Go Inherit; + +// Attributes +// ********** + protected: DisplaySlot* _displaySlot; + +// Constructors +// ************ + + protected: UserGo(DisplaySlot* displaySlot); + +// Destructor +// ********** + +// Accessors +// ********* + +// Updators +// ******** + + public: virtual void Materialize(); + public: virtual void Unmaterialize(); + +// Others +// ****** + + protected: virtual void _PostCreate(); + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("UserGo");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; +}; + +UserGos GetUserGos(const Cell* cell); + +} // End of Hurricane namespace. + +#endif // HURRICANE_USER_GO diff --git a/hurricane/src/hurricane/UserGos.h b/hurricane/src/hurricane/UserGos.h new file mode 100644 index 00000000..e7ffe622 --- /dev/null +++ b/hurricane/src/hurricane/UserGos.h @@ -0,0 +1,61 @@ +// **************************************************************************************************** +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +// File: UserGos.h +// Authors: C. Alexandre +// **************************************************************************************************** + +#ifndef HURRICANE_USER_GOS +#define HURRICANE_USER_GOS + +#include "Collection.h" + +namespace Hurricane { + +class UserGo; + + + +// **************************************************************************************************** +// UserGosdeclaration +// **************************************************************************************************** + +typedef GenericCollection UserGos; + + + +// **************************************************************************************************** +// UserGoLocator declaration +// **************************************************************************************************** + +typedef GenericLocator UserGoLocator; + + + +// **************************************************************************************************** +// UserGoFilter declaration +// **************************************************************************************************** + +typedef GenericFilter UserGoFilter; + + + +// **************************************************************************************************** +// for_each_usergo declaration +// **************************************************************************************************** + +#define for_each_user_go(userGo, userGos)\ +/***************************************/\ +{\ + UserGoLocator _locator = userGos.GetLocator();\ + while (_locator.IsValid()) {\ + UserGo* userGo = _locator.GetElement();\ + _locator.Progress(); + + +} // End of Hurricane namespace. + +#endif // HURRICANE_USER_GOS diff --git a/hurricane/src/hurricane/VectorCollection.h b/hurricane/src/hurricane/VectorCollection.h new file mode 100644 index 00000000..a8aed893 --- /dev/null +++ b/hurricane/src/hurricane/VectorCollection.h @@ -0,0 +1,203 @@ +// **************************************************************************************************** +// File: VectorCollection.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_VECTOR_COLLECTION +#define HURRICANE_VECTOR_COLLECTION + +#include "Commons.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// VectorCollection declaration +// **************************************************************************************************** + +template class VectorCollection : public Collection { +// ************************************************************************ + +// Types +// ***** + + public: typedef Collection Inherit; + + public: typedef vector ElementVector; + + public: class Locator : public Hurricane::Locator { + // ******************************************************* + + public: typedef Hurricane::Locator Inherit; + + private: const ElementVector* _elementVector; + private: typename ElementVector::const_iterator _iterator; // AD + + public: Locator(const ElementVector* elementVector) + // ************************************************ + : Inherit(), + _elementVector(elementVector), + _iterator() + { + if (_elementVector) _iterator = _elementVector->begin(); + }; + + public: virtual Element GetElement() const + // *************************************** + { + return (IsValid()) ? *_iterator : Element(); + }; + + public: virtual Hurricane::Locator* GetClone() const + // ********************************************************** + { + return new Locator(_elementVector); + }; + + public: virtual bool IsValid() const + // ********************************* + { + return (_elementVector && (_iterator != _elementVector->end())); + }; + + public: virtual void Progress() + // **************************** + { + ++_iterator; + }; + + }; + +// Attributes +// ********** + + private: const ElementVector* _elementVector; + +// Constructors +// ************ + + public: VectorCollection(const ElementVector* elementVector = NULL) + // **************************************************************** + : Inherit(), + _elementVector(elementVector) + { + }; + + public: VectorCollection(const ElementVector& elementVector) + // ********************************************************* + : Inherit(), + _elementVector(&elementVector) + { + }; + + public: VectorCollection(const VectorCollection& vectorCollection) + // *************************************************************** + : Inherit(), + _elementVector(vectorCollection._elementVector) + { + }; + +// Operators +// ********* + + public: VectorCollection& operator=(const VectorCollection& vectorCollection) + // ************************************************************************** + { + _elementVector = vectorCollection._elementVector; + return *this; + }; + +// Accessors +// ********* + + public: virtual Collection* GetClone() const + // ************************************************** + { + return new VectorCollection(*this); + } + + public: virtual Hurricane::Locator* GetLocator() const + // ************************************************************ + { + // return (_elementVector) ? new Locator(_elementVector) : NULL; + // V3 + return (_elementVector) ? new Locator(_elementVector) : NULL; + } + + public: virtual unsigned GetSize() const + // ************************************* + { + return (_elementVector) ? _elementVector->size() : 0; + }; + +// Others +// ****** + + public: virtual string _GetTypeName() const + // ************************************** + { + return _TName("VectorCollection"); + }; + + public: virtual string _GetString() const + // ************************************** + { + if (!_elementVector) + return "<" + _GetTypeName() + " unbound>"; + else { + if (_elementVector->empty()) + return "<" + _GetTypeName() + " empty>"; + else + return "<" + _GetTypeName() + " " + GetString(_elementVector->size()) + ">"; + } + }; + + public: Record* _GetRecord() const + // ************************* + { + H::Record* record = NULL; + if (!_elementVector->empty()) { + record = new Record(_GetString()); + unsigned n = 1; + typename vector::const_iterator iterator = _elementVector->begin(); // AD + while (iterator != _elementVector->end()) { + record->Add(GetSlot(GetString(n++), *iterator)); + ++iterator; + } + } + return record; + } + +}; + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +template + inline GenericCollection GetCollection(const vector& elementVector) +// ************************************************************************************* +{ + return VectorCollection(elementVector); +} + +template + inline GenericCollection GetCollection(const vector* elementVector) +// ************************************************************************************* +{ + return VectorCollection(elementVector); +} + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_VECTOR_COLLECTION + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Vertical.cpp b/hurricane/src/hurricane/Vertical.cpp new file mode 100644 index 00000000..bbfa5d84 --- /dev/null +++ b/hurricane/src/hurricane/Vertical.cpp @@ -0,0 +1,174 @@ +// **************************************************************************************************** +// File: Vertical.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Vertical.h" +#include "Net.h" +#include "BasicLayer.h" +#include "CompositeLayer.h" +#include "Plug.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Vertical implementation +// **************************************************************************************************** + +Vertical::Vertical(Net* net, Component* source, Component* target, Layer* layer, const Unit& x, const Unit& width, const Unit& dySource, const Unit& dyTarget) +// **************************************************************************************************** +: Inherit(net, source, target, layer, width), + _x(x), + _dySource(dySource), + _dyTarget(dyTarget) +{ +} + +Vertical* Vertical::Create(Net* net, Layer* layer, const Unit& x, const Unit& width, const Unit& dySource, const Unit& dyTarget) +// **************************************************************************************************** +{ + if (!net) + throw Error("Can't create " + _TName("Vertical") + " : null net"); + + Vertical* vertical = new Vertical(net, NULL, NULL, layer, x, width, dySource, dyTarget); + + vertical->_PostCreate(); + + return vertical; +} + +Vertical* Vertical::Create(Component* source, Component* target, Layer* layer, const Unit& x, const Unit& width, const Unit& dySource, const Unit& dyTarget) +// **************************************************************************************************** +{ + if (!source) + throw Error("Can't create " + _TName("Vertical") + " : null source"); + + if (!target) + throw Error("Can't create " + _TName("Vertical") + " : null target"); + + Vertical* vertical = + new Vertical(source->GetNet(), source, target, layer, x, width, dySource, dyTarget); + + vertical->_PostCreate(); + + return vertical; +} + +Box Vertical::GetBoundingBox() const +// ********************************* +{ + Unit size = GetHalfWidth() + _GetSize(); + Unit extention = _GetExtention(); + + return Box(_x, GetSourceY(), _x, GetTargetY()).Inflate(size, extention); +} + +Box Vertical::GetBoundingBox(BasicLayer* basicLayer) const +// ******************************************************* +{ + if (!GetLayer()->Contains(basicLayer)) return Box(); + + Unit size = GetHalfWidth() + _GetSize(basicLayer); + Unit extention = _GetExtention(basicLayer); + + return Box(_x, GetSourceY(), _x, GetTargetY()).Inflate(size, extention); +} + +Unit Vertical::GetSourceY() const +// ****************************** +{ + Component* source = GetSource(); + return (source) ? source->GetY() + _dySource : _dySource; +} + +Unit Vertical::GetTargetY() const +// ****************************** +{ + Component* target = GetTarget(); + return (target) ? target->GetY() + _dyTarget : _dyTarget; +} + +Unit Vertical::GetLength() const +// ***************************** +{ + return abs(GetSourceY() - GetTargetY()); +} + +Point Vertical::GetCenter() const +// ******************************* +{ + return Point ( GetX(), (GetSourceY()+GetTargetY())/2 ); +} + +void Vertical::Translate(const Unit& dx, const Unit& dy) +// ***************************************************** +{ + if (dx != 0) { + Invalidate(true); + _x += dx; + } +} + +void Vertical::SetX(const Unit& x) +// ******************************* +{ + if (x != _x) { + Invalidate(true); + _x = x; + } +} + +void Vertical::SetDySource(const Unit& dySource) +// ********************************************* +{ + if (dySource != _dySource) { + Invalidate(false); + _dySource = dySource; + } +} + +void Vertical::SetDyTarget(const Unit& dyTarget) +// ********************************************* +{ + if (dyTarget != _dyTarget) { + Invalidate(false); + _dyTarget = dyTarget; + } +} + +void Vertical::Translate(const Unit& dx) +// ************************************* +{ + if (dx != 0) { + Invalidate(true); + _x += dx; + } +} + +string Vertical::_GetString() const +// ******************************** +{ + return Inherit::_GetString(); +} + +Record* Vertical::_GetRecord() const +// *************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("X", &_x)); + record->Add(GetSlot("DySource", &_dySource)); + record->Add(GetSlot("DyTarget", &_dyTarget)); + } + return record; +} + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Vertical.h b/hurricane/src/hurricane/Vertical.h new file mode 100644 index 00000000..2bb7ce55 --- /dev/null +++ b/hurricane/src/hurricane/Vertical.h @@ -0,0 +1,88 @@ +// **************************************************************************************************** +// File: Vertical.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_VERTICAL +#define HURRICANE_VERTICAL + +#include "Segment.h" +#include "Verticals.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Vertical declaration +// **************************************************************************************************** + +class Vertical : public Segment { +// **************************** + +// Types +// ***** + + public: typedef Segment Inherit; + +// Attributes +// ********** + + private: Unit _x; + private: Unit _dySource; + private: Unit _dyTarget; + +// Constructors +// ************ + + protected: Vertical(Net* net, Component* source, Component* target, Layer* layer, const Unit& x, const Unit& width = 0, const Unit& dySource = 0, const Unit& dyTarget = 0); + + public: static Vertical* Create(Net* net, Layer* layer, const Unit& x, const Unit& width = 0, const Unit& dySource = 0, const Unit& dyTarget = 0); + public: static Vertical* Create(Component* source, Component* target, Layer* layer, const Unit& x, const Unit& width = 0, const Unit& dySource = 0, const Unit& dyTarget = 0); + +// Accessors +// ********* + + public: virtual Unit GetX() const {return _x;}; + public: virtual Point GetCenter() const; + public: virtual Box GetBoundingBox() const; + public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const; + public: virtual Unit GetSourceX() const {return GetX();}; + public: virtual Unit GetSourceY() const; + public: virtual Unit GetTargetX() const {return GetX();}; + public: virtual Unit GetTargetY() const; + public: virtual Unit GetLength() const; + public: const Unit& GetDySource() const {return _dySource;}; + public: const Unit& GetDyTarget() const {return _dyTarget;}; + +// Updators +// ******** + + public: virtual void Translate(const Unit& dx, const Unit& dy); + + public: void SetX(const Unit& x); + public: void SetDySource(const Unit& dySource); + public: void SetDyTarget(const Unit& dyTarget); + public: void Translate(const Unit& dx); + +// Others +// ****** + + public: virtual string _GetTypeName() const {return _TName("Vertical");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Vertical) + +#endif // HURRICANE_VERTICAL + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Verticals.h b/hurricane/src/hurricane/Verticals.h new file mode 100644 index 00000000..ebb9cb3c --- /dev/null +++ b/hurricane/src/hurricane/Verticals.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Verticals.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_VERTICALS +#define HURRICANE_VERTICALS + +#include "Collection.h" + +namespace Hurricane { + +class Vertical; + + + +// **************************************************************************************************** +// Verticals declaration +// **************************************************************************************************** + +typedef GenericCollection Verticals; + + + +// **************************************************************************************************** +// VerticalLocator declaration +// **************************************************************************************************** + +typedef GenericLocator VerticalLocator; + + + +// **************************************************************************************************** +// VerticalFilter declaration +// **************************************************************************************************** + +typedef GenericFilter VerticalFilter; + + + +// **************************************************************************************************** +// for_each_vertical declaration +// **************************************************************************************************** + +#define for_each_vertical(vertical, verticals)\ +/*********************************************/\ +{\ + VerticalLocator _locator = verticals.GetLocator();\ + while (_locator.IsValid()) {\ + Vertical* vertical = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_VERTICALS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Views.h b/hurricane/src/hurricane/Views.h new file mode 100644 index 00000000..406ed7f8 --- /dev/null +++ b/hurricane/src/hurricane/Views.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Views.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_VIEWS +#define HURRICANE_VIEWS + +#include "Collection.h" + +namespace Hurricane { + +class View; + + + +// **************************************************************************************************** +// Views declaration +// **************************************************************************************************** + +typedef GenericCollection Views; + + + +// **************************************************************************************************** +// ViewLocator declaration +// **************************************************************************************************** + +typedef GenericLocator ViewLocator; + + + +// **************************************************************************************************** +// ViewFilter declaration +// **************************************************************************************************** + +typedef GenericFilter ViewFilter; + + + +// **************************************************************************************************** +// for_each_view declaration +// **************************************************************************************************** + +#define for_each_view(view, views)\ +/*********************************/\ +{\ + ViewLocator _locator = views.GetLocator();\ + while (_locator.IsValid()) {\ + View* view = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_VIEWS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Warning.cpp b/hurricane/src/hurricane/Warning.cpp new file mode 100644 index 00000000..2c0f2d3a --- /dev/null +++ b/hurricane/src/hurricane/Warning.cpp @@ -0,0 +1,55 @@ +// **************************************************************************************************** +// File: Warning.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Warning.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Warning implementation +// **************************************************************************************************** + +Warning::Warning(const string& reason, int code) +// ********************************************* +: Inherit(), + _reason(reason), + _code(code) +{ +} + +Warning::Warning(const Warning& warning) +// ************************************* +: Inherit(), + _reason(warning._reason), + _code(warning._code) +{ +} + +Warning& Warning::operator=(const Warning& warning) +// ************************************************ +{ + _reason = warning._reason; + _code = warning._code; + return *this; +} + +string Warning::_GetString() const +// ******************************* +{ + if (!_code) return "[WARNING] " + _reason; + + return "[WARNING:" + GetString(_code) + "] " + _reason; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/Warning.h b/hurricane/src/hurricane/Warning.h new file mode 100644 index 00000000..2294a9e0 --- /dev/null +++ b/hurricane/src/hurricane/Warning.h @@ -0,0 +1,70 @@ +// **************************************************************************************************** +// File: Warning.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_WARNING +#define HURRICANE_WARNING + +#include "Exception.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Warning declaration +// **************************************************************************************************** + +class Warning : public Exception { +// ***************************** + +// Types +// ***** + + public: typedef Exception Inherit; + +// Attributes +// ********** + + private: string _reason; + private: int _code; + +// Constructors +// ************ + + public: Warning(const string& reason, int code = 0); + + public: Warning(const Warning& warning); + +// Operators +// ********* + + public: Warning& operator=(const Warning& warning); + +// Accessors +// ********* + + public: string GetReason() const {return _reason;}; + public: int GetCode() const {return _code;}; + +// Others +// ****** + + public: virtual string _GetTypeName() const { return _TName("Warning"); }; + public: virtual string _GetString() const; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Warning) + +#endif // HURRICANE_WARNING + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/demangle.h b/hurricane/src/hurricane/demangle.h new file mode 100644 index 00000000..af294672 --- /dev/null +++ b/hurricane/src/hurricane/demangle.h @@ -0,0 +1,536 @@ +/* Defs for interface to demanglers. + Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, + 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, + Boston, MA 02110-1301, USA. */ + + +#if !defined (DEMANGLE_H) +#define DEMANGLE_H + +#include "libiberty.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Options passed to cplus_demangle (in 2nd parameter). */ + +#define DMGL_NO_OPTS 0 /* For readability... */ +#define DMGL_PARAMS (1 << 0) /* Include function args */ +#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ +#define DMGL_JAVA (1 << 2) /* Demangle as Java rather than C++. */ +#define DMGL_VERBOSE (1 << 3) /* Include implementation details. */ +#define DMGL_TYPES (1 << 4) /* Also try to demangle type encodings. */ +#define DMGL_RET_POSTFIX (1 << 5) /* Print function return types (when + present) after function signature */ + +#define DMGL_AUTO (1 << 8) +#define DMGL_GNU (1 << 9) +#define DMGL_LUCID (1 << 10) +#define DMGL_ARM (1 << 11) +#define DMGL_HP (1 << 12) /* For the HP aCC compiler; + same as ARM except for + template arguments, etc. */ +#define DMGL_EDG (1 << 13) +#define DMGL_GNU_V3 (1 << 14) +#define DMGL_GNAT (1 << 15) + +/* If none of these are set, use 'current_demangling_style' as the default. */ +#define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT) + +/* Enumeration of possible demangling styles. + + Lucid and ARM styles are still kept logically distinct, even though + they now both behave identically. The resulting style is actual the + union of both. I.E. either style recognizes both "__pt__" and "__rf__" + for operator "->", even though the first is lucid style and the second + is ARM style. (FIXME?) */ + +extern enum demangling_styles +{ + no_demangling = -1, + unknown_demangling = 0, + auto_demangling = DMGL_AUTO, + gnu_demangling = DMGL_GNU, + lucid_demangling = DMGL_LUCID, + arm_demangling = DMGL_ARM, + hp_demangling = DMGL_HP, + edg_demangling = DMGL_EDG, + gnu_v3_demangling = DMGL_GNU_V3, + java_demangling = DMGL_JAVA, + gnat_demangling = DMGL_GNAT +} current_demangling_style; + +/* Define string names for the various demangling styles. */ + +#define NO_DEMANGLING_STYLE_STRING "none" +#define AUTO_DEMANGLING_STYLE_STRING "auto" +#define GNU_DEMANGLING_STYLE_STRING "gnu" +#define LUCID_DEMANGLING_STYLE_STRING "lucid" +#define ARM_DEMANGLING_STYLE_STRING "arm" +#define HP_DEMANGLING_STYLE_STRING "hp" +#define EDG_DEMANGLING_STYLE_STRING "edg" +#define GNU_V3_DEMANGLING_STYLE_STRING "gnu-v3" +#define JAVA_DEMANGLING_STYLE_STRING "java" +#define GNAT_DEMANGLING_STYLE_STRING "gnat" + +/* Some macros to test what demangling style is active. */ + +#define CURRENT_DEMANGLING_STYLE current_demangling_style +#define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO) +#define GNU_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU) +#define LUCID_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_LUCID) +#define ARM_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_ARM) +#define HP_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_HP) +#define EDG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_EDG) +#define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3) +#define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA) +#define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT) + +/* Provide information about the available demangle styles. This code is + pulled from gdb into libiberty because it is useful to binutils also. */ + +extern const struct demangler_engine +{ + const char *const demangling_style_name; + const enum demangling_styles demangling_style; + const char *const demangling_style_doc; +} libiberty_demanglers[]; + +extern char * +cplus_demangle (const char *mangled, int options); + +extern int +cplus_demangle_opname (const char *opname, char *result, int options); + +extern const char * +cplus_mangle_opname (const char *opname, int options); + +/* Note: This sets global state. FIXME if you care about multi-threading. */ + +extern void +set_cplus_marker_for_demangling (int ch); + +extern enum demangling_styles +cplus_demangle_set_style (enum demangling_styles style); + +extern enum demangling_styles +cplus_demangle_name_to_style (const char *name); + +/* V3 ABI demangling entry points, defined in cp-demangle.c. */ +extern char* +cplus_demangle_v3 (const char* mangled, int options); + +extern char* +java_demangle_v3 (const char* mangled); + + +enum gnu_v3_ctor_kinds { + gnu_v3_complete_object_ctor = 1, + gnu_v3_base_object_ctor, + gnu_v3_complete_object_allocating_ctor +}; + +/* Return non-zero iff NAME is the mangled form of a constructor name + in the G++ V3 ABI demangling style. Specifically, return an `enum + gnu_v3_ctor_kinds' value indicating what kind of constructor + it is. */ +extern enum gnu_v3_ctor_kinds + is_gnu_v3_mangled_ctor (const char *name); + + +enum gnu_v3_dtor_kinds { + gnu_v3_deleting_dtor = 1, + gnu_v3_complete_object_dtor, + gnu_v3_base_object_dtor +}; + +/* Return non-zero iff NAME is the mangled form of a destructor name + in the G++ V3 ABI demangling style. Specifically, return an `enum + gnu_v3_dtor_kinds' value, indicating what kind of destructor + it is. */ +extern enum gnu_v3_dtor_kinds + is_gnu_v3_mangled_dtor (const char *name); + +/* The V3 demangler works in two passes. The first pass builds a tree + representation of the mangled name, and the second pass turns the + tree representation into a demangled string. Here we define an + interface to permit a caller to build their own tree + representation, which they can pass to the demangler to get a + demangled string. This can be used to canonicalize user input into + something which the demangler might output. It could also be used + by other demanglers in the future. */ + +/* These are the component types which may be found in the tree. Many + component types have one or two subtrees, referred to as left and + right (a component type with only one subtree puts it in the left + subtree). */ + +enum demangle_component_type +{ + /* A name, with a length and a pointer to a string. */ + DEMANGLE_COMPONENT_NAME, + /* A qualified name. The left subtree is a class or namespace or + some such thing, and the right subtree is a name qualified by + that class. */ + DEMANGLE_COMPONENT_QUAL_NAME, + /* A local name. The left subtree describes a function, and the + right subtree is a name which is local to that function. */ + DEMANGLE_COMPONENT_LOCAL_NAME, + /* A typed name. The left subtree is a name, and the right subtree + describes that name as a function. */ + DEMANGLE_COMPONENT_TYPED_NAME, + /* A template. The left subtree is a template name, and the right + subtree is a template argument list. */ + DEMANGLE_COMPONENT_TEMPLATE, + /* A template parameter. This holds a number, which is the template + parameter index. */ + DEMANGLE_COMPONENT_TEMPLATE_PARAM, + /* A constructor. This holds a name and the kind of + constructor. */ + DEMANGLE_COMPONENT_CTOR, + /* A destructor. This holds a name and the kind of destructor. */ + DEMANGLE_COMPONENT_DTOR, + /* A vtable. This has one subtree, the type for which this is a + vtable. */ + DEMANGLE_COMPONENT_VTABLE, + /* A VTT structure. This has one subtree, the type for which this + is a VTT. */ + DEMANGLE_COMPONENT_VTT, + /* A construction vtable. The left subtree is the type for which + this is a vtable, and the right subtree is the derived type for + which this vtable is built. */ + DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, + /* A typeinfo structure. This has one subtree, the type for which + this is the tpeinfo structure. */ + DEMANGLE_COMPONENT_TYPEINFO, + /* A typeinfo name. This has one subtree, the type for which this + is the typeinfo name. */ + DEMANGLE_COMPONENT_TYPEINFO_NAME, + /* A typeinfo function. This has one subtree, the type for which + this is the tpyeinfo function. */ + DEMANGLE_COMPONENT_TYPEINFO_FN, + /* A thunk. This has one subtree, the name for which this is a + thunk. */ + DEMANGLE_COMPONENT_THUNK, + /* A virtual thunk. This has one subtree, the name for which this + is a virtual thunk. */ + DEMANGLE_COMPONENT_VIRTUAL_THUNK, + /* A covariant thunk. This has one subtree, the name for which this + is a covariant thunk. */ + DEMANGLE_COMPONENT_COVARIANT_THUNK, + /* A Java class. This has one subtree, the type. */ + DEMANGLE_COMPONENT_JAVA_CLASS, + /* A guard variable. This has one subtree, the name for which this + is a guard variable. */ + DEMANGLE_COMPONENT_GUARD, + /* A reference temporary. This has one subtree, the name for which + this is a temporary. */ + DEMANGLE_COMPONENT_REFTEMP, + /* A hidden alias. This has one subtree, the encoding for which it + is providing alternative linkage. */ + DEMANGLE_COMPONENT_HIDDEN_ALIAS, + /* A standard substitution. This holds the name of the + substitution. */ + DEMANGLE_COMPONENT_SUB_STD, + /* The restrict qualifier. The one subtree is the type which is + being qualified. */ + DEMANGLE_COMPONENT_RESTRICT, + /* The volatile qualifier. The one subtree is the type which is + being qualified. */ + DEMANGLE_COMPONENT_VOLATILE, + /* The const qualifier. The one subtree is the type which is being + qualified. */ + DEMANGLE_COMPONENT_CONST, + /* The restrict qualifier modifying a member function. The one + subtree is the type which is being qualified. */ + DEMANGLE_COMPONENT_RESTRICT_THIS, + /* The volatile qualifier modifying a member function. The one + subtree is the type which is being qualified. */ + DEMANGLE_COMPONENT_VOLATILE_THIS, + /* The const qualifier modifying a member function. The one subtree + is the type which is being qualified. */ + DEMANGLE_COMPONENT_CONST_THIS, + /* A vendor qualifier. The left subtree is the type which is being + qualified, and the right subtree is the name of the + qualifier. */ + DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, + /* A pointer. The one subtree is the type which is being pointed + to. */ + DEMANGLE_COMPONENT_POINTER, + /* A reference. The one subtree is the type which is being + referenced. */ + DEMANGLE_COMPONENT_REFERENCE, + /* A complex type. The one subtree is the base type. */ + DEMANGLE_COMPONENT_COMPLEX, + /* An imaginary type. The one subtree is the base type. */ + DEMANGLE_COMPONENT_IMAGINARY, + /* A builtin type. This holds the builtin type information. */ + DEMANGLE_COMPONENT_BUILTIN_TYPE, + /* A vendor's builtin type. This holds the name of the type. */ + DEMANGLE_COMPONENT_VENDOR_TYPE, + /* A function type. The left subtree is the return type. The right + subtree is a list of ARGLIST nodes. Either or both may be + NULL. */ + DEMANGLE_COMPONENT_FUNCTION_TYPE, + /* An array type. The left subtree is the dimension, which may be + NULL, or a string (represented as DEMANGLE_COMPONENT_NAME), or an + expression. The right subtree is the element type. */ + DEMANGLE_COMPONENT_ARRAY_TYPE, + /* A pointer to member type. The left subtree is the class type, + and the right subtree is the member type. CV-qualifiers appear + on the latter. */ + DEMANGLE_COMPONENT_PTRMEM_TYPE, + /* An argument list. The left subtree is the current argument, and + the right subtree is either NULL or another ARGLIST node. */ + DEMANGLE_COMPONENT_ARGLIST, + /* A template argument list. The left subtree is the current + template argument, and the right subtree is either NULL or + another TEMPLATE_ARGLIST node. */ + DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, + /* An operator. This holds information about a standard + operator. */ + DEMANGLE_COMPONENT_OPERATOR, + /* An extended operator. This holds the number of arguments, and + the name of the extended operator. */ + DEMANGLE_COMPONENT_EXTENDED_OPERATOR, + /* A typecast, represented as a unary operator. The one subtree is + the type to which the argument should be cast. */ + DEMANGLE_COMPONENT_CAST, + /* A unary expression. The left subtree is the operator, and the + right subtree is the single argument. */ + DEMANGLE_COMPONENT_UNARY, + /* A binary expression. The left subtree is the operator, and the + right subtree is a BINARY_ARGS. */ + DEMANGLE_COMPONENT_BINARY, + /* Arguments to a binary expression. The left subtree is the first + argument, and the right subtree is the second argument. */ + DEMANGLE_COMPONENT_BINARY_ARGS, + /* A trinary expression. The left subtree is the operator, and the + right subtree is a TRINARY_ARG1. */ + DEMANGLE_COMPONENT_TRINARY, + /* Arguments to a trinary expression. The left subtree is the first + argument, and the right subtree is a TRINARY_ARG2. */ + DEMANGLE_COMPONENT_TRINARY_ARG1, + /* More arguments to a trinary expression. The left subtree is the + second argument, and the right subtree is the third argument. */ + DEMANGLE_COMPONENT_TRINARY_ARG2, + /* A literal. The left subtree is the type, and the right subtree + is the value, represented as a DEMANGLE_COMPONENT_NAME. */ + DEMANGLE_COMPONENT_LITERAL, + /* A negative literal. Like LITERAL, but the value is negated. + This is a minor hack: the NAME used for LITERAL points directly + to the mangled string, but since negative numbers are mangled + using 'n' instead of '-', we want a way to indicate a negative + number which involves neither modifying the mangled string nor + allocating a new copy of the literal in memory. */ + DEMANGLE_COMPONENT_LITERAL_NEG +}; + +/* Types which are only used internally. */ + +struct demangle_operator_info; +struct demangle_builtin_type_info; + +/* A node in the tree representation is an instance of a struct + demangle_component. Note that the field names of the struct are + not well protected against macros defined by the file including + this one. We can fix this if it ever becomes a problem. */ + +struct demangle_component +{ + /* The type of this component. */ + enum demangle_component_type type; + + union + { + /* For DEMANGLE_COMPONENT_NAME. */ + struct + { + /* A pointer to the name (which need not NULL terminated) and + its length. */ + const char *s; + int len; + } s_name; + + /* For DEMANGLE_COMPONENT_OPERATOR. */ + struct + { + /* Operator. */ + const struct demangle_operator_info *op; + } s_operator; + + /* For DEMANGLE_COMPONENT_EXTENDED_OPERATOR. */ + struct + { + /* Number of arguments. */ + int args; + /* Name. */ + struct demangle_component *name; + } s_extended_operator; + + /* For DEMANGLE_COMPONENT_CTOR. */ + struct + { + /* Kind of constructor. */ + enum gnu_v3_ctor_kinds kind; + /* Name. */ + struct demangle_component *name; + } s_ctor; + + /* For DEMANGLE_COMPONENT_DTOR. */ + struct + { + /* Kind of destructor. */ + enum gnu_v3_dtor_kinds kind; + /* Name. */ + struct demangle_component *name; + } s_dtor; + + /* For DEMANGLE_COMPONENT_BUILTIN_TYPE. */ + struct + { + /* Builtin type. */ + const struct demangle_builtin_type_info *type; + } s_builtin; + + /* For DEMANGLE_COMPONENT_SUB_STD. */ + struct + { + /* Standard substitution string. */ + const char* string; + /* Length of string. */ + int len; + } s_string; + + /* For DEMANGLE_COMPONENT_TEMPLATE_PARAM. */ + struct + { + /* Template parameter index. */ + long number; + } s_number; + + /* For other types. */ + struct + { + /* Left (or only) subtree. */ + struct demangle_component *left; + /* Right subtree. */ + struct demangle_component *right; + } s_binary; + + } u; +}; + +/* People building mangled trees are expected to allocate instances of + struct demangle_component themselves. They can then call one of + the following functions to fill them in. */ + +/* Fill in most component types with a left subtree and a right + subtree. Returns non-zero on success, zero on failure, such as an + unrecognized or inappropriate component type. */ + +extern int +cplus_demangle_fill_component (struct demangle_component *fill, + enum demangle_component_type, + struct demangle_component *left, + struct demangle_component *right); + +/* Fill in a DEMANGLE_COMPONENT_NAME. Returns non-zero on success, + zero for bad arguments. */ + +extern int +cplus_demangle_fill_name (struct demangle_component *fill, + const char *, int); + +/* Fill in a DEMANGLE_COMPONENT_BUILTIN_TYPE, using the name of the + builtin type (e.g., "int", etc.). Returns non-zero on success, + zero if the type is not recognized. */ + +extern int +cplus_demangle_fill_builtin_type (struct demangle_component *fill, + const char *type_name); + +/* Fill in a DEMANGLE_COMPONENT_OPERATOR, using the name of the + operator and the number of arguments which it takes (the latter is + used to disambiguate operators which can be both binary and unary, + such as '-'). Returns non-zero on success, zero if the operator is + not recognized. */ + +extern int +cplus_demangle_fill_operator (struct demangle_component *fill, + const char *opname, int args); + +/* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR, providing the + number of arguments and the name. Returns non-zero on success, + zero for bad arguments. */ + +extern int +cplus_demangle_fill_extended_operator (struct demangle_component *fill, + int numargs, + struct demangle_component *nm); + +/* Fill in a DEMANGLE_COMPONENT_CTOR. Returns non-zero on success, + zero for bad arguments. */ + +extern int +cplus_demangle_fill_ctor (struct demangle_component *fill, + enum gnu_v3_ctor_kinds kind, + struct demangle_component *name); + +/* Fill in a DEMANGLE_COMPONENT_DTOR. Returns non-zero on success, + zero for bad arguments. */ + +extern int +cplus_demangle_fill_dtor (struct demangle_component *fill, + enum gnu_v3_dtor_kinds kind, + struct demangle_component *name); + +/* This function translates a mangled name into a struct + demangle_component tree. The first argument is the mangled name. + The second argument is DMGL_* options. This returns a pointer to a + tree on success, or NULL on failure. On success, the third + argument is set to a block of memory allocated by malloc. This + block should be passed to free when the tree is no longer + needed. */ + +extern struct demangle_component * +cplus_demangle_v3_components (const char *mangled, int options, void **mem); + +/* This function takes a struct demangle_component tree and returns + the corresponding demangled string. The first argument is DMGL_* + options. The second is the tree to demangle. The third is a guess + at the length of the demangled string, used to initially allocate + the return buffer. The fourth is a pointer to a size_t. On + success, this function returns a buffer allocated by malloc(), and + sets the size_t pointed to by the fourth argument to the size of + the allocated buffer (not the length of the returned string). On + failure, this function returns NULL, and sets the size_t pointed to + by the fourth argument to 0 for an invalid tree, or to 1 for a + memory allocation error. */ + +extern char * +cplus_demangle_print (int options, + const struct demangle_component *tree, + int estimated_length, + size_t *p_allocated_size); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* DEMANGLE_H */ diff --git a/hurricane/src/hurricane/grenier/Builder.cpp b/hurricane/src/hurricane/grenier/Builder.cpp new file mode 100644 index 00000000..6cb98896 --- /dev/null +++ b/hurricane/src/hurricane/grenier/Builder.cpp @@ -0,0 +1,102 @@ +// **************************************************************************************************** +// File: Builder.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Builder.h" + +#include "Hurricane.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Variables +// **************************************************************************************************** + +typedef map Builder_BuilderMap; + +static Builder_BuilderMap* BUILDER_MAP = NULL; + + + +// **************************************************************************************************** +// Builder implementation +// **************************************************************************************************** + +Builder::Builder(const string& token) +// ********************************** +: _token(token) +{ + if (_token.empty()) + throw Error("Can't create Builder : empty token"); + + if (!BUILDER_MAP) + BUILDER_MAP = new Builder_BuilderMap(); + else { + if (GetBuilder(_token)) + throw Error("Can't create Builder : already exists"); + } + + (*BUILDER_MAP)[_token] = this; +} + +Builder::~Builder() +// **************** +{ + BUILDER_MAP->erase(_token); + + if (BUILDER_MAP->empty()) { + delete BUILDER_MAP; + BUILDER_MAP = NULL; + } +} + +void Builder::Scan(InputFile& inputFile, char*& arguments) +// ******************************************************* +{ +} + +string Builder::_GetString() const +// ******************************* +{ + string s = "<" + _GetTypeName() + ">"; + return s; +} + +Record* Builder::_GetRecord() const +// ************************** +{ + Record* record = new Record(GetString(this)); + if (record) { + record->Add(GetSlot("Token", GetToken())); + } + return record; +} + + + +} // End of Hurricane namespace. + + + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + +H::Builder* GetBuilder(const string& token) +// ************************************* +{ + if (H::BUILDER_MAP) { + H::Builder_BuilderMap::iterator it = H::BUILDER_MAP->find(token); + if (it != H::BUILDER_MAP->end()) return (*it).second; + } + + return NULL; +} + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/Builder.h b/hurricane/src/hurricane/grenier/Builder.h new file mode 100644 index 00000000..91d5c15a --- /dev/null +++ b/hurricane/src/hurricane/grenier/Builder.h @@ -0,0 +1,79 @@ +// **************************************************************************************************** +// File: Builder.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_BUILDER +#define HURRICANE_BUILDER + +#include "InputFile.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Builder declaration +// **************************************************************************************************** + +class Builder : public NestedSlotAdapter { +// ************************************* + +// Attributes +// ********** + + private: string _token; + +// Constructors +// ************ + + public: Builder(const string& token); + + private: Builder(const Builder& builder); // not implemented to forbid copy + +// Destructor +// ********** + + public: virtual ~Builder(); + +// Operators +// ********* + + private: Builder& operator=(const Builder& builder); // not implemented to forbid assinment + +// Accessors +// ********* + + public: string GetToken() const {return _token;}; + +// Managers +// ******** + + public: virtual void Scan(InputFile& inputFile, char*& arguments); + public: virtual DBo* CreateDBo() = 0; + +// Others +// ****** + + public: virtual string _GetTypeName() const = 0; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Builder) + + +H::Builder* GetBuilder(const string& token); + + +#endif // HURRICANE_BUILDER + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/Command.cpp b/hurricane/src/hurricane/grenier/Command.cpp new file mode 100644 index 00000000..501e6e96 --- /dev/null +++ b/hurricane/src/hurricane/grenier/Command.cpp @@ -0,0 +1,141 @@ +// **************************************************************************************************** +// File: Command.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Command.h" +#include "View.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Command implementation +// **************************************************************************************************** + +Command::Command(const Name& name, unsigned button) +// ************************************************ +: _name(name), + _button(button), + _viewSet() +{ + if (_name.IsEmpty()) + throw Error("Can't create " + _TName("Command") + " : empty name"); +} + +bool Command::IsInstalledOn(View* view) const +// ****************************************** +{ + return (_viewSet.find(view) != _viewSet.end()); +} + +void Command::InstallOn(View* view) +// ******************************** +{ + if (!view) + throw Error("Can't install command : null view"); + + Command* command = view->GetCommand(_button); + if (command != this) { + if (command) command->UninstallFrom(view); + view->_GetCommandMap()[_button] = this; + _OnInstalledOn(view); + } + + _viewSet.insert(view); +} + +void Command::UninstallFrom(View* view) +// ************************************ +{ + if (!view) + throw Error("Can't uninstall command : null view"); + + if (view->GetCommand(_button) != this) + throw Error("Can't uninstall command : not installed"); + + _OnUninstalledFrom(view); + view->_GetCommandMap().erase(_button); + + _viewSet.erase(view); +} + +void Command::_PreDelete() +// *********************** +{ + Inherit::_PreDelete(); + + for_each_view(view, GetViews()) UninstallFrom(view); end_for; +} + +string Command::_GetString() const +// ******************************* +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_name)); + s.insert(s.length() - 1, " " + GetString(_button)); + return s; +} + +Record* Command::_GetRecord() const +// ************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("Button", &_button)); + record->Add(GetSlot("Views", &_viewSet)); + } + return record; +} + +void Command::_OnInstalledOn(View* view) +// ************************************* +{ +} + +void Command::_OnUninstalledFrom(View* view) +// ***************************************** +{ +} + +void Command::_OnDrawGhost(View* view) +// *********************************** +{ +} + +void Command::_OnMouseEnter(View* view, const Point& position) +// *********************************************************** +{ +} + +void Command::_OnMouseMove(View* view, const Point& position, unsigned state) +// ************************************************************************** +{ +} + +void Command::_OnMouseLeave(View* view, const Point& position) +// *********************************************************** +{ +} + +void Command::_OnButtonPress(View* view, const Point& position, unsigned state) +// **************************************************************************** +{ +} + +void Command::_OnButtonRelease(View* view, const Point& position, unsigned state) +// ****************************************************************************** +{ +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/Command.h b/hurricane/src/hurricane/grenier/Command.h new file mode 100644 index 00000000..296bc2d5 --- /dev/null +++ b/hurricane/src/hurricane/grenier/Command.h @@ -0,0 +1,93 @@ +// **************************************************************************************************** +// File: Command.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_COMMAND +#define HURRICANE_COMMAND + +#include "DBo.h" +#include "Commands.h" +#include "Views.h" +#include "Point.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Command declaration +// **************************************************************************************************** + +class Command : public DBo { +// *********************** + +// Types +// ***** + + public: typedef DBo Inherit; + + public: typedef set ViewSet; + +// Attributes +// ********** + + private: Name _name; + private: unsigned _button; + private: ViewSet _viewSet; + +// Constructors +// ************ + + protected: Command(const Name& name, unsigned button); + +// Accessors +// ********* + + public: const Name& GetName() const {return _name;}; + public: unsigned GetButton() const {return _button;}; + public: Views GetViews() const {return GetCollection(_viewSet);}; + +// Predicates +// ********** + + public: bool IsInstalledOn(View* view) const; + +// Managers +// ******** + + public: void InstallOn(View* view); + public: void UninstallFrom(View* view); + +// Others +// ****** + + protected: virtual void _PreDelete(); + + public: string _GetString() const; + public: Record* _GetRecord() const; + public: ViewSet& _GetViewSet() {return _viewSet;}; + + public: virtual void _OnInstalledOn(View* view); + public: virtual void _OnUninstalledFrom(View* view); + public: virtual void _OnDrawGhost(View* view); + public: virtual void _OnMouseEnter(View* view, const Point& position); + public: virtual void _OnMouseMove(View* view, const Point& position, unsigned state); + public: virtual void _OnMouseLeave(View* view, const Point& position); + public: virtual void _OnButtonPress(View* view, const Point& position, unsigned state); + public: virtual void _OnButtonRelease(View* view, const Point& position, unsigned state); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Command) + +#endif // HURRICANE_COMMAND + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/Commands.h b/hurricane/src/hurricane/grenier/Commands.h new file mode 100644 index 00000000..84ad97c3 --- /dev/null +++ b/hurricane/src/hurricane/grenier/Commands.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: Commands.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_COMMANDS +#define HURRICANE_COMMANDS + +#include "Collection.h" + +namespace Hurricane { + +class Command; + + + +// **************************************************************************************************** +// Commands declaration +// **************************************************************************************************** + +typedef GenericCollection Commands; + + + +// **************************************************************************************************** +// CommandLocator declaration +// **************************************************************************************************** + +typedef GenericLocator CommandLocator; + + + +// **************************************************************************************************** +// CommandFilter declaration +// **************************************************************************************************** + +typedef GenericFilter CommandFilter; + + + +// **************************************************************************************************** +// for_each_command declaration +// **************************************************************************************************** + +#define for_each_command(command, commands)\ +/******************************************/\ +{\ + CommandLocator _locator = commands.GetLocator();\ + while (_locator.IsValid()) {\ + Command* command = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_COMMANDS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/GtkUtils.cpp b/hurricane/src/hurricane/grenier/GtkUtils.cpp new file mode 100644 index 00000000..af3d6be5 --- /dev/null +++ b/hurricane/src/hurricane/grenier/GtkUtils.cpp @@ -0,0 +1,254 @@ +// **************************************************************************************************** +// File: GtkUtils.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "GtkUtils.h" +#include "Interruption.h" + +namespace Hurricane { + + + + +// **************************************************************************************************** +// Globals +// **************************************************************************************************** + +static bool gtk_has_been_aborted() +// ******************************* +{ + bool aborted = false; + if (gdk_events_pending()) { + GdkEvent* event = gdk_event_get(); + if (event) { + if ((event->type == GDK_KEY_PRESS) && + (string(gdk_keyval_name(((GdkEventKey*)event)->keyval)) == "Escape")) + aborted = true; + else + aborted = gtk_has_been_aborted(); + gdk_event_put(event); + gdk_event_free(event); + } + } + return aborted; +} + +void gtk_check_for_interruption() +// ****************************** +{ + if (gtk_has_been_aborted()) throw Interruption("Escape"); +} + +GdkWindow* gtk_get_window() +// ************************ +{ + static GdkWindow* WINDOW = (GdkWindow*)NULL; + if (!WINDOW) { + GtkWidget* widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_widget_realize(widget); + WINDOW = widget->window; + } + return WINDOW; +} + +GdkColor* gdk_color_new(unsigned short red, unsigned short green, unsigned short blue) +// *********************************************************************************** +{ + GdkWindow* window = gtk_get_window(); + GdkColor* color = new GdkColor; + color->red = red * 255; + color->green = green * 255; + color->blue = blue * 255; + + gdk_color_alloc(gdk_window_get_colormap(window), color); + + return color; +} + +GdkGC* gtk_gc_new(GdkColor* color, const string& pattern, unsigned linewidth) +// ************************************************************************** +{ + GdkWindow* window = gtk_get_window(); + gdk_color_alloc(gdk_window_get_colormap(window), color); + GdkGC* gc = gdk_gc_new(window); + gdk_gc_set_foreground(gc, color); + + if (linewidth != 0) + { + gdk_gc_set_line_attributes(gc + , linewidth + , GDK_LINE_SOLID + , GDK_CAP_NOT_LAST + , GDK_JOIN_MITER ); + } + + if (pattern == "FFFFFFFFFFFFFFFF") { + gdk_gc_set_fill(gc, GDK_SOLID); + } + else { + gdk_gc_set_fill(gc, GDK_STIPPLED); + char bits[8]; + for (int i = 0; i < 8; i++) { + int high = pattern[i * 2]; + if (('0' <= high) && (high <= '9')) + high = high - '0'; + else { + if (('a' <= high) && (high <= 'f')) + high = 10 + high - 'a'; + else { + if (('A' <= high) && (high <= 'F')) + high = 10 + high - 'A'; + else + high = '0'; + } + } + int low = pattern[(i * 2) + 1]; + if (('0' <= low) && (low <= '9')) + low = low - '0'; + else { + if (('a' <= low) && (low <= 'f')) + low = 10 + low - 'a'; + else { + if (('A' <= low) && (low <= 'F')) + low = 10 + low - 'A'; + else + low = '0'; + } + } + bits[i] = (char)((high * 16) + low); + } + GdkPixmap* stipple = gdk_bitmap_create_from_data(window, bits, 8, 8); + gdk_gc_set_stipple(gc, stipple); + } + return gc; +} + +GdkGC* gtk_gc_new(unsigned short red, unsigned short green, unsigned short blue, const string& pattern, unsigned linewidth) +// **************************************************************************************************** +{ + GdkColor color; + color.red = red * 255; + color.green = green * 255; + color.blue = blue * 255; + + return gtk_gc_new(&color, pattern, linewidth); +} + +GtkWidget* gtk_pixmap_new_from_name(gchar* pixmapName[]) +// ***************************************************** +{ + GdkBitmap* mask; + GdkPixmap* pixmap = + gdk_pixmap_create_from_xpm_d(gtk_get_window(), + &mask, + (GdkColor*)NULL, + pixmapName); + GtkWidget* widget = gtk_pixmap_new(pixmap, mask); + gdk_pixmap_unref(pixmap); + gdk_pixmap_unref(mask); + + return widget; +} + +GtkWidget* gtk_button_new_with_pixmap(gchar* pixmapName[]) +// ******************************************************* +{ + GtkWidget* button = gtk_button_new(); + + GtkWidget* pixmap = gtk_pixmap_new_from_name(pixmapName); + + gtk_container_add(GTK_CONTAINER(button), pixmap); + + return button; +} + +GtkWidget* gtk_hbutton_new_with_pixmap_and_label(gchar* pixmapName[], gchar* labelString) +// ************************************************************************************** +{ + GtkWidget* button = gtk_button_new(); + + GtkWidget* table = gtk_table_new(4, 1, false); + gtk_container_add(GTK_CONTAINER(button), table); + gtk_table_set_col_spacings(GTK_TABLE(table), 5); + + gtk_table_attach + (GTK_TABLE(table), gtk_label_new(""), 0, 1, 0, 1, GTK_FILL_EXPAND, GTK_FILL, 0, 0); + + GtkWidget* pixmap = gtk_pixmap_new_from_name(pixmapName); + gtk_table_attach + (GTK_TABLE(table), pixmap, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0); + + GtkWidget* label = gtk_label_new(labelString); + gtk_table_attach + (GTK_TABLE(table), label, 2, 3, 0, 1, GTK_FILL, GTK_FILL, 0, 0); + + gtk_table_attach + (GTK_TABLE(table), gtk_label_new(""), 3, 4, 0, 1, GTK_FILL_EXPAND, GTK_FILL, 0, 0); + + gtk_table_set_col_spacing(GTK_TABLE(table), 2, 11); + + return button; +} + +GtkWidget* gtk_vbutton_new_with_pixmap_and_label(gchar* pixmapName[], gchar* labelString) +// ************************************************************************************** +{ + GtkWidget* button = gtk_button_new(); + + GtkWidget* table = gtk_table_new(1, 4, false); + gtk_container_add(GTK_CONTAINER(button), table); + gtk_table_set_row_spacings(GTK_TABLE(table), 2); + + GtkWidget* pixmap = gtk_pixmap_new_from_name(pixmapName); + gtk_table_attach + (GTK_TABLE(table), pixmap, 0, 1, 1, 2, GTK_FILL_EXPAND, GTK_FILL_EXPAND, 0, 0); + + GtkWidget* label = gtk_label_new(labelString); + gtk_table_attach + (GTK_TABLE(table), label, 0, 1, 2, 3, GTK_FILL_EXPAND, GTK_FILL_EXPAND, 0, 0); + + return button; +} + +GtkWidget* gtk_menu_item_new_with_pixmap_and_label(gchar* pixmapName[], gchar* labelString) +// **************************************************************************************** +{ + GtkWidget* menuItem = gtk_menu_item_new(); + + GtkWidget* hBox = gtk_hbox_new(FALSE, 0); + + GtkWidget* pixmap = gtk_pixmap_new_from_name(pixmapName); + gtk_box_pack_start(GTK_BOX(hBox), pixmap, FALSE, FALSE, 5); + + GtkWidget* label = gtk_label_new(labelString); + gtk_box_pack_start(GTK_BOX(hBox), label, FALSE, FALSE, 5); + + gtk_container_add(GTK_CONTAINER(menuItem), hBox); + + return menuItem; +} + + + + +// --------------------------------------------------------------- +// Function : "GdkKeyvalName()". + +string GdkKeyvalName ( int keyval ) +{ + string skeyval = "None"; + if ( keyval != 0 ) skeyval = gdk_keyval_name(keyval); + + return ( skeyval ); +} + + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/GtkUtils.h b/hurricane/src/hurricane/grenier/GtkUtils.h new file mode 100644 index 00000000..957894fb --- /dev/null +++ b/hurricane/src/hurricane/grenier/GtkUtils.h @@ -0,0 +1,50 @@ +// **************************************************************************************************** +// File: GtkUtils.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_GTK_UTILS +#define HURRICANE_GTK_UTILS + +#include "Commons.h" + +#include + +#define GTK_FILL_EXPAND ((GtkAttachOptions)(GTK_FILL | GTK_EXPAND)) + +namespace Hurricane { + + + +// **************************************************************************************************** +// Globals +// **************************************************************************************************** + +void gtk_check_for_interruption(); + +GdkWindow* gtk_get_window(); + +GdkColor* gdk_color_new(unsigned short red, unsigned short green, unsigned short blue); +GdkGC* gtk_gc_new(GdkColor* color, const string& pattern = "FFFFFFFFFFFFFFFF", unsigned linewidth=0); +GdkGC* gtk_gc_new(unsigned short red, unsigned short green, unsigned short blue, const string& pattern = "FFFFFFFFFFFFFFFF", unsigned linewidth=0); + +GtkWidget* gtk_pixmap_new_from_name(gchar* pixmapName[]); + +GtkWidget* gtk_button_new_with_pixmap(gchar* pixmapName[]); + +GtkWidget* gtk_hbutton_new_with_pixmap_and_label(gchar* pixmapName[], gchar* labelString); +GtkWidget* gtk_vbutton_new_with_pixmap_and_label(gchar* pixmapName[], gchar* labelString); + +GtkWidget* gtk_menu_item_new_with_pixmap_and_label(gchar* pixmapName[], gchar* labelString); + +string GdkKeyvalName ( int keyval ); + + +} // End of Hurricane namespace. + +#endif // HURRICANE_GTK_UTILS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/InputFile.cpp b/hurricane/src/hurricane/grenier/InputFile.cpp new file mode 100644 index 00000000..c6effa47 --- /dev/null +++ b/hurricane/src/hurricane/grenier/InputFile.cpp @@ -0,0 +1,211 @@ +// **************************************************************************************************** +// File: InputFile.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "InputFile.h" +#include "Builder.h" +#include "Hurricane.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// InputFile implementation +// **************************************************************************************************** + +InputFile::InputFile(const string& filePathName) +// ********************************************* +: _filePathName(filePathName), + _file(NULL), + _lineNumber(0), + _ownerStack(), + _dboVector(), + _componentVector(), + _componentIdMap() +{ + if (_filePathName.empty()) + throw Error("Can't create InputFile : empty file pathname"); + + _file = fopen(_filePathName.c_str(), "r"); + + if (!_file) + throw Error("Can't create InputFile : bad file"); + + _dboVector.push_back(NULL); // to start indexation at 1 +} + +InputFile::~InputFile() +// ******************** +{ + fclose(_file); +} + +DBo* InputFile::GetOwner() const +// ***************************** +{ + return (!_ownerStack.empty()) ? _ownerStack.top() : NULL; +} + +DBo* InputFile::GetDBo(unsigned id) const +// ************************************** +{ + return (id < _dboVector.size()) ? _dboVector[id] : NULL; +} + +Component* InputFile::GetComponent(unsigned id) const +// ************************************************** +{ + return (id < _componentVector.size()) ? _componentVector[id] : NULL; +} + +void InputFile::Register(DBo* dbo) +// ******************************* +{ + _dboVector.push_back(dbo); +} + +void InputFile::Register(Component* component) +// ******************************************* +{ + _componentVector.push_back(component); +} + +void InputFile::ClearComponentVector() +// *********************************** +{ + _componentVector.clear(); + _componentVector.push_back(NULL); // to start indexation at 1 +} + +void InputFile::Attach(Hook* hook, unsigned componentId) +// ***************************************************** +{ + Component* component = GetComponent(componentId); + if (!component) + _componentIdMap[hook] = componentId; + else { + if (hook->IsMaster() && hook->IsAttached()) + hook->Merge(component->GetBodyHook()); + else + hook->Attach(component->GetBodyHook()); + } +} + +void InputFile::AttachRemainingHooks() +// *********************************** +{ + for (ComponentIdMap::iterator it = _componentIdMap.begin(); it != _componentIdMap.end(); ++it) { + Hook* hook = (*it).first; + Component* component = GetComponent((*it).second); + if (!component) throw Error("Can't attach hook : no target component"); + if (hook->IsMaster() && hook->IsAttached()) + hook->Merge(component->GetBodyHook()); + else + hook->Attach(component->GetBodyHook()); + } + _componentIdMap.clear(); +} + +void InputFile::Load() +// ******************* +{ + unsigned rank; + char* token; + char* arguments; + while (Read(rank, token, arguments)) { + + while (rank < _ownerStack.size()) { + DBo* dbo = _ownerStack.top(); + if (dbo) dbo->_Finalize(*this); + _ownerStack.pop(); + } + + Builder* builder = GetBuilder(token); + + if (!builder) + throw Error("Can't load input file : unknown directive " + string(token) + + " (line " + GetString(_lineNumber) + ")"); + + builder->Scan(*this, arguments); + + DBo* dbo = builder->CreateDBo(); + + if (dbo) dbo->_Realize(builder, *this); + + _ownerStack.push(dbo); + } + + while (!_ownerStack.empty()) { + DBo* dbo = _ownerStack.top(); + if (dbo) dbo->_Finalize(*this); + _ownerStack.pop(); + } +} + +bool InputFile::Read(unsigned& rank, char*& token, char*& arguments) +// ***************************************************************** +{ + static char LINE[1024]; + static char TOKEN[128]; + + _lineNumber++; + + LINE[0] = fgetc(_file); + + if (LINE[0] == EOF) return false; + + if (LINE[0] == '\n') return Read(rank, token, arguments); + + fgets(&LINE[1], sizeof(LINE) - 1, _file); + + char* line = &LINE[0]; + while ((line[0] == ' ') || (line[0] == '\t')) line = &line[1]; + + if (line[0] == '\n') return Read(rank, token, arguments); + + line = &LINE[0]; + + rank = 0; + + while ((line[0] == '\t') && (LINE[0] != '\n')) { + rank++; + line = &line[1]; + } + + unsigned n; + sscanf(line, "%s%n", TOKEN, &n); + token = &TOKEN[0]; + arguments = &line[n]; + while ((arguments[0] == ' ') || (arguments[0] == '\t')) arguments = &arguments[1]; + arguments[strlen(arguments) - 1] = '\0'; + + return true; +} + +string InputFile::_GetString() const +// ********************************* +{ + return "<" + _TName("InputFile") + " " + _filePathName + ">"; +} + +Record* InputFile::_GetRecord() const +// **************************** +{ + Record* record = new Record(GetString(this)); + if (record) { + record->Add(GetSlot("FilePathName", &_filePathName)); + record->Add(GetSlot("DBos", &_dboVector)); + } + return record; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/InputFile.h b/hurricane/src/hurricane/grenier/InputFile.h new file mode 100644 index 00000000..a4247458 --- /dev/null +++ b/hurricane/src/hurricane/grenier/InputFile.h @@ -0,0 +1,103 @@ +// **************************************************************************************************** +// File: InputFile.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_INPUT_FILE +#define HURRICANE_INPUT_FILE + +#include "Commons.h" + +namespace Hurricane { + +class DBo; +class Component; +class Hook; + + + +// **************************************************************************************************** +// InputFile declaration +// **************************************************************************************************** + +class InputFile { +// ************ + +// Types +// ***** + + public: typedef stack OwnerStack; + public: typedef vector DBoVector; + public: typedef vector ComponentVector; + public: typedef map ComponentIdMap; + +// Attributes +// ********** + + private: string _filePathName; + private: FILE* _file; + private: unsigned _lineNumber; + private: OwnerStack _ownerStack; + private: DBoVector _dboVector; + private: ComponentVector _componentVector; + private: ComponentIdMap _componentIdMap; + +// Constructors +// ************ + + public: InputFile(const string& filePathName); + + private: InputFile(const InputFile& inputFile); // not implemented to forbid copy + +// Destructor +// ********** + + public: ~InputFile(); + +// Operators +// ********* + + private: InputFile& operator=(const InputFile& inputFile); // not implemented to forbid assinment + +// Accessors +// ********* + + public: DBo* GetOwner() const; + public: DBo* GetDBo(unsigned id) const; + public: Component* GetComponent(unsigned id) const; + +// Updators +// ******** + + public: void Register(DBo* dbo); + public: void Register(Component* component); + public: void ClearComponentVector(); + public: void Attach(Hook* hook, unsigned componentId); + public: void AttachRemainingHooks(); + +// Loader +// ****** + + public: void Load(); + + public: bool Read(unsigned& rank, char*& token, char*& arguments); + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("InputFile"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + +}; + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_INPUT_FILE + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/MainView.cpp b/hurricane/src/hurricane/grenier/MainView.cpp new file mode 100644 index 00000000..80e2b24d --- /dev/null +++ b/hurricane/src/hurricane/grenier/MainView.cpp @@ -0,0 +1,112 @@ +// **************************************************************************************************** +// File: MainView.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "MainView.h" +#include "MapView.h" +#include "Cell.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// MainView implementation +// **************************************************************************************************** + +MainView::MainView() +// ***************** +: Inherit(), + _cell(NULL), + _mapView(NULL) +{ +} + +MainView* MainView::Create() +// ************************* +{ + MainView* mainView = new MainView(); + + mainView->_PostCreate(); + + return mainView; +} + +bool MainView::Update(bool useDoubleBuffering) +// ******************************************* +{ + if (Inherit::Update(useDoubleBuffering)) { + if (_mapView) { + _mapView->FitToContent(); + _mapView->Update(useDoubleBuffering); + } + return true; + } + return false; +} + +void MainView::_PostCreate() +// ************************* +{ + Inherit::_PostCreate(); + + _mapView = MapView::_Create(this); +} + +void MainView::_PreDelete() +// ************************ +{ + Inherit::_PreDelete(); + + if (_mapView) _mapView->_Delete(); +} + +string MainView::_GetString() const +// ******************************** +{ + return Inherit::_GetString(); +} + +Record* MainView::_GetRecord() const +// *************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("MapView", _mapView)); + } + return record; +} + +void MainView::_SetCell(Cell* cell) +// ******************************** +{ + if (cell != _cell) { + UnselectAll(); + if (_cell) { + if (_mapView) _cell->_GetViewSet()._Remove(_mapView); + _cell->_GetViewSet()._Remove(this); + } + _cell = cell; + if (_cell) { + _cell->_GetViewSet()._Insert(this); + if (_mapView) _cell->_GetViewSet()._Insert(_mapView); + } + } +} + +void MainView::_SetTransformation(const Transformation& transformation) +// ******************************************************************** +{ + _transformation = transformation; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/MainView.h b/hurricane/src/hurricane/grenier/MainView.h new file mode 100644 index 00000000..564f705e --- /dev/null +++ b/hurricane/src/hurricane/grenier/MainView.h @@ -0,0 +1,82 @@ +// **************************************************************************************************** +// File: MainView.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_MAIN_VIEW +#define HURRICANE_MAIN_VIEW + +#include "View.h" + +namespace Hurricane { + +class MapView; + + + +// **************************************************************************************************** +// MainView declaration +// **************************************************************************************************** + +class MainView : public View { +// ************************* + +// Types +// ***** + + public: typedef View Inherit; + +// Attributes +// ********** + + private: Cell* _cell; + private: Transformation _transformation; + private: MapView* _mapView; + +// Constructors +// ************ + + protected: MainView(); + + public: static MainView* Create(); + +// Accessors +// ********* + + public: virtual Cell* GetCell() const {return _cell;}; + public: virtual Transformation GetTransformation() const {return _transformation;}; + public: MapView* GetMapView() const {return _mapView;}; + +// Managers +// ******** + + public: virtual bool Update(bool useDoubleBuffering = false); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("MainView");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: virtual void _SetCell(Cell* cell); + public: virtual void _SetTransformation(const Transformation& transformation); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::MainView) + +#endif // HURRICANE_MAIN_VIEW + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/MainViews.h b/hurricane/src/hurricane/grenier/MainViews.h new file mode 100644 index 00000000..e77d9ddf --- /dev/null +++ b/hurricane/src/hurricane/grenier/MainViews.h @@ -0,0 +1,62 @@ +// **************************************************************************************************** +// File: MainViews.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_MAIN_VIEWS +#define HURRICANE_MAIN_VIEWS + +#include "Collection.h" + +namespace Hurricane { + +class MainView; + + + +// **************************************************************************************************** +// MainViews declaration +// **************************************************************************************************** + +typedef GenericCollection MainViews; + + + +// **************************************************************************************************** +// MainViewLocator declaration +// **************************************************************************************************** + +typedef GenericLocator MainViewLocator; + + + +// **************************************************************************************************** +// MainViewFilter declaration +// **************************************************************************************************** + +typedef GenericFilter MainViewFilter; + + + +// **************************************************************************************************** +// for_each_main_view declaration +// **************************************************************************************************** + +#define for_each_main_view(mainView, mainViews)\ +/**********************************************/\ +{\ + MainViewLocator _locator = mainViews.GetLocator();\ + while (_locator.IsValid()) {\ + MainView* mainView = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_MAIN_VIEWS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/MapView.cpp b/hurricane/src/hurricane/grenier/MapView.cpp new file mode 100644 index 00000000..2efeecb9 --- /dev/null +++ b/hurricane/src/hurricane/grenier/MapView.cpp @@ -0,0 +1,150 @@ +// **************************************************************************************************** +// File: MapView.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "MapView.h" +#include "MainView.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// MapView implementation +// **************************************************************************************************** + +MapView::MapView(MainView* mainView) +// ********************************* +: Inherit(), + _mainView(mainView) +{ + if (!_mainView) + throw Error("Can't create " + _TName("MapView") + " : null main view"); + + if (_mainView->GetMapView()) + throw Error("Can't create " + _TName("MapView") + " : already exists"); +} + +void MapView::Delete() +// ******************* +{ + throw Error("Abnormal deletion of " + _TName("MapView")); +} + +Cell* MapView::GetCell() const +// *************************** +{ + return _mainView->GetCell(); +} + +Transformation MapView::GetTransformation() const +// ********************************************** +{ + return _mainView->GetTransformation(); +} + +Box MapView::GetClientArea() const +// ******************************* +{ + return Inherit::GetClientArea().Merge(_mainView->GetVisibleArea()); +} + +MapView* MapView::_Create(MainView* mainView) +// ****************************************** +{ + MapView* mapView = new MapView(mainView); + + mapView->_PostCreate(); + + return mapView; +} + +void MapView::_PostCreate() +// ************************ +{ + Inherit::_PostCreate(); + + HideRubbers(); + HideMarkers(); + HideCutPoints(); + HideAllLayers(); + HideGrid(); + HideSelection(); + HideDisplaySlots(); + DisableAutoScroll(); + EnableDoubleBuffering(); +} + +void MapView::_Delete() +// ******************** +{ + _PreDelete(); + + delete this; +} + +string MapView::_GetString() const +// ******************************* +{ + string s = Inherit::_GetString(); + return s; +} + +Record* MapView::_GetRecord() const +// ************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("MainView", _mainView)); + } + return record; +} + +void MapView::_SetCell(Cell* newCell) +// ********************************** +{ + assert(newCell == NULL); +} + +void MapView::_SetTransformation(const Transformation& transformation) +// ******************************************************************* +{ + //assert(false); +} + +void MapView::_PostRepaint() +// ************************* +{ + Box clientArea = _mainView->GetClientArea(); + DrawRectangle(clientArea); + + Box visibleArea = _mainView->GetVisibleArea(); + DrawRectangle(visibleArea); + DrawLine(GetX(0), + visibleArea.GetYCenter(), + visibleArea.GetXMin(), + visibleArea.GetYCenter()); + DrawLine(visibleArea.GetXMax(), + visibleArea.GetYCenter(), + GetX(GetScreenWidth()), + visibleArea.GetYCenter()); + DrawLine(visibleArea.GetXCenter(), + GetY(0), + visibleArea.GetXCenter(), + visibleArea.GetYMax()); + DrawLine(visibleArea.GetXCenter(), + GetY(GetScreenHeight()), + visibleArea.GetXCenter(), + visibleArea.GetYMin()); +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/MapView.h b/hurricane/src/hurricane/grenier/MapView.h new file mode 100644 index 00000000..1f3b498c --- /dev/null +++ b/hurricane/src/hurricane/grenier/MapView.h @@ -0,0 +1,82 @@ +// **************************************************************************************************** +// File: MapView.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_MAP_VIEW +#define HURRICANE_MAP_VIEW + +#include "View.h" + +namespace Hurricane { + +class MainView; + + + +// **************************************************************************************************** +// MapView declaration +// **************************************************************************************************** + +class MapView : public View { +// ************************ + +// Types +// ***** + + public: typedef View Inherit; + +// Attributes +// ********** + + private: MainView* _mainView; + +// Constructors +// ************ + + private: MapView(MainView* mainView); // can't be derived + +// Destructor +// ********** + + public: virtual void Delete(); + +// Accessors +// ********* + + public: virtual Cell* GetCell() const; + public: virtual Transformation GetTransformation() const; + public: virtual Box GetClientArea() const; + public: MainView* GetMainView() const {return _mainView;}; + +// Others +// ****** + + public: static MapView* _Create(MainView* mainView); + private: virtual void _PostCreate(); + + public: void _Delete(); + + public: virtual string _GetTypeName() const {return _TName("MapView");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: virtual void _SetCell(Cell* cell); + public: virtual void _SetTransformation(const Transformation& transformation); + + public: virtual void _PostRepaint(); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::MapView) + +#endif // HURRICANE_MAP_VIEW + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/OutputFile.cpp b/hurricane/src/hurricane/grenier/OutputFile.cpp new file mode 100644 index 00000000..14ab26fe --- /dev/null +++ b/hurricane/src/hurricane/grenier/OutputFile.cpp @@ -0,0 +1,144 @@ +// **************************************************************************************************** +// File: OutputFile.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "OutputFile.h" +#include "Layer.h" +#include "Library.h" +#include "Cell.h" +#include "Instance.h" +#include "Component.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// OutputFile implementation +// **************************************************************************************************** + +OutputFile::OutputFile(const string& filePathName) +// *********************************************** +: _filePathName(filePathName), + _file(filePathName.c_str()), + _tab("\t"), + _dboIdMap(), + _componentIdMap(), + _cellSet(), + _cellVector() +{ + if (_filePathName.empty()) + throw Error("Can't create OutputFile : empty file pathname"); + + if (!_file.good()) + throw Error("Can't create OutputFile : bad file"); +} + +unsigned OutputFile::GetId(DBo* dbo) +// ********************************* +{ + DBoIdMap::iterator it = _dboIdMap.find(dbo); + return (it != _dboIdMap.end()) ? (*it).second : 0; +} + +Cells OutputFile::GetCells() +// ************************* + {return GetCollection(_cellVector);} + +unsigned OutputFile::GetId(Component* component) +// ********************************************* +{ + ComponentIdMap::iterator it = _componentIdMap.find(component); + return (it != _componentIdMap.end()) ? (*it).second : 0; +} + +void OutputFile::Push(Cell* cell) +// ****************************** +{ + if (_cellSet.find(cell) == _cellSet.end()) { + for_each_instance(instance, cell->GetInstances()) { + Push(instance->GetMasterCell()); + end_for; + } + _cellSet.insert(cell); + _cellVector.push_back(cell); + } +} + +void OutputFile::Register(DBo* dbo) +// ******************************** +{ + if (dbo && !GetId(dbo)) { + unsigned id = _dboIdMap.size() + 1; + _dboIdMap[dbo] = id; + } +} + +void OutputFile::Register(Component* component) +// ******************************************** +{ + if (component && !GetId(component)) { + unsigned id = _componentIdMap.size() + 1; + _componentIdMap[component] = id; + } +} + +void OutputFile::OpenHeader() +// ************************** +{ + _file << _tab; +} + +void OutputFile::CloseHeader() +// *************************** +{ + _file << endl; +} + +void OutputFile::OpenContent() +// *************************** +{ + ++_tab; +} + +void OutputFile::CloseContent() +// **************************** +{ + --_tab; +} + +void OutputFile::ClearComponentIdMap() +// *********************************** +{ + _componentIdMap.clear(); +} + +string OutputFile::_GetString() const +// ********************************** +{ + return "<" + _TName("OutputFile") + " " + _filePathName + ">"; +} + +Record* OutputFile::_GetRecord() const +// ***************************** +{ + Record* record = new Record(GetString(this)); + if (record) { + record->Add(GetSlot("FilePathName", &_filePathName)); + record->Add(GetSlot("DBoIds", &_dboIdMap)); + record->Add(GetSlot("ComponentIds", &_componentIdMap)); + record->Add(GetSlot("Cells", &_cellVector)); + } + return record; +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/OutputFile.h b/hurricane/src/hurricane/grenier/OutputFile.h new file mode 100644 index 00000000..9f4028c6 --- /dev/null +++ b/hurricane/src/hurricane/grenier/OutputFile.h @@ -0,0 +1,108 @@ +// **************************************************************************************************** +// File: OutputFile.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_OUTPUT_FILE +#define HURRICANE_OUTPUT_FILE + +#include "Commons.h" +#include "Cells.h" + +namespace Hurricane { + +class DBo; +class Cell; +class Component; + + + +// **************************************************************************************************** +// OutputFile declaration +// **************************************************************************************************** + +class OutputFile { +// ************* + +// Types +// ***** + + public: typedef map DBoIdMap; + public: typedef map ComponentIdMap; + public: typedef set CellSet; + public: typedef vector CellVector; + +// Attributes +// ********** + + private: string _filePathName; + private: ofstream _file; + private: Tabulation _tab; + private: DBoIdMap _dboIdMap; + private: ComponentIdMap _componentIdMap; + private: CellSet _cellSet; + private: CellVector _cellVector; + +// Constructors +// ************ + + public: OutputFile(const string& filePathName); + + private: OutputFile(const OutputFile& outputFile); // not implemented to forbid copy + +// Operators +// ********* + + private: OutputFile& operator=(const OutputFile& outputFile); // not implemented to forbid assinment + + public: template OutputFile& operator<<(Data data) + // *********************************************************** + { + _file << GetString(data); + return *this; + } + +// Accessors +// ********* + + public: const string& GetFilePathName() const {return _filePathName;} + + public: unsigned GetId(DBo* dbo); + public: unsigned GetId(Component* component); + + public: Cells GetCells(); // {return GetCollection(_cellVector);}; NOON!!! + +// Managers +// ******** + + public: void Push(Cell* cell); + + public: void Register(DBo* dbo); + public: void Register(Component* component); + + public: void OpenHeader(); + public: void CloseHeader(); + public: void OpenContent(); + public: void CloseContent(); + + public: void ClearComponentIdMap(); + +// Others +// ****** + + public: string _GetTypeName() const { return _TName("OutputFile"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + +}; + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_OUTPUT_FILE + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/Primitive.cpp b/hurricane/src/hurricane/grenier/Primitive.cpp new file mode 100644 index 00000000..cf9c1399 --- /dev/null +++ b/hurricane/src/hurricane/grenier/Primitive.cpp @@ -0,0 +1,609 @@ +// **************************************************************************************************** +// File: Primitive.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Primitive.h" +#include "Symbol.h" +#include "View.h" +#include "Error.h" + +#include + +namespace Hurricane { + + + +// **************************************************************************************************** +// Variables +// **************************************************************************************************** + +static vector POINTS; + + + +// **************************************************************************************************** +// Primitive implementation +// **************************************************************************************************** + +Primitive::Primitive(Symbol* symbol) +// ********************************* +: Inherit(), + _symbol(symbol) +{ + if (!_symbol) + throw Error("Can't create " + _TName("Primitive") + " : null symbol"); +} + +void Primitive::_PostCreate() +// ************************** +{ + _symbol->_GetPrimitiveList().push_back(this); + _symbol->_Fit(GetBoundingBox()); + + Inherit::_PostCreate(); +} + +void Primitive::_PreDelete() +// ************************* +{ + Inherit::_PreDelete(); + + _symbol->_Unfit(GetBoundingBox()); + _symbol->_GetPrimitiveList().remove(this); +} + +string Primitive::_GetString() const +// ********************************* +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_symbol->GetName())); + return s; +} + +Record* Primitive::_GetRecord() const +// **************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Symbol", _symbol)); + } + return record; +} + +void Primitive::_Highlight(View* view, const Box& updateArea, const Transformation& transformation) +// ************************************************************************************************ +{ + _Draw(view, updateArea, transformation); +} + + + +// **************************************************************************************************** +// Port implementation +// **************************************************************************************************** + +Port::Port(Symbol* symbol, const Name& name, const Point& position) +// **************************************************************** +: Inherit(symbol), + _name(name), + _position(position) +{ + if (name.IsEmpty()) + throw Error("Can't create " + _TName("Port") + " : empty name"); + + if (GetSymbol()->GetPort(_name)) + throw Error("Can't create " + _TName("Port") + " : already exists"); +} + +Port* Port::Create(Symbol* symbol, const Name& name, const Point& position) +// ************************************************************************ +{ + Port* port = new Port(symbol, name, position); + + port->_PostCreate(); + + return port; +} + +Port* Port::Create(Symbol* symbol, const Name& name, const Unit& x, const Unit& y) +// ******************************************************************************* +{ + Port* port = new Port(symbol, name, Point(x, y)); + + port->_PostCreate(); + + return port; +} + +string Port::_GetString() const +// **************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_name)); + s.insert(s.length() - 1, " [" + GetValueString(_position.GetX())); + s.insert(s.length() - 1, " " + GetValueString(_position.GetY()) + "]"); + return s; +} + +Record* Port::_GetRecord() const +// *********************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("Position", &_position)); + } + return record; +} + +bool Port::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +// ************************************************************************************ +{ + return GetBoundingBox().Intersect(Box(point).Inflate(aperture)); +} + +void Port::_Draw(View* view, const Box& updateArea, const Transformation& transformation) +// ************************************************************************************** +{ + if (0 < view->GetScale()) { + if (view->GetScale() <= 10) + view->DrawPoint(transformation.GetPoint(_position), 1); + else if (view->GetScale() <= 20) + view->DrawPoint(transformation.GetPoint(_position), 2); + else + view->DrawPoint(transformation.GetPoint(_position), 3); + } +} + + + +// **************************************************************************************************** +// Line implementation +// **************************************************************************************************** + +Line::Line(Symbol* symbol, const Point& source, const Point& target) +// ***************************************************************** +: Inherit(symbol), + _source(source), + _target(target) +{ +} + +Line* Line::Create(Symbol* symbol, const Point& source, const Point& target) +// ************************************************************************* +{ + Line* line = new Line(symbol, source, target); + + line->_PostCreate(); + + return line; +} + +Line* Line::Create(Symbol* symbol, const Unit& xSource, const Unit& ySource, const Unit& xTarget, const Unit& yTarget) +// **************************************************************************************************** +{ + Line* line = new Line(symbol, Point(xSource, ySource), Point(xTarget, yTarget)); + + line->_PostCreate(); + + return line; +} + +string Line::_GetString() const +// **************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " [" + GetValueString(_source.GetX())); + s.insert(s.length() - 1, " " + GetValueString(_source.GetY()) + "]"); + s.insert(s.length() - 1, " [" + GetValueString(_target.GetX())); + s.insert(s.length() - 1, " " + GetValueString(_target.GetY()) + "]"); + return s; +} + +Record* Line::_GetRecord() const +// *********************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Source", &_source)); + record->Add(GetSlot("Target", &_target)); + } + return record; +} + +bool Line::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +// ************************************************************************************ +{ + if (GetBoundingBox().Intersect(Box(point).Inflate(aperture))) { + + double a = GetValue(aperture); + + double x = GetValue(point.GetX()); + double y = GetValue(point.GetY()); + double xo = GetValue(_source.GetX()); + double yo = GetValue(_source.GetY()); + double xe = GetValue(_target.GetX()); + double ye = GetValue(_target.GetY()); + + double xp = xo; + double yp = yo; + + if (xo != xe) xp = (((xe - xo) / (ye - yo)) * (y - yo)) + xo; + if (yo != ye) yp = (((ye - yo) / (xe - xo)) * (x - xo)) + yo; + if ((abs(xp - x) <= a) || (abs(yp - y) <= a)) return true; + + } + + return false; +} + +void Line::_Draw(View* view, const Box& updateArea, const Transformation& transformation) +// ************************************************************************************** +{ + view->DrawLine(transformation.GetPoint(_source), transformation.GetPoint(_target)); +} + + + +// **************************************************************************************************** +// Rectangle implementation +// **************************************************************************************************** + +Rectangle::Rectangle(Symbol* symbol, const Box& box, bool isFilled) +// **************************************************************** +: Inherit(symbol), + _box(box), + _isFilled(isFilled) +{ +} + +Rectangle* Rectangle::Create(Symbol* symbol, const Box& box, bool isFilled) +// ************************************************************************ +{ + Rectangle* rectangle = new Rectangle(symbol, box, isFilled); + + rectangle->_PostCreate(); + + return rectangle; +} + +Rectangle* Rectangle::Create(Symbol* symbol, const Point& point1, const Point& point2, bool isFilled) +// ************************************************************************************************** +{ + Rectangle* rectangle = new Rectangle(symbol, Box(point1, point2), isFilled); + + rectangle->_PostCreate(); + + return rectangle; +} + +Rectangle* Rectangle::Create(Symbol* symbol, const Unit& x1, const Unit& y1, const Unit& x2, const Unit& y2, bool isFilled) +// ************************************************************************************************** +{ + Rectangle* rectangle = new Rectangle(symbol, Box(x1, y1, x2, y2), isFilled); + + rectangle->_PostCreate(); + + return rectangle; +} + +string Rectangle::_GetString() const +// ********************************* +{ + string s = Inherit::_GetString(); + if (_box.IsEmpty()) + s.insert(s.length() - 1, " [empty]"); + else { + s.insert(s.length() - 1, " [" + GetValueString(_box.GetXMin())); + s.insert(s.length() - 1, " " + GetValueString(_box.GetYMin())); + s.insert(s.length() - 1, " " + GetValueString(_box.GetXMax())); + s.insert(s.length() - 1, " " + GetValueString(_box.GetYMax()) + "]"); + } + if (_isFilled) s.insert(s.length() - 1, " FILLED"); + return s; +} + +Record* Rectangle::_GetRecord() const +// **************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Box", &_box)); + record->Add(GetSlot("IsFilled", &_isFilled)); + } + return record; +} + +bool Rectangle::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +// ***************************************************************************************** +{ + Box area = Box(point).Inflate(aperture); + + return (_isFilled) ? + _box.Intersect(area) : + (_box.Intersect(area) && !Box(_box).Inflate(-aperture * 2).Intersect(area)); + +} + +void Rectangle::_Draw(View* view, const Box& updateArea, const Transformation& transformation) +// ******************************************************************************************* +{ + if (!_isFilled) + view->DrawRectangle(transformation.GetBox(_box)); + else + view->FillRectangle(transformation.GetBox(_box)); +} + + + +// **************************************************************************************************** +// Circle implementation +// **************************************************************************************************** + +Circle::Circle(Symbol* symbol, const Point& center, const Unit& radius) +// ******************************************************************** +: Inherit(symbol), + _center(center), + _radius(radius) +{ + if (_radius < 0) + throw Error("Can't create " + _TName("Circle") + " : negative radius"); +} + +Circle* Circle::Create(Symbol* symbol, const Unit& x, const Unit& y, const Unit& radius) +// ************************************************************************************* +{ + Circle* circle = new Circle(symbol, Point(x, y), radius); + + circle->_PostCreate(); + + return circle; +} + +Circle* Circle::Create(Symbol* symbol, const Point& center, const Unit& radius) +// **************************************************************************** +{ + Circle* circle = new Circle(symbol, center, radius); + + circle->_PostCreate(); + + return circle; +} + +string Circle::_GetString() const +// ****************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " [" + GetValueString(_center.GetX())); + s.insert(s.length() - 1, " " + GetValueString(_center.GetY()) + "]"); + s.insert(s.length() - 1, " " + GetValueString(_radius)); + return s; +} + +Record* Circle::_GetRecord() const +// ************************* +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Center", &_center)); + record->Add(GetSlot("Radius", &_radius)); + } + return record; +} + +bool Circle::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +// ************************************************************************************** +{ + if (GetBoundingBox().Intersect(Box(point).Inflate(aperture))) { + + double xp = GetValue(point.GetX()); + double yp = GetValue(point.GetY()); + double xc = GetValue(_center.GetX()); + double yc = GetValue(_center.GetY()); + + double d = sqrt(pow(abs(xp - xc), 2) + pow(abs(yp - yc), 2)) - GetValue(aperture); + + return (d <= GetValue(_radius)); + + } + + return false; +} + +void Circle::_Draw(View* view, const Box& updateArea, const Transformation& transformation) +// **************************************************************************************** +{ + view->DrawCircle(transformation.GetPoint(_center), _radius); +} + + + +// **************************************************************************************************** +// Lines implementation +// **************************************************************************************************** + +Lines::Lines(Symbol* symbol, const Points& points) +// *********************************************** +: Inherit(symbol), + _points(points) +{ +} + +Lines* Lines::Create(Symbol* symbol, const Points& points) +// ******************************************************* +{ + Lines* lines = new Lines(symbol, points); + + lines->_PostCreate(); + + return lines; +} + +Box Lines::GetBoundingBox() const +// ****************************** +{ + Box boundingBox; + for (unsigned i = 0; i < _points.size(); i++) + boundingBox.Merge(_points[i]); + return boundingBox; +} + +string Lines::_GetString() const +// ***************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetValueString(_points.size())); + return s; +} + +Record* Lines::_GetRecord() const +// ************************ +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Points", &_points)); + } + return record; +} + +bool Lines::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +// ************************************************************************************* +{ + if (1 < _points.size()) { + double a = GetValue(aperture); + double x = GetValue(point.GetX()); + double y = GetValue(point.GetY()); + + Point origin = _points[0]; + for (unsigned i = 1; i < _points.size(); i++) { + Point extremity = _points[i]; + if (Box(origin, extremity).Intersect(Box(point).Inflate(aperture))) { + double xo = GetValue(origin.GetX()); + double yo = GetValue(origin.GetY()); + double xe = GetValue(extremity.GetX()); + double ye = GetValue(extremity.GetY()); + double xp = xo; + double yp = yo; + if (xo != xe) xp = (((xe - xo) / (ye - yo)) * (y - yo)) + xo; + if (yo != ye) yp = (((ye - yo) / (xe - xo)) * (x - xo)) + yo; + if ((abs(xp - x) <= a) || (abs(yp - y) <= a)) return true; + } + origin = extremity; + } + } + + return false; +} + +void Lines::_Draw(View* view, const Box& updateArea, const Transformation& transformation) +// *************************************************************************************** +{ + for (unsigned i = POINTS.size(); i < _points.size(); i++) + POINTS.push_back(Point(0, 0)); + + for (unsigned i = 0; i < _points.size(); i++) + POINTS[i] = transformation.GetPoint(_points[i]); + + view->DrawLines(POINTS, _points.size()); +} + + + +// **************************************************************************************************** +// Polygon implementation +// **************************************************************************************************** + +Polygon::Polygon(Symbol* symbol, const Points& points) +// *************************************************** +: Inherit(symbol), + _points(points) +{ +} + +Polygon* Polygon::Create(Symbol* symbol, const Points& points) +// *********************************************************** +{ + Polygon* polygon = new Polygon(symbol, points); + + polygon->_PostCreate(); + + return polygon; +} + +Box Polygon::GetBoundingBox() const +// ******************************** +{ + Box boundingBox; + for (unsigned i = 0; i < _points.size(); i++) + boundingBox.Merge(_points[i]); + return boundingBox; +} + +string Polygon::_GetString() const +// ******************************* +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetValueString(_points.size())); + return s; +} + +Record* Polygon::_GetRecord() const +// ************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Points", &_points)); + } + return record; +} + +bool Polygon::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +// *************************************************************************************** +{ + if (1 < _points.size()) { + double a = GetValue(aperture); + double x = GetValue(point.GetX()); + double y = GetValue(point.GetY()); + + Point origin = _points[0]; + for (unsigned i = 1; i <= _points.size(); i++) { + Point extremity = (i == _points.size()) ? _points[0] : _points[i]; + if (Box(origin, extremity).Intersect(Box(point).Inflate(aperture))) { + double xo = GetValue(origin.GetX()); + double yo = GetValue(origin.GetY()); + double xe = GetValue(extremity.GetX()); + double ye = GetValue(extremity.GetY()); + double xp = xo; + double yp = yo; + if (xo != xe) xp = (((xe - xo) / (ye - yo)) * (y - yo)) + xo; + if (yo != ye) yp = (((ye - yo) / (xe - xo)) * (x - xo)) + yo; + if ((abs(xp - x) <= a) || (abs(yp - y) <= a)) return true; + } + origin = extremity; + } + } + + return false; +} + +void Polygon::_Draw(View* view, const Box& updateArea, const Transformation& transformation) +// ***************************************************************************************** +{ + for (unsigned i = POINTS.size(); i < _points.size(); i++) + POINTS.push_back(Point(0, 0)); + + for (unsigned i = 0; i < _points.size(); i++) + POINTS[i] = transformation.GetPoint(_points[i]); + + view->DrawPolygon(POINTS, _points.size()); +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/Primitive.h b/hurricane/src/hurricane/grenier/Primitive.h new file mode 100644 index 00000000..9fc44cc6 --- /dev/null +++ b/hurricane/src/hurricane/grenier/Primitive.h @@ -0,0 +1,365 @@ +// **************************************************************************************************** +// File: Primitive.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_PRIMITIVE +#define HURRICANE_PRIMITIVE + +#include "DBo.h" +#include "Primitives.h" +#include "Transformation.h" + +namespace Hurricane { + +class Symbol; +class View; + + + +// **************************************************************************************************** +// Primitive declaration +// **************************************************************************************************** + +class Primitive : public DBo { +// ************************* + +// Types +// ***** + + public: typedef DBo Inherit; + +// Attributes +// ********** + + private: Symbol* _symbol; + +// Constructors +// ************ + + protected: Primitive(Symbol* symbol); + +// Accessors +// ********* + + public: Symbol* GetSymbol() const {return _symbol;}; + public: virtual Box GetBoundingBox() const = 0; + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const = 0; + public: virtual void _Draw(View* view, const Box& updateArea, const Transformation& transformation) = 0; + public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + + +// **************************************************************************************************** +// Port declaration +// **************************************************************************************************** + +class Port : public Primitive { +// ************************** + +// Types +// ***** + + public: typedef Primitive Inherit; + +// Attributes +// ********** + + private: Name _name; + private: Point _position; + +// Constructors +// ************ + + protected: Port(Symbol* symbol, const Name& name, const Point& position); + + public: static Port* Create(Symbol* symbol, const Name& name, const Point& position); + public: static Port* Create(Symbol* symbol, const Name& name, const Unit& x, const Unit& y); + +// Accessors +// ********* + + public: virtual Box GetBoundingBox() const {return Box(_position);}; + public: const Name& GetName() const {return _name;}; + public: const Unit& GetX() const {return _position.GetX();}; + public: const Unit& GetY() const {return _position.GetY();}; + public: const Point& GetPosition() const {return _position;}; + +// Others +// ****** + + public: virtual string _GetTypeName() const {return _TName("Port");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; + public: virtual void _Draw(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + + +// **************************************************************************************************** +// Line declaration +// **************************************************************************************************** + +class Line : public Primitive { +// ************************** + +// Types +// ***** + + public: typedef Primitive Inherit; + +// Attributes +// ********** + + private: Point _source; + private: Point _target; + +// Constructors +// ************ + + protected: Line(Symbol* symbol, const Point& source, const Point& target); + + public: static Line* Create(Symbol* symbol, const Point& source, const Point& target); + public: static Line* Create(Symbol* symbol, const Unit& xSource, const Unit& ySource, const Unit& xTarget, const Unit& yTarget); + +// Accessors +// ********* + + public: virtual Box GetBoundingBox() const {return Box(_source, _target);}; + public: const Point& GetSource() const {return _source;}; + public: const Point& GetTarget() const {return _target;}; + +// Others +// ****** + + public: virtual string _GetTypeName() const {return _TName("Line");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; + public: virtual void _Draw(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + + +// **************************************************************************************************** +// Rectangle declaration +// **************************************************************************************************** + +class Rectangle : public Primitive { +// ******************************* + +// Types +// ***** + + public: typedef Primitive Inherit; + +// Attributes +// ********** + + private: Box _box; + private: bool _isFilled; + +// Constructors +// ************ + + protected: Rectangle(Symbol* symbol, const Box& box, bool isFilled = false); + + public: static Rectangle* Create(Symbol* symbol, const Box& box, bool isFilled = false); + public: static Rectangle* Create(Symbol* symbol, const Point& point1, const Point& point2, bool isFilled = false); + public: static Rectangle* Create(Symbol* symbol, const Unit& x1, const Unit& y1, const Unit& x2, const Unit& y2, bool isFilled = false); + +// Accessors +// ********* + + public: virtual Box GetBoundingBox() const {return _box;}; + public: const Box& GetBox() const {return _box;}; + +// Others +// ****** + + public: virtual string _GetTypeName() const {return _TName("Rectangle");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; + public: virtual void _Draw(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + + +// **************************************************************************************************** +// Circle declaration +// **************************************************************************************************** + +class Circle : public Primitive { +// **************************** + +// Types +// ***** + + public: typedef Primitive Inherit; + +// Attributes +// ********** + + private: Point _center; + private: Unit _radius; + +// Constructors +// ************ + + protected: Circle(Symbol* symbol, const Point& center, const Unit& radius); + + public: static Circle* Create(Symbol* symbol, const Unit& x, const Unit& y, const Unit& radius); + public: static Circle* Create(Symbol* symbol, const Point& center, const Unit& radius); + +// Accessors +// ********* + + public: virtual Box GetBoundingBox() const {return Box(_center).Inflate(_radius);}; + public: const Point& GetCenter() const {return _center;}; + public: const Unit& GetRadius() const {return _radius;}; + +// Others +// ****** + + public: virtual string _GetTypeName() const {return _TName("Circle");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; + public: virtual void _Draw(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + + +// **************************************************************************************************** +// Lines declaration +// **************************************************************************************************** + +class Lines : public Primitive { +// *************************** + +// Types +// ***** + + public: typedef Primitive Inherit; + + public: typedef vector Points; + +// Attributes +// ********** + + private: Points _points; + +// Constructors +// ************ + + protected: Lines(Symbol* symbol, const Points& points); + + public: static Lines* Create(Symbol* symbol, const Points& points); + +// Accessors +// ********* + + public: virtual Box GetBoundingBox() const; + public: const Points& GetPoints() const {return _points;}; + public: unsigned GetSize() const {return _points.size();}; + +// Others +// ****** + + public: virtual string _GetTypeName() const {return _TName("Lines");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; + public: virtual void _Draw(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + + +// **************************************************************************************************** +// Polygon declaration +// **************************************************************************************************** + +class Polygon : public Primitive { +// ***************************** + +// Types +// ***** + + public: typedef Primitive Inherit; + + public: typedef vector Points; + +// Attributes +// ********** + + private: Points _points; + +// Constructors +// ************ + + protected: Polygon(Symbol* symbol, const Points& points); + + public: static Polygon* Create(Symbol* symbol, const Points& points); + +// Accessors +// ********* + + public: virtual Box GetBoundingBox() const; + public: const Points& GetPoints() const {return _points;}; + public: unsigned GetSize() const {return _points.size();}; + +// Others +// ****** + + public: virtual string _GetTypeName() const {return _TName("Polygon");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + + public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; + public: virtual void _Draw(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Primitive) +SetNestedSlotAdapter(Hurricane::Port) +SetNestedSlotAdapter(Hurricane::Line) +SetNestedSlotAdapter(Hurricane::Rectangle) +SetNestedSlotAdapter(Hurricane::Lines) +SetNestedSlotAdapter(Hurricane::Polygon) + +#endif // HURRICANE_PRIMITIVE + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/Selector.cpp b/hurricane/src/hurricane/grenier/Selector.cpp new file mode 100644 index 00000000..391d53e1 --- /dev/null +++ b/hurricane/src/hurricane/grenier/Selector.cpp @@ -0,0 +1,119 @@ +// **************************************************************************************************** +// File: Selector.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Selector.h" +#include "Quark.h" +#include "View.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Selector implementation +// **************************************************************************************************** + +Selector::Selector() +// ***************** +: Inherit(), + _viewSet() +{ +} + +const Name& Selector::GetPropertyName() +// ************************************ +{ + static Name NAME = _PName("Selector"); + return NAME; +} + +Name Selector::GetName() const +// *************************** +{ + return Selector::GetPropertyName(); +} + +Occurrence Selector::GetOccurrence() const +// ************************************* +{ + DBo* owner = GetOwner(); + if (!owner) return Occurrence(); + assert(is_a(owner)); + return ((Quark*)owner)->GetOccurrence(); +} + +Selector* Selector::_Create(Occurrence& occurrence) +// ********************************************** +{ + if (!occurrence.IsValid()) + throw Error("Can't create " + _TName("Selector") + " : invalid occurrence"); + + if (occurrence.GetProperty(Selector::GetPropertyName())) + throw Error("Can't create " + _TName("Selector") + " : already exists"); + + Selector* selector = new Selector(); + + selector->_PostCreate(); + + occurrence.Put(selector); + + return selector; +} + +void Selector::_PreDelete() +// ************************ +{ + Inherit::_PreDelete(); + + for_each_view(view, GetViews()) _DetachFrom(view, true); end_for; +} + +string Selector::_GetString() const +// ******************************** +{ + return "<" + _TName("Selector") + " " + GetString(GetOccurrence()) + ">"; +} + +Record* Selector::_GetRecord() const +// *************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Views", &_viewSet)); + } + return record; +} + +void Selector::_AttachTo(View* view) +// ********************************* +{ + if (!view) + throw Error("Can't attach selector : null view)"); + + _viewSet.insert(view); + view->_GetSelectorSet().insert(this); +} + +void Selector::_DetachFrom(View* view, bool inDeletion) +// **************************************************** +{ + if (!view) + throw Error("Can't detach selector : null view"); + + view->_GetSelectorSet().erase(this); + _viewSet.erase(view); + + if (!inDeletion && _viewSet.empty()) Delete(); +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/Selector.h b/hurricane/src/hurricane/grenier/Selector.h new file mode 100644 index 00000000..efbcccee --- /dev/null +++ b/hurricane/src/hurricane/grenier/Selector.h @@ -0,0 +1,78 @@ +// **************************************************************************************************** +// File: Selector.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_SELECTOR +#define HURRICANE_SELECTOR + +#include "Property.h" +#include "Selectors.h" +#include "Occurrence.h" +#include "Views.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Selector declaration +// **************************************************************************************************** + +class Selector : public PrivateProperty { +// ************************************ + +// Types +// ***** + + public: typedef PrivateProperty Inherit; + + public: typedef set ViewSet; + +// Attributes +// ********** + + private: ViewSet _viewSet; + +// Constructors +// ************ + + protected: Selector(); + +// Accessors +// ********* + + public: static const Name& GetPropertyName(); + public: virtual Name GetName() const; + public: Occurrence GetOccurrence() const; + public: Views GetViews() const {return GetCollection(_viewSet);}; + +// Ohers +// ***** + + public: static Selector* _Create(Occurrence& occurrence); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("Selector");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: ViewSet& _GetViewSet() {return _viewSet;}; + + public: void _AttachTo(View* view); + public: void _DetachFrom(View* view, bool inDeletion = false); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Selector) + +#endif // HURRICANE_SELECTOR + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/Symbol.cpp b/hurricane/src/hurricane/grenier/Symbol.cpp new file mode 100644 index 00000000..a785c146 --- /dev/null +++ b/hurricane/src/hurricane/grenier/Symbol.cpp @@ -0,0 +1,344 @@ +// **************************************************************************************************** +// File: Symbol.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#include "Symbol.h" +#include "Library.h" +#include "Net.h" +#include "View.h" +#include "Error.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Net comparator +// **************************************************************************************************** + +struct Symbol_NetSetComparator { +// *************************** + + bool operator()(Net* net1, Net* net2) const + // **************************************** + { + return (net1->GetName() < net2->GetName()); + }; + +}; + + + +// **************************************************************************************************** +// Symbol implementation +// **************************************************************************************************** + +Symbol::Symbol(Library* library, const Name& name) +// *********************************************** +: Inherit(), + _library(library), + _name(name), + _cellSet(), + _primitiveList(), + _boundingBox(), + _nextOfLibrarySymbolMap(NULL) +{ + if (!_library) + throw Error("Can't create " + _TName("Symbol") + " : null library"); + + if (name.IsEmpty()) + throw Error("Can't create " + _TName("Symbol") + " : empty name"); + + if (_library->GetSymbol(_name)) + throw Error("Can't create " + _TName("Symbol") + " : already exists"); +} + +Symbol* Symbol::Create(Library* library, const Name& name) +// ******************************************************* +{ + Symbol* symbol = new Symbol(library, name); + + symbol->_PostCreate(); + + return symbol; +} + +Symbol* Symbol::CreateFor(Cell* cell) +// ********************************** +{ + if (!cell) + throw Error("Can't create " + _TName("Symbol") + " for cell : null cell"); + + char name[32]; + static unsigned NEW_SYMBOL_ID = 1; + sprintf(name, "~symbol%d", NEW_SYMBOL_ID++); + + Symbol* symbol = new Symbol(cell->GetLibrary(), name); + + symbol->_PostCreate(); + + set westNetSet; + set eastNetSet; + set northNetSet; + set southNetSet; + + for_each_net(net, cell->GetExternalNets()) { + if (!net->IsSupply()) { + switch (net->GetDirection()) { + case Net::Direction::IN : westNetSet.insert(net); break; + case Net::Direction::OUT : eastNetSet.insert(net); break; + case Net::Direction::UNDEFINED : northNetSet.insert(net); break; + default : southNetSet.insert(net); break; + } + } + end_for; + } + + int westSize = westNetSet.size(); + int eastSize = eastNetSet.size(); + int northSize = northNetSet.size(); + int southSize = southNetSet.size(); + + int width = max(max(northSize, southSize), 1) * 4; + int halfWidth = width / 2; + int height = max(max(westSize, eastSize), 1) * 4; + int halfHeight = height / 2; + + Rectangle::Create(symbol, Box(0, 0).Inflate(GetUnit(halfWidth), GetUnit(halfHeight)), true); + + if (westSize) { + int offset = (height - ((westSize - 1) * 4)) / 2; + int x = - halfWidth; + int y = offset - halfHeight; + for_each_net(net, GetCollection(westNetSet)) { + Line::Create(symbol, GetUnit(x), GetUnit(y), GetUnit(x - 1), GetUnit(y)); + Port::Create(symbol, net->GetName(), GetUnit(x - 1), GetUnit(y)); + y += 4; + end_for; + } + } + + if (eastSize) { + int offset = (height - ((eastSize - 1) * 4)) / 2; + int x = halfWidth; + int y = offset - halfHeight; + for_each_net(net, GetCollection(eastNetSet)) { + Line::Create(symbol, GetUnit(x), GetUnit(y), GetUnit(x + 1), GetUnit(y)); + Port::Create(symbol, net->GetName(), GetUnit(x + 1), GetUnit(y)); + y += 4; + end_for; + } + } + + if (northSize) { + int offset = (width - ((northSize - 1) * 4)) / 2; + int x = offset - halfWidth; + int y = halfHeight; + for_each_net(net, GetCollection(northNetSet)) { + Line::Create(symbol, GetUnit(x), GetUnit(y), GetUnit(x), GetUnit(y + 1)); + Port::Create(symbol, net->GetName(), GetUnit(x), GetUnit(y + 1)); + x += 4; + end_for; + } + } + + if (southSize) { + int offset = (width - ((southSize - 1) * 4)) / 2; + int x = offset - halfWidth; + int y = - halfHeight; + for_each_net(net, GetCollection(southNetSet)) { + Line::Create(symbol, GetUnit(x), GetUnit(y), GetUnit(x), GetUnit(y - 1)); + Port::Create(symbol, net->GetName(), GetUnit(x), GetUnit(y - 1)); + x += 4; + end_for; + } + } + + return symbol; +} + +Box Symbol::GetBoundingBox() const +// ******************************* +{ + if (_boundingBox.IsEmpty()) { + Box& boundingBox = (Box&)_boundingBox; + for_each_primitive(primitive, GetPrimitives()) { + boundingBox.Merge(primitive->GetBoundingBox()); + end_for; + } + } + + return _boundingBox; +} + +Port* Symbol::GetPort(const Name& name) const +// ****************************************** +{ + for_each_primitive(primitive, GetPrimitives()) { + if (is_a(primitive) && (((Port*)primitive)->GetName() == name)) + return (Port*)primitive; + end_for; + } + return NULL; +} + +void Symbol::SetName(const Name& name) +// *********************************** +{ + if (name != _name) { + if (name.IsEmpty()) + throw Error("Can't change " + _TName("Symbol") + " name : empty name"); + + if (_library->GetSymbol(name)) + throw Error("Can't change " + _TName("Symbol") + " name : already exists"); + + _library->_GetSymbolMap()._Remove(this); + _name = name; + _library->_GetSymbolMap()._Insert(this); + } +} + +void Symbol::_PostCreate() +// *********************** +{ + _library->_GetSymbolMap()._Insert(this); + + Inherit::_PostCreate(); +} + +void Symbol::_PreDelete() +// ********************** +{ + Inherit::_PreDelete(); + + for_each_cell(cell, GetCells()) cell->SetSymbol(NULL); end_for; + for_each_primitive(primitive, GetPrimitives()) primitive->Delete(); end_for; + + _library->_GetSymbolMap()._Remove(this); +} + +string Symbol::_GetString() const +// ****************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(_name)); + return s; +} + +Record* Symbol::_GetRecord() const +// ************************* +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Library", _library)); + record->Add(GetSlot("Name", &_name)); + record->Add(GetSlot("Cells", &_cellSet)); + record->Add(GetSlot("Primitives", &_primitiveList)); + record->Add(GetSlot("BoundingBox", &_boundingBox)); + } + return record; +} + +void Symbol::_Fit(const Box& box) +// ****************************** +{ + if (box.IsEmpty()) return; + if (_boundingBox.IsEmpty()) return; + if (_boundingBox.Contains(box)) return; + _boundingBox.Merge(box); + for_each_cell(cell, GetCells()) { + cell->_Fit(box); + end_for; + } +} + +void Symbol::_Unfit(const Box& box) +// ******************************** +{ + if (box.IsEmpty()) return; + if (_boundingBox.IsEmpty()) return; + if (!_boundingBox.IsConstrainedBy(box)) return; + for_each_cell(cell, GetCells()) { + cell->_Unfit(box); + end_for; + } + _boundingBox.MakeEmpty(); +} + +bool Symbol::_IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const +// ************************************************************************************** +{ + for_each_primitive(primitive, GetPrimitives()) { + if (primitive->_IsInterceptedBy(view, point, aperture)) return true; + end_for; + } + return false; +} + +void Symbol::_Draw(View* view, const Box& updateArea, const Transformation& transformation) +// **************************************************************************************** +{ + for_each_primitive(primitive, GetPrimitives()) { + primitive->_Draw(view, updateArea, transformation); + end_for; + } +} + +void Symbol::_Highlight(View* view, const Box& updateArea, const Transformation& transformation) +// ********************************************************************************************* +{ + for_each_primitive(primitive, GetPrimitives()) { + primitive->_Highlight(view, updateArea, transformation); + end_for; + } +} + +void Symbol::_SaveHeaderTo(OutputFile& outputFile) +// *********************************************** +{ +} + +void Symbol::_SaveContentTo(OutputFile& outputFile) +// ************************************************ +{ +} + + + +// **************************************************************************************************** +// Symbol::CellSet implementation +// **************************************************************************************************** + +Symbol::CellSet::CellSet() +// *********************** +: Inherit() +{ +} + +unsigned Symbol::CellSet::_GetHashValue(Cell* cell) const +// ****************************************************** +{ + return ( (unsigned int)( (unsigned long)cell ) ) / 8; +} + +Cell* Symbol::CellSet::_GetNextElement(Cell* cell) const +// ***************************************************** +{ + return cell->_GetNextOfSymbolCellSet(); +} + +void Symbol::CellSet::_SetNextElement(Cell* cell, Cell* nextCell) const +// ******************************************************************** +{ + cell->_SetNextOfSymbolCellSet(nextCell); +} + + + +} // End of Hurricane namespace. + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/Symbol.h b/hurricane/src/hurricane/grenier/Symbol.h new file mode 100644 index 00000000..139282d1 --- /dev/null +++ b/hurricane/src/hurricane/grenier/Symbol.h @@ -0,0 +1,120 @@ +// **************************************************************************************************** +// File: Symbol.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_SYMBOL +#define HURRICANE_SYMBOL + +#include "DBo.h" +#include "Symbols.h" +#include "Cell.h" +#include "Transformation.h" +#include "IntrusiveSet.h" +#include "IntrusiveMap.h" + +namespace Hurricane { + +class Library; +class Port; +class View; + + + +// **************************************************************************************************** +// Symbol declaration +// **************************************************************************************************** + +class Symbol : public DBo { +// ********************** + +// Types +// ***** + + public: typedef DBo Inherit; + + public: class CellSet : public IntrusiveSet { + // ********************************************** + + public: typedef IntrusiveSet Inherit; + + public: CellSet(); + + public: virtual unsigned _GetHashValue(Cell* cell) const; + public: virtual Cell* _GetNextElement(Cell* cell) const; + public: virtual void _SetNextElement(Cell* cell, Cell* nextCell) const; + + }; + + public: typedef list PrimitiveList; + +// Attributes +// ********** + + private: Library* _library; + private: Name _name; + private: CellSet _cellSet; + private: PrimitiveList _primitiveList; + private: Box _boundingBox; + private: Symbol* _nextOfLibrarySymbolMap; + +// Constructors +// ************ + + protected: Symbol(Library* library, const Name& name); + + public: static Symbol* Create(Library* library, const Name& name); + public: static Symbol* CreateFor(Cell* cell); + +// Accessors +// ********* + + public: Library* GetLibrary() const {return _library;}; + public: const Name& GetName() const {return _name;}; + public: Cells GetCells() const {return _cellSet.GetElements();}; + public: Primitives GetPrimitives() const {return GetCollection(_primitiveList);}; + public: Box GetBoundingBox() const; + public: Port* GetPort(const Name& name) const; + +// Updators +// ******** + + public: void SetName(const Name& name); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetTypeName() const {return _TName("Symbol");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: CellSet& _GetCellSet() {return _cellSet;}; + public: PrimitiveList& _GetPrimitiveList() {return _primitiveList;}; + public: Symbol* _GetNextOfLibrarySymbolMap() const {return _nextOfLibrarySymbolMap;}; + + public: void _SetNextOfLibrarySymbolMap(Symbol* symbol) {_nextOfLibrarySymbolMap = symbol;}; + + public: void _Fit(const Box& box); + public: void _Unfit(const Box& box); + + public: bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; + public: void _Draw(View* view, const Box& updateArea, const Transformation& transformation); + public: void _Highlight(View* view, const Box& updateArea, const Transformation& transformation); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::Symbol) + +#endif // HURRICANE_SYMBOL + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/View.cpp b/hurricane/src/hurricane/grenier/View.cpp new file mode 100644 index 00000000..1bfd319f --- /dev/null +++ b/hurricane/src/hurricane/grenier/View.cpp @@ -0,0 +1,1811 @@ +// **************************************************************************************************** +// File: View.cpp +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** +// 21-10-2003 Alignment BULL-LIP6 (Lip6 addded DisplaySlots) (added VisualMaps) + +#include "View.h" +#include "DataBase.h" +#include "Cell.h" +#include "Technology.h" +#include "CompositeLayer.h" +#include "Selector.h" +#include "VisualMap.h" +#include "DisplaySlot.h" +#include "Go.h" +#include "Command.h" +#include "Error.h" +#include "Interruption.h" + +namespace Hurricane { + + + +// **************************************************************************************************** +// Variables +// **************************************************************************************************** + +static View* DRAG_VIEW = NULL; +static unsigned DRAG_BUTTON = 0; +static bool IN_AUTO_SCROLL = false; + +static unsigned SIZE = 0; +static GdkPoint* POINTS = NULL; + +GdkColor View::_backgroundColor = { 0, 50*255, 50*255, 50*255 }; +GdkColor View::_foregroundColor = { 0, 255*255, 255*255, 255*255 }; +GdkColor View::_rubberColor = { 0, 192*255, 0*255, 192*255 }; +GdkColor View::_phantomColor = { 0, 139*255, 134*255, 130*255 }; +GdkColor View::_boundaryColor = { 0, 208*255, 199*255, 192*255 }; +GdkColor View::_markerColor = { 0, 80*255, 250*255, 80*255 }; +GdkColor View::_selectionDrawColor = { 0, 255*255, 255*255, 255*255 }; +GdkColor View::_selectionFillColor = { 0, 255*255, 255*255, 255*255 }; +GdkColor View::_gridColor = { 0, 255*255, 255*255, 255*255 }; +GdkColor View::_spotColor = { 0, 255*255, 255*255, 255*255 }; +GdkColor View::_ghostColor = { 0, 255*255, 255*255, 255*255 }; + + +// **************************************************************************************************** +// Utilitarians +// **************************************************************************************************** + +static GdkPixmap* GetPixmap(const ScreenUnit& width, const ScreenUnit& height) +// *************************************************************************** +{ + static int WIDTH = 0; + static int HEIGHT = 0; + static GdkPixmap* PIXMAP = NULL; + if (!PIXMAP || (WIDTH < width) || (HEIGHT < height)) { + if (PIXMAP) gdk_pixmap_unref(PIXMAP); + WIDTH = width; + HEIGHT = height; + GdkWindow* window = gtk_get_window(); + PIXMAP = gdk_pixmap_new(window, WIDTH, HEIGHT, gdk_window_get_visual(window)->depth); + } + return PIXMAP; +} + + + +// **************************************************************************************************** +// Callbacks +// **************************************************************************************************** + +static void OnExpose(GtkWidget* drawingArea, GdkEventExpose* event, View* view) +// **************************************************************************** +{ + GdkRectangle area = event->area; + view->_OnExpose(area.x, area.y, area.width, area.height, (event->count == 0)); +} + +static void OnConfigure(GtkWidget* drawingArea, GdkEventConfigure* event, View* view) +// ********************************************************************************** +{ + view->_OnResize(event->width, event->height); +} + +static void OnEnterNotify(GtkWidget* drawingArea, GdkEventCrossing* event, View* view) +// *********************************************************************************** +{ + if (!DRAG_VIEW || (DRAG_VIEW == view)) { + ScreenUnit screenX = (ScreenUnit)event->x; + ScreenUnit screenY = (ScreenUnit)event->y; + Point position(GetOnGridUnit(view->GetX(screenX)), GetOnGridUnit(view->GetY(screenY))); + view->_OnMouseEnter(position); + } +} + +static void OnMotionNotify(GtkWidget* drawingArea, GdkEventMotion* event, View* view) +// ********************************************************************************** +{ + if (!DRAG_VIEW || (DRAG_VIEW == view)) { + ScreenUnit screenX = (ScreenUnit)event->x; + ScreenUnit screenY = (ScreenUnit)event->y; + + if ((DRAG_VIEW == view) && view->AutoScrollIsEnabled()) { + ScreenUnit screenDx = 0; + if (screenX < 0) + screenDx = screenX; + else + if (view->GetScreenWidth() < screenX) + screenDx = screenX - view->GetScreenWidth(); + ScreenUnit screenDy = 0; + if (screenY < 0) + screenDy = screenY; + else + if (view->GetScreenHeight() < screenY) + screenDy = screenY - view->GetScreenHeight(); + if (screenDx || screenDy) { + IN_AUTO_SCROLL = true; + view->Scroll(- view->GetSize(screenDx), view->GetSize(screenDy)); + view->Update(); + IN_AUTO_SCROLL = false; + } + screenX = (ScreenUnit)event->x; + screenY = (ScreenUnit)event->y; + } + + Point position(GetOnGridUnit(view->GetX(screenX)), GetOnGridUnit(view->GetY(screenY))); + view->_OnMouseMove(position, event->state); + } + + // to enable next pointer motion notify event + gint x, y; + GdkModifierType mt; + gdk_window_get_pointer(drawingArea->window, &x, &y, &mt); + // see GDK_POINTER_MOTION_HINT_MASK to understand previous lines +} + +static void OnLeaveNotify(GtkWidget* drawingArea, GdkEventCrossing* event, View* view) +// *********************************************************************************** +{ + if (!DRAG_VIEW || (DRAG_VIEW == view)) { + ScreenUnit screenX = (ScreenUnit)event->x; + ScreenUnit screenY = (ScreenUnit)event->y; + Point position(GetOnGridUnit(view->GetX(screenX)), GetOnGridUnit(view->GetY(screenY))); + view->_OnMouseLeave(position); + } +} + +static void OnButtonPress(GtkWidget* drawingArea, GdkEventButton* event, View* view) +// ********************************************************************************* +{ + unsigned button = event->button; + ScreenUnit screenX = (ScreenUnit)event->x; + ScreenUnit screenY = (ScreenUnit)event->y; + Point position(GetOnGridUnit(view->GetX(screenX)), GetOnGridUnit(view->GetY(screenY))); + if ( ( button == 4 ) || ( button == 5 ) ) + { + view->_OnButtonPress(button, position, event->state); + } + else if (!DRAG_VIEW) { + DRAG_BUTTON = button; + view->_OnButtonPress(button, position, event->state); + DRAG_VIEW = view; + } +} + +static void OnButtonRelease(GtkWidget* drawingArea, GdkEventButton* event, View* view) +// *********************************************************************************** +{ + unsigned button = event->button; + ScreenUnit screenX = (ScreenUnit)event->x; + ScreenUnit screenY = (ScreenUnit)event->y; + Point position(GetOnGridUnit(view->GetX(screenX)), GetOnGridUnit(view->GetY(screenY))); + if ( ( button == 4 ) || ( button == 5 ) ) + { + view->_OnButtonRelease(button, position, event->state); + } + else if (DRAG_VIEW && ( button == DRAG_BUTTON ) ) { + view->_OnButtonRelease(button, position, event->state); + DRAG_VIEW = NULL; + } +} + + + +// **************************************************************************************************** +// View implementation +// **************************************************************************************************** + +View::View() +// ********* +: Inherit(), + _frame(NULL), + _drawingArea(NULL), + _center(0, 0), + _scale(1), + _backCenter(0, 0), + _backScale(1), + _screenDx(0), + _screenDy(0), + _screenWidth(1), + _screenHeight(1), + _hasBeenExposed(false), + _screenUpdateArea(), + _clipBox(), + _drawable(NULL), + _backgroundGC(NULL), + _foregroundGC(NULL), + _phantomGC(NULL), + _boundaryGC(NULL), + _rubberGC(NULL), + _markerGC(NULL), + _selectionDrawGC(NULL), + _selectionFillGC(NULL), + _gridGC(NULL), + _spotGC(NULL), + _ghostGC(NULL), + _drawGC(NULL), + _fillGC(NULL), + _commandMap(), + _gridIsVisible(true), + _gridDisplayThreshold(6), + _autoScrollIsEnabled(true), + _doubleBufferingIsEnabled(false), + _phantomsAreVisible(true), + _boundariesAreVisible(true), + _rubbersAreVisible(false), + _markersAreVisible(true), + _cutPointsAreVisible(false), + _selectionIsVisible(true), + _displaySlotsAreVisible(true), + _visualMapsAreVisible(false), + _spotIsVisible(false), + _spotIsDrawable(false), + _spotPosition(), + _visibleBasicLayersMask(~0), + _selectorSet(), + _rubberDisplayType(), + _isTextVisible(false), + _nextOfCellViewSet(NULL) +{ +} + +Unit View::GetX(const ScreenUnit& screenX) const +// ********************************************* +{ + return GetUnit((screenX - _screenDx) / _scale); +} + +Unit View::GetY(const ScreenUnit& screenY) const +// ********************************************* +{ + return GetUnit(((_screenHeight - screenY) - _screenDy) / _scale); +} + +Unit View::GetSize(const ScreenUnit& screenSize) const +// *************************************************** +{ + return GetUnit(screenSize / _scale); +} + +Point View::GetPoint(const ScreenPoint& screenPoint) const +// ******************************************************* +{ + return Point(GetX(screenPoint.GetX()), GetY(screenPoint.GetY())); +} + +Box View::GetBox(const ScreenBox& screenBox) const +// *********************************************** +{ + return Box(GetX(screenBox.GetXMin()), + GetY(screenBox.GetYMin()), + GetX(screenBox.GetXMax()), + GetY(screenBox.GetYMax())); +} + +ScreenUnit View::GetScreenX(const Unit& x) const +// ********************************************* +{ + return _screenDx + (ScreenUnit)(GetValue(x) * _scale); +} + +ScreenUnit View::GetScreenY(const Unit& y) const +// ********************************************* +{ + return _screenHeight - (_screenDy + (ScreenUnit)(GetValue(y) * _scale)); +} + +ScreenUnit View::GetScreenSize(const Unit& size) const +// *************************************************** +{ + return (ScreenUnit)(GetValue(size) * _scale); +} + +ScreenPoint View::GetScreenPoint(const Point& point) const +// ******************************************************* +{ + return Point(GetScreenX(point.GetX()), GetScreenY(point.GetY())); +} + +ScreenBox View::GetScreenBox(const Box& box) const +// *********************************************** +{ + return Box(GetScreenX(box.GetXMin()), + GetScreenY(box.GetYMin()), + GetScreenX(box.GetXMax()), + GetScreenY(box.GetYMax())); +} + +Box View::GetClientArea() const +// **************************** +{ + Box area(-1, -1, 1, 1); + Cell* cell = GetCell(); + if (cell) { + Box boundingBox = cell->GetBoundingBox(); + if (!boundingBox.IsEmpty()) area = boundingBox; + } + GetTransformation().ApplyOn(area); + return area; +} + +Box View::GetVisibleArea() const +// ***************************** +{ + return Box(GetX(0), GetY(0), GetX(_screenWidth), GetY(_screenHeight)); +} + +Command* View::GetCommand(unsigned button) const +// ********************************************* +{ + CommandMap::const_iterator it = _commandMap.find(button); + return (it != _commandMap.end()) ? (*it).second : NULL; +} + +BasicLayers View::GetVisibleBasicLayers() const +// ******************************************** +{ + Technology* technology = GetDataBase()->GetTechnology(); + return (technology) ? technology->GetBasicLayers(_visibleBasicLayersMask) : BasicLayers(); +} + +bool View::IsVisible(BasicLayer* basicLayer) const +// *********************************************** +{ + if (!basicLayer) + throw Error("Can't evaluate if is visible : null basic layer"); + + return (basicLayer->GetMask() & _visibleBasicLayersMask); +} + +bool View::IsSelected(Go* go) const +// ******************************** +{ + if (!go) + throw Error("Can't evaluate if is selected : null go"); + + Occurrence occurrence = go; + return IsSelected(occurrence); +} + +bool View::IsSelected(const Occurrence& occurrence) const +// **************************************************** +{ + for_each_selector(selector, GetSelectors()) { + if (selector->GetOccurrence() == occurrence) return true; + end_for; + } + return false; +} + +void View::SetCell(Cell* newCell) +// ****************************** +{ + Cell* oldCell = GetCell(); + if (newCell != oldCell) { + + UnselectAll(); + + for_each_command(command, GetCommands()) command->UninstallFrom(this); end_for; + + _SetCell(newCell); + _SetTransformation(Transformation()); + + if (_hasBeenExposed) FitToContent(); + + _backCenter = _center; + _backScale = _scale; + } +} + +void View::SetTransformation(const Transformation& newTransformation) +// ****************************************************************** +{ + Transformation oldTransformation = GetTransformation(); + if (newTransformation != oldTransformation) { + _SetTransformation(newTransformation); + if (GetCell()) FitToContent(); + _backCenter = _center; + _backScale = _scale; + } +} + +void View::ShowGrid() +// ****************** +{ + if (!_gridIsVisible) { + _gridIsVisible = true; + if (GridIsDrawable()) Invalidate(); + } +} + +void View::HideGrid() +// ****************** +{ + if (_gridIsVisible) { + _gridIsVisible = false; + if (GridIsDrawable()) Invalidate(); + } +} + +void View::SetGridDisplayThreshold(const ScreenUnit& threshold) +// ************************************************************ +{ + if (threshold < 3) + throw Error("Can't set grid display threshold : too small value"); + + if (threshold != _gridDisplayThreshold) { + _gridDisplayThreshold = threshold; + Invalidate(); + } +} + +void View::SetVisibleBasicLayersMask(const Layer::Mask& visibleBasicLayersMask) +// **************************************************************************** +{ + if (_visibleBasicLayersMask != visibleBasicLayersMask) { + _visibleBasicLayersMask = visibleBasicLayersMask; + Invalidate(); + } +} + +void View::ShowPhantoms() +// ********************** +{ + if (!_phantomsAreVisible) { + _phantomsAreVisible = true; + Invalidate(); + } +} + +void View::HidePhantoms() +// ********************** +{ + if (_phantomsAreVisible) { + _phantomsAreVisible = false; + Invalidate(); + } +} + +void View::ShowBoundaries() +// ************************ +{ + if (!_boundariesAreVisible) { + _boundariesAreVisible = true; + Invalidate(); + } +} + +void View::HideBoundaries() +// ************************ +{ + if (_boundariesAreVisible) { + _boundariesAreVisible = false; + Invalidate(); + } +} + +void View::ShowCutPoints() +// *********************** +{ + if (!_cutPointsAreVisible) { + _cutPointsAreVisible = true; + Invalidate(); + } +} + +void View::HideCutPoints() +// *********************** +{ + if (_cutPointsAreVisible) { + _cutPointsAreVisible = false; + Invalidate(); + } +} + +void View::ShowRubbers() +// ********************* +{ + if (!_rubbersAreVisible) { + _rubbersAreVisible = true; + Invalidate(); + } +} + +void View::HideRubbers() +// ********************* +{ + if (_rubbersAreVisible) { + _rubbersAreVisible = false; + Invalidate(); + } +} + +void View::ShowMarkers() +// ********************* +{ + if (!_markersAreVisible) { + _markersAreVisible = true; + Invalidate(); + } +} + +void View::HideMarkers() +// ********************* +{ + if (_markersAreVisible) { + _markersAreVisible = false; + Invalidate(); + } +} + +void View::ShowSelection() +// *********************** +{ + if (!_selectionIsVisible) { + _selectionIsVisible = true; + if (HasSomethingSelected()) Invalidate(); + } +} + +void View::HideSelection() +// *********************** +{ + if (_selectionIsVisible) { + _selectionIsVisible = false; + if (HasSomethingSelected()) Invalidate(); + } +} + +void View::ShowDisplaySlots() +// ************************** +{ + if (!_displaySlotsAreVisible) { + _displaySlotsAreVisible = true; + Invalidate(); + } +} + +void View::HideDisplaySlots() +// ************************** +{ + if (_displaySlotsAreVisible) { + _displaySlotsAreVisible = false; + Invalidate(); + } +} + +void View::ShowVisualMaps() +// ************************** +{ + if (!_visualMapsAreVisible) { + _visualMapsAreVisible = true; + Invalidate(); + } +} + +void View::HideVisualMaps() +// ************************** +{ + if (_visualMapsAreVisible) { + _visualMapsAreVisible = false; + Invalidate(); + } +} + +void View::Show(BasicLayer* basicLayer) +// ************************************ +{ + if (!basicLayer) + throw Error("Can't show basic layer : null basic layer"); + + if (!IsVisible(basicLayer)) { + _visibleBasicLayersMask |= basicLayer->GetMask(); + Invalidate(); + } +} + +void View::Hide(BasicLayer* basicLayer) +// ************************************ +{ + if (!basicLayer) + throw Error("Can't hide basic layer : null basic layer"); + + if (IsVisible(basicLayer)) { + _visibleBasicLayersMask &= ~basicLayer->GetMask(); + Invalidate(); + } +} + +void View::ShowAllLayers() +// *********************** +{ + SetVisibleBasicLayersMask(~0); +} + +void View::HideAllLayers() +// *********************** +{ + SetVisibleBasicLayersMask(0); +} + +void View::Select(Go* go) +// ********************** +{ + if (!go) + throw Error("Can't select go : null go"); + + Occurrence occurrence = go; + Select(occurrence); +} + +void View::Unselect(Go* go) +// ************************ +{ + if (!go) + throw Error("Can't unselect go : null go"); + + Occurrence occurrence = go; + Unselect(occurrence); +} + +void View::Select(Occurrence& occurrence) +// ************************************ +{ + if (!occurrence.IsValid()) + throw Error("Can't select occurrence : invalid occurrence"); + + if (occurrence.GetOwnerCell() != GetCell()) + throw Error("Can't select occurrence : incompatible occurrence"); + + Selector* selector = (Selector*)occurrence.GetProperty(Selector::GetPropertyName()); + if (!selector) + selector = Selector::_Create(occurrence); + else + if (!is_a(selector)) + throw Error("Abnormal property named " + GetString(Selector::GetPropertyName())); + + selector->_AttachTo(this); + Invalidate(GetTransformation().GetBox(occurrence.GetBoundingBox())); +} + +void View::Unselect(Occurrence& occurrence) +// ************************************** +{ + if (!occurrence.IsValid()) + throw Error("Can't unselect occurrence : invalid occurrence"); + + if (occurrence.GetOwnerCell() != GetCell()) + throw Error("Can't unselect occurrence : incompatible occurrence"); + + Selector* selector = (Selector*)occurrence.GetProperty(Selector::GetPropertyName()); + if (selector) { + if (!is_a(selector)) + throw Error("Abnormal property named " + GetString(Selector::GetPropertyName())); + + selector->_DetachFrom(this); + Invalidate(GetTransformation().GetBox(occurrence.GetBoundingBox())); + } +} + +void View::UnselectAll() +// ********************* +{ + Box boundingBox; + + for_each_selector(selector, GetSelectors()) { + boundingBox.Merge(selector->GetOccurrence().GetBoundingBox()); + selector->_DetachFrom(this); + end_for; + } + + if (!boundingBox.IsEmpty()) + Invalidate(GetTransformation().GetBox(boundingBox)); +} + +void View::Invalidate(const ScreenUnit& screenXo, const ScreenUnit& screenYo, const ScreenUnit& screenXe, const ScreenUnit& screenYe) +// **************************************************************************************************** +{ + if (_drawingArea && _drawingArea->window) { + ScreenBox screenBox = Box(0, 0, _screenWidth, _screenHeight).Inflate(1); + ScreenBox updateBox = Box(screenXo, screenYo, screenXe, screenYe).Inflate(1); + _screenUpdateArea.Merge(screenBox.GetIntersection(updateBox)); + } +} + +void View::Invalidate() +// ******************** +{ + if (_drawingArea && _drawingArea->window) + _screenUpdateArea = ScreenBox(0, 0, _screenWidth, _screenHeight); +} + +void View::Invalidate(const Box& area) +// *********************************** +{ + if (!area.IsEmpty()) + Invalidate(GetScreenX(area.GetXMin()), + GetScreenY(area.GetYMin()), + GetScreenX(area.GetXMax()), + GetScreenY(area.GetYMax())); +} + +bool View::Update(bool useDoubleBuffering) +// *************************************** +{ + if (_screenUpdateArea.IsEmpty()) return false; + + if (!_drawingArea) return false; + + GdkWindow* window = _drawingArea->window; + + if (!window) return false; + + _HideSpot(); + + for_each_command(command, GetCommands()) { + if (!DRAG_VIEW || (DRAG_VIEW == this)) + DrawGhost(command); + end_for; + } + + _drawable = window; + _drawGC = _foregroundGC; + _fillGC = _foregroundGC; + + _clipBox = Box(GetX(-2), GetY(_screenHeight + 2), GetX(_screenWidth + 2), GetY(-2)); + + if (IN_AUTO_SCROLL || useDoubleBuffering || _doubleBufferingIsEnabled) + _drawable = GetPixmap(_screenWidth, _screenHeight); + + _screenUpdateArea.Inflate(5); + + static GdkCursor* sprayCanCursor = gdk_cursor_new(GDK_SPRAYCAN); + gdk_window_set_cursor(window, sprayCanCursor); + + _Repaint(GetBox(_screenUpdateArea)); + + static GdkCursor* leftPtrCursor = gdk_cursor_new(GDK_LEFT_PTR); + gdk_window_set_cursor(window, leftPtrCursor); + + if (_drawable != window) { + if (IN_AUTO_SCROLL) _screenUpdateArea = Box(0, 0, _screenWidth, _screenHeight); + gdk_window_copy_area + (window, + _foregroundGC, + _screenUpdateArea.GetXMin(), _screenUpdateArea.GetYMin(), + _drawable, + _screenUpdateArea.GetXMin(), _screenUpdateArea.GetYMin(), + _screenUpdateArea.GetWidth(), _screenUpdateArea.GetHeight()); + } + + _fillGC = _foregroundGC; + _drawGC = _foregroundGC; + _drawable = window; + + _screenUpdateArea = ScreenBox(); + + for_each_command(command, GetCommands()) { + if (!DRAG_VIEW || (DRAG_VIEW == this)) + DrawGhost(command); + end_for; + } + + _ShowSpot(); + + return true; +} + +void View::Refresh(bool useDoubleBuffering) +// **************************************** +{ + Invalidate(); + Update(useDoubleBuffering); +} + +void View::CheckForDisplayInterruption() +// ************************************* +{ + if (_DisplayHasBeenAborted()) throw Interruption("Display"); +} + +void View::VerticalScroll(const Unit& dy) +// ************************************** +{ + Reframe(Point(_center).Translate(0, -dy)); +} + +void View::HorizontalScroll(const Unit& dx) +// **************************************** +{ + Reframe(Point(_center).Translate(-dx, 0)); +} + +void View::Scroll(const Unit& dx, const Unit& dy) +// ********************************************** +{ + Reframe(Point(_center).Translate(-dx, -dy)); +} + +void View::Reframe(const Point& center) +// ************************************ +{ + Reframe(center, _scale); +} + +void View::Reframe(const Point& center, double scale) +// ************************************************** +{ + if ((0 < scale) && ((center != _center) || (scale != _scale))) { + _backCenter = _center; + _backScale = _scale; + _center = center; + _scale = scale; + _screenDx = -(int)((GetValue(_center.GetX()) - (_screenWidth / (_scale * 2))) * _scale); + _screenDy = -(int)((GetValue(_center.GetY()) - (_screenHeight / (_scale * 2))) * _scale); + Invalidate(); + } +} + +void View::Reframe(const Box& area) +// ******************************** +{ + if (!area.IsEmpty() && !area.IsFlat()) + Reframe( + area.GetCenter(), + min(_screenWidth / GetValue(area.GetWidth()), _screenHeight / GetValue(area.GetHeight()))); +} + +void View::ReframeBack() +// ********************* +{ + // _backCenter is mofified inside the Reframe function + // so we should give a copy to have a good behaviour + Reframe(Point(_backCenter), _backScale); +} + +void View::FitToContent() +// ********************** +{ + Box area = GetClientArea(); + + Point center = _center; + double scale = _scale; + + Reframe(area); + area.Inflate(GetSize(10)); + Reframe(area); + + _backCenter = center; + _backScale = scale; + + _hasBeenExposed = true; +} + +void View::DrawGhost(Command* command) +// *********************************** +{ + if (command) { + GdkGC* oldDrawGC = _drawGC; + GdkGC* oldFillGC = _fillGC; + _drawGC = _ghostGC; + _fillGC = _ghostGC; + command->_OnDrawGhost(this); + _drawGC = oldDrawGC; + _fillGC = oldFillGC; + } +} + +void View::DrawPoint(const Unit& x, const Unit& y, const ScreenUnit& screenSize) +// ***************************************************************************** +{ + if (!_drawable) return; + + if (x < _clipBox.GetXMin()) return; + else if (_clipBox.GetXMax() < x) return; + if (y < _clipBox.GetYMin()) return; + else if (_clipBox.GetYMax() < y) return; + + ScreenUnit screenX = GetScreenX(x); + ScreenUnit screenY = GetScreenY(y); + + static gint ANGLE = 360 * 64; + gdk_draw_arc(_drawable, + _drawGC, + true, + screenX - screenSize, + screenY - screenSize, + (screenSize * 2), + (screenSize * 2), + 0, + ANGLE); +} + +void View::DrawPoint(const Point& position, const ScreenUnit& screenSize) +// ********************************************************************** +{ + DrawPoint(position.GetX(), position.GetY(), screenSize); +} + +void View::DrawLine(const Unit& xo, const Unit& yo, const Unit& xe, const Unit& ye) +// ******************************************************************************** +{ + if (!_drawable) return; + + Unit cXo = xo; + Unit cYo = yo; + Unit cXe = xe; + Unit cYe = ye; + + if (_ClipLine(cXo, cYo, cXe, cYe)) { + gdk_draw_line(_drawable, + _drawGC, + GetScreenX(cXo), + GetScreenY(cYo), + GetScreenX(cXe), + GetScreenY(cYe)); + } +} + +void View::DrawLine(const Point& origin, const Point& extremity) +// ************************************************************* +{ + DrawLine(origin.GetX(), origin.GetY(), extremity.GetX(), extremity.GetY()); +} + +void View::DrawLines(const vector& points, unsigned size) +// ************************************************************* +{ + // PROVISOIREMENT : doit faire le clipping + + if (!_drawable || !size) return; + + if (SIZE < size) { + if (POINTS) delete[] POINTS; + SIZE = size; + POINTS = new GdkPoint[SIZE]; + } + + for (unsigned i = 0; i < size; i++) { + POINTS[i].x = GetScreenX(points[i].GetX()); + POINTS[i].y = GetScreenY(points[i].GetY()); + } + + gdk_draw_lines(_drawable, _drawGC, POINTS, size); +} + +void View::DrawPolygon(const vector& points, unsigned size) +// *************************************************************** +{ + // PROVISOIREMENT : doit faire le clipping + + if (!_drawable || !size) return; + + if (SIZE < size) { + if (POINTS) delete[] POINTS; + SIZE = size; + POINTS = new GdkPoint[SIZE]; + } + + for (unsigned i = 0; i < size; i++) { + POINTS[i].x = GetScreenX(points[i].GetX()); + POINTS[i].y = GetScreenY(points[i].GetY()); + } + + gdk_draw_polygon(_drawable, _drawGC, false, POINTS, size); +} + +void View::DrawRectangle(const Unit& xo, const Unit& yo, const Unit& xe, const Unit& ye) +// ************************************************************************************* +{ + DrawRectangle(Box(xo, yo, xe, ye)); +} + +void View::DrawRectangle(const Point& origin, const Point& extremity) +// ****************************************************************** +{ + DrawRectangle(Box(origin, extremity)); +} + +void View::DrawRectangle(const Box& box) +// ************************************* +{ + if (!_drawable) return; + + Box cBox = box; + + if (_ClipBox(cBox)) { + Box screenBox = GetScreenBox(cBox); + gdk_draw_rectangle(_drawable, + _drawGC, + false, + screenBox.GetXMin(), + screenBox.GetYMin(), + screenBox.GetWidth(), + screenBox.GetHeight()); + } +} + +void View::DrawCircle(const Unit& x, const Unit& y, const Unit& radius) +// ******************************************************************** +{ + if (!_drawable) return; + + ScreenUnit screenX = GetScreenX(x); + ScreenUnit screenY = GetScreenY(y); + ScreenUnit screenRadius = GetScreenSize(radius); + + static gint ANGLE = 360 * 64; + gdk_draw_arc(_drawable, + _drawGC, + false, + screenX - screenRadius, + screenY - screenRadius, + (screenRadius * 2), + (screenRadius * 2), + 0, + ANGLE); +} + +void View::DrawCircle(const Point& center, const Unit& radius) +// *********************************************************** +{ + DrawCircle(center.GetX(), center.GetY(), radius); +} + +void View::DrawString(const string& text, const Unit& x, const Unit& y) +// ******************************************************************** +{ + if (!_drawable) return; + + Unit X = x; + Unit Y = y; + + GdkFont * police = gdk_font_load ( "-*-lucidatypewriter-bold-*-*-*-*-120-*-*-*-*-iso8859-1" ); + + gint textWidth = gdk_string_width ( police, text.c_str() ); + gint textHeight = gdk_string_height ( police, text.c_str() ); + + gdk_draw_string ( _drawable, + police, + _drawGC, + GetScreenX( X ) + 2, + GetScreenY( Y ) + 2, + text.c_str() + ); + gdk_draw_rectangle ( _drawable, + _drawGC, + false, + GetScreenX( X ), + GetScreenY( Y ) - textHeight, + textWidth + 4, + textHeight + 4 + ); +} + +void View::FillPolygon(const vector& points, unsigned size, bool solid) +// *************************************************************************** +{ + // PROVISOIREMENT : doit faire le clipping + + if (!_drawable || !size) return; + + if (SIZE < size) { + if (POINTS) delete[] POINTS; + SIZE = size; + POINTS = new GdkPoint[SIZE]; + } + + for (unsigned i = 0; i < size; i++) { + POINTS[i].x = GetScreenX(points[i].GetX()); + POINTS[i].y = GetScreenY(points[i].GetY()); + } + + gdk_draw_polygon(_drawable, ((solid) ? _drawGC : _fillGC), true, POINTS, size); +} + +void View::FillRectangle(const Unit& xo, const Unit& yo, const Unit& xe, const Unit& ye, bool solid) +// ************************************************************************************************* +{ + FillRectangle(Box(xo, yo, xe, ye), solid); +} + +void View::FillRectangle(const Point& origin, const Point& extremity, bool solid) +// ***************************************************************************** +{ + FillRectangle(Box(origin, extremity), solid); +} + +void View::FillRectangle(const Box& box, bool solid) +// ************************************************* +{ + if (!_drawable) return; + + Box cBox = box; + + if (_ClipBox(cBox)) { + Box screenBox = GetScreenBox(cBox); + gdk_draw_rectangle(_drawable, + (solid) ? _drawGC : _fillGC, + true, + screenBox.GetXMin(), + screenBox.GetYMin(), + screenBox.GetWidth() + 1, + screenBox.GetHeight() + 1); + } +} + +void View::FillCircle(const Unit& x, const Unit& y, const Unit& radius, bool solid) +// ******************************************************************************** +{ + if (!_drawable) return; + + ScreenUnit screenX = GetScreenX(x); + ScreenUnit screenY = GetScreenY(y); + ScreenUnit screenRadius = GetScreenSize(radius); + + static gint ANGLE = 360 * 64; + gdk_draw_arc(_drawable, + (solid) ? _drawGC : _fillGC, + true, + screenX - screenRadius, + screenY - screenRadius, + (screenRadius * 2), + (screenRadius * 2), + 0, + ANGLE); +} + +void View::FillCircle(const Point& center, const Unit& radius, bool solid) +// *********************************************************************** +{ + FillCircle(center.GetX(), center.GetY(), radius, solid); +} + +void View::_PostCreate() +// ********************* +{ + _frame = gtk_table_new(1, 1, false); + gtk_container_set_border_width(GTK_CONTAINER(_frame), 2); + + gtk_signal_connect(GTK_OBJECT(_frame), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &_frame); + + _drawingArea = gtk_drawing_area_new(); + gtk_table_attach + (GTK_TABLE(_frame), _drawingArea, 0, 1, 0, 1, GTK_FILL_EXPAND, GTK_FILL_EXPAND, 0, 0); + + gtk_signal_connect + (GTK_OBJECT(_drawingArea), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &_drawingArea); + + gtk_signal_connect + (GTK_OBJECT(_drawingArea), "expose_event", GTK_SIGNAL_FUNC(OnExpose), this); + + gtk_signal_connect + (GTK_OBJECT(_drawingArea), "configure_event", GTK_SIGNAL_FUNC(OnConfigure), this); + + gtk_signal_connect + (GTK_OBJECT(_drawingArea), "enter_notify_event", GTK_SIGNAL_FUNC(OnEnterNotify), this); + gtk_widget_add_events(GTK_WIDGET(_drawingArea), GDK_ENTER_NOTIFY_MASK); + + gtk_signal_connect + (GTK_OBJECT(_drawingArea), "motion_notify_event", GTK_SIGNAL_FUNC(OnMotionNotify), this); + gtk_widget_add_events + (GTK_WIDGET(_drawingArea), GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); + + gtk_signal_connect + (GTK_OBJECT(_drawingArea), "leave_notify_event", GTK_SIGNAL_FUNC(OnLeaveNotify), this); + gtk_widget_add_events(GTK_WIDGET(_drawingArea), GDK_LEAVE_NOTIFY_MASK); + + gtk_signal_connect + (GTK_OBJECT(_drawingArea), "button_press_event", GTK_SIGNAL_FUNC(OnButtonPress), this); + gtk_widget_add_events(GTK_WIDGET(_drawingArea), GDK_BUTTON_PRESS_MASK); + + gtk_signal_connect + (GTK_OBJECT(_drawingArea), "button_release_event", GTK_SIGNAL_FUNC(OnButtonRelease), this); + gtk_widget_add_events(GTK_WIDGET(_drawingArea), GDK_BUTTON_RELEASE_MASK); + + _backgroundGC = gtk_gc_new(&_backgroundColor); + _foregroundGC = gtk_gc_new(&_foregroundColor); + _phantomGC = gtk_gc_new(&_phantomColor); + _boundaryGC = gtk_gc_new(&_boundaryColor); + _rubberGC = gtk_gc_new(&_rubberColor); + _markerGC = gtk_gc_new(&_markerColor); + gdk_gc_set_line_attributes (_markerGC, 1, GDK_LINE_SOLID, GDK_CAP_PROJECTING, GDK_JOIN_MITER); + _selectionDrawGC = gtk_gc_new(&_selectionDrawColor); + _selectionFillGC = gtk_gc_new(&_selectionFillColor, "AA55AA55AA55AA55"); + _gridGC = gtk_gc_new(&_gridColor); + _spotGC = gtk_gc_new(&_spotColor); + gdk_gc_set_function(_spotGC, GDK_XOR); + _ghostGC = gtk_gc_new(&_ghostColor); + gdk_gc_set_function(_ghostGC, GDK_XOR); + + _drawGC = _foregroundGC; + _fillGC = _foregroundGC; + + Inherit::_PostCreate(); +} + +void View::_PreDelete() +// ******************** +{ + Inherit::_PreDelete(); + + for_each_selector(selector, GetSelectors()) selector->_DetachFrom(this); end_for; + + for_each_command(command, GetCommands()) command->UninstallFrom(this); end_for; + + gdk_gc_destroy(_backgroundGC); + gdk_gc_destroy(_foregroundGC); + gdk_gc_destroy(_phantomGC); + gdk_gc_destroy(_boundaryGC); + gdk_gc_destroy(_rubberGC); + gdk_gc_destroy(_markerGC); + gdk_gc_destroy(_selectionDrawGC); + gdk_gc_destroy(_selectionFillGC); + gdk_gc_destroy(_gridGC); + gdk_gc_destroy(_spotGC); + gdk_gc_destroy(_ghostGC); + + if (_frame) gtk_widget_destroy(_frame); + + Cell* cell = GetCell(); + if (cell) cell->_GetViewSet()._Remove(this); +} + +string View::_GetString() const +// **************************** +{ + string s = Inherit::_GetString(); + Cell* cell = GetCell(); + if (cell) s.insert(s.length() - 1, " " + GetString(cell->GetName())); + return s; +} + +Record* View::_GetRecord() const +// *********************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Cell", GetCell())); + record->Add(GetSlot("Transformation",GetTransformation())); + record->Add(GetSlot("Center", &_center)); + record->Add(GetSlot("Scale", &_scale)); + record->Add(GetSlot("ScreenWidth", &_screenWidth)); + record->Add(GetSlot("ScreenHeight", &_screenHeight)); + record->Add(GetSlot("Commands", &_commandMap)); + record->Add(GetSlot("GridIsVisible", &_gridIsVisible)); + record->Add(GetSlot("GridDisplayThreshold", &_gridDisplayThreshold)); + record->Add(GetSlot("AutoScrollIsEnabled", &_autoScrollIsEnabled)); + record->Add(GetSlot("DoubleBufferingIsEnabled", &_doubleBufferingIsEnabled)); + record->Add(GetSlot("PhantomsAreVisible", &_phantomsAreVisible)); + record->Add(GetSlot("BoundariesAreVisible", &_boundariesAreVisible)); + record->Add(GetSlot("CutPointsAreVisible", &_cutPointsAreVisible)); + record->Add(GetSlot("RubbersAreVisible", &_rubbersAreVisible)); + record->Add(GetSlot("MarkersAreVisible", &_markersAreVisible)); + record->Add(GetSlot("SelectionIsVisible", &_selectionIsVisible)); + record->Add(GetSlot("DisplaySlotsAreVisible", &_displaySlotsAreVisible)); + record->Add(GetSlot("VisualMapsAreVisible", &_visualMapsAreVisible)); + record->Add(GetSlot("VisibleBasicLayersMask", &_visibleBasicLayersMask)); + record->Add(GetSlot("Selection", &_selectorSet)); + record->Add(GetSlot("RubberDisplayType", &_rubberDisplayType)); + } + return record; +} + +bool View::_DisplayHasBeenAborted() +// ******************************** +{ + bool aborted = false; + if (gdk_events_pending()) { + GdkEvent* event = gdk_event_get(); + if (event) { + if (event->any.window == _drawingArea->window) { + if ((event->type == GDK_CONFIGURE) || + (event->type == GDK_BUTTON_PRESS) || + (event->type == GDK_2BUTTON_PRESS) || + (event->type == GDK_3BUTTON_PRESS) || + (event->type == GDK_KEY_PRESS)) + aborted = true; + } + if (!aborted) aborted = _DisplayHasBeenAborted(); + gdk_event_put(event); + gdk_event_free(event); + } + } + return aborted; +} + +void View::_PreRepaint() +// ********************* +{ +} + +void View::_PostRepaint() +// ********************** +{ +} + +void View::_DrawDisplaySlot(DisplaySlot* displaySlot, const Box& area, const Box& updateArea, const Transformation& transformation) +// ******************************************************************************************************************************** +{ + GdkRectangle clipRectangle; + clipRectangle.x = GetScreenX(area.GetXMin()); + clipRectangle.y = GetScreenY(area.GetYMax()); + clipRectangle.width = GetScreenX(area.GetXMax()) - clipRectangle.x; + clipRectangle.height = GetScreenY(area.GetYMin()) - clipRectangle.y; + + if (displaySlot->IsVisible()) { + _drawGC = displaySlot->_GetDrawGC(); + _fillGC = displaySlot->_GetFillGC(); + gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); + gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); + displaySlot->_Draw(this, updateArea, transformation); + gdk_flush(); + } +} + +void View::_Repaint(const Box& area) +// ********************************* +{ + GdkRectangle clipRectangle; + clipRectangle.x = GetScreenX(area.GetXMin()); + clipRectangle.y = GetScreenY(area.GetYMax()); + clipRectangle.width = GetScreenX(area.GetXMax()) - clipRectangle.x; + clipRectangle.height = GetScreenY(area.GetYMin()) - clipRectangle.y; + + Box updateArea = GetTransformation().GetInvert().GetBox(area); + + _drawGC = _backgroundGC; + _fillGC = _backgroundGC; + gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); + gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); + FillRectangle(area, true); + + _PreRepaint(); + + Cell* cell = GetCell(); + if (cell) { + + if (_phantomsAreVisible) { + _drawGC = _phantomGC; + _fillGC = _phantomGC; + gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); + gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); + cell->_DrawPhantoms(this, updateArea, GetTransformation()); + gdk_flush(); + } + + if (_boundariesAreVisible) { + _drawGC = _boundaryGC; + _fillGC = _boundaryGC; + gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); + gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); + cell->_DrawBoundaries(this, updateArea, GetTransformation()); + gdk_flush(); + } + + _drawGC = _foregroundGC; + _fillGC = _foregroundGC; + gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); + gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); + + DataBase* dataBase = GetDataBase(); + Technology* technology = dataBase->GetTechnology(); + for_each_composite_layer(compositeLayer, technology->GetCompositeLayers()) { + compositeLayer->_UpdateSymbolicBasicLayer(_visibleBasicLayersMask); + end_for; + } + + try { + for_each_basic_layer(basicLayer, GetVisibleBasicLayers()) { + CheckForDisplayInterruption(); + if (basicLayer->GetDisplayThreshold() < _scale) { + _drawGC = basicLayer->_GetDrawGC(); + _fillGC = basicLayer->_GetFillGC(); + gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); + gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); + cell->_DrawContent(this, basicLayer, updateArea, GetTransformation()); + gdk_flush(); + _drawGC = _foregroundGC; + _fillGC = _foregroundGC; + } + end_for; + } + } + catch (Interruption& interruption) { + } + + for_each_composite_layer(compositeLayer, technology->GetCompositeLayers()) { + compositeLayer->_UpdateSymbolicBasicLayer(~0); + end_for; + } + + if (_rubbersAreVisible) { + _drawGC = _rubberGC; + _fillGC = _rubberGC; + gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); + gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); + cell->_DrawRubbers(this, updateArea, GetTransformation()); + gdk_flush(); + } + + if (_markersAreVisible) { + _drawGC = _markerGC; + _fillGC = _markerGC; + gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); + gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); + cell->_DrawMarkers(this, updateArea, GetTransformation()); + gdk_flush(); + } + + if (_displaySlotsAreVisible) { + cell->_DrawDisplaySlots(this, area, updateArea, GetTransformation()); + } + + if (_visualMapsAreVisible) { + for_each_visual_map(visualMap, GetVisualMaps(cell)) { + if (visualMap->IsVisible()) { +#if 0 + _drawGC = visualMap->_GetGC(); + _fillGC = visualMap->_GetGC(); + gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); + gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); +#endif + visualMap->_Draw(this, updateArea, GetTransformation()); + gdk_flush(); + } + end_for; + } + } + + bool cutPointsAreVisible = _cutPointsAreVisible; + _cutPointsAreVisible = true; + if (_selectionIsVisible) { + _drawGC = _selectionDrawGC; + _fillGC = _selectionFillGC; + gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); + gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); + for_each_selector(selector, GetSelectors()) { + Occurrence occurrence = selector->GetOccurrence(); + Entity* entity = occurrence.GetEntity(); + Transformation transformation = occurrence.GetPath().GetTransformation(); + GetTransformation().ApplyOn(transformation); + if (is_a(entity)) + ((Go*)entity)->_Highlight(this, updateArea, transformation); + end_for; + } + gdk_flush(); + } + _cutPointsAreVisible = cutPointsAreVisible; + } + + if (GridIsVisible() && GridIsDrawable()) { + Unit xmin = GetOnGridUnit(GetX(0)); + Unit ymin = GetOnGridUnit(GetY(_screenHeight)); + Unit xmax = GetOnGridUnit(GetX(_screenWidth)); + Unit ymax = GetOnGridUnit(GetY(0)); + for (Unit xi = xmin; xi <= xmax; xi += GetGridStep()) { + bool bx = IsOnGrid(xi, 10); + for (Unit yi = ymin; yi <= ymax; yi += GetGridStep()) { + bool by = IsOnGrid(yi, 10); + ScreenUnit screenX = GetScreenX(xi); + ScreenUnit screenY = GetScreenY(yi); + if (!bx || !by) + gdk_draw_point(_drawable, _gridGC, screenX, screenY); + else { + gdk_draw_line(_drawable, _gridGC, screenX - 2, screenY, screenX + 2, screenY); + gdk_draw_line(_drawable, _gridGC, screenX, screenY - 2, screenX, screenY + 2); + } + } + } + } + + _PostRepaint(); + + clipRectangle.x = 0; + clipRectangle.y = 0; + clipRectangle.width = _screenWidth; + clipRectangle.height = _screenHeight; + gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); + gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); +} + +void View::_DrawSpot() +// ******************* +{ + if (!_drawingArea || !_drawingArea->window) return; + + if (_spotIsDrawable) { + ScreenUnit screenX = GetScreenX(_spotPosition.GetX()); + ScreenUnit screenY = GetScreenY(_spotPosition.GetY()); + if (((-3 <= screenX) && (screenX <= (_screenWidth + 3))) && + ((-3 <= screenY) && (screenY <= (_screenHeight + 3)))) + gdk_draw_rectangle(_drawable, _spotGC, false, screenX - 3, screenY - 3, 6, 6); + _spotIsVisible = !_spotIsVisible; + } +} + +void View::_ShowSpot() +// ******************* +{ + if (!_spotIsVisible) _DrawSpot(); +} + +void View::_HideSpot() +// ******************* +{ + if (_spotIsVisible) _DrawSpot(); +} + +int View::_GetClipCode(const Unit& x, const Unit& y) const +// ******************************************************* +{ + int code = 0; + if (x < _clipBox.GetXMin()) code = 1; + else if (_clipBox.GetXMax() < x) code = 2; + if (y < _clipBox.GetYMin()) code |= 4; + else if (_clipBox.GetYMax() < y) code |= 8; + return code; +} + +bool View::_ClipLine(Unit& xo, Unit& yo, Unit& xe, Unit& ye) const +// *************************************************************** +{ + int cco = _GetClipCode(xo, yo); + int cce = _GetClipCode(xe, ye); + + if (!(cco | cce)) return true; + + int c = cco & cce; + if ((c & 1) || (c & 2) || (c & 4) || (c & 8)) return false; + + if (cco & 1) { + yo += GetUnit((GetValue(ye - yo) * GetValue(_clipBox.GetXMin() - xo)) / GetValue(xe - xo)); + xo = _clipBox.GetXMin(); + return _ClipLine(xo, yo, xe, ye); + } + if (cco & 2) { + yo += GetUnit((GetValue(ye - yo) * GetValue(_clipBox.GetXMax() - xo)) / GetValue(xe - xo)); + xo = _clipBox.GetXMax(); + return _ClipLine(xo, yo, xe, ye); + } + if (cce & 1) { + ye += GetUnit((GetValue(yo - ye) * GetValue(_clipBox.GetXMin() - xe)) / GetValue(xo - xe)); + xe = _clipBox.GetXMin(); + return _ClipLine(xo, yo, xe, ye); + } + if (cce & 2) { + ye += GetUnit((GetValue(yo - ye) * GetValue(_clipBox.GetXMax() - xe)) / GetValue(xo - xe)); + xe = _clipBox.GetXMax(); + return _ClipLine(xo, yo, xe, ye); + } + if (cco & 4) { + xo += GetUnit((GetValue(xe - xo) * GetValue(_clipBox.GetYMin() - yo)) / GetValue(ye - yo)); + yo = _clipBox.GetYMin(); + return _ClipLine(xo, yo, xe, ye); + } + if (cco & 8) { + xo += GetUnit((GetValue(xe - xo) * GetValue(_clipBox.GetYMax() - yo)) / GetValue(ye - yo)); + yo = _clipBox.GetYMax(); + return _ClipLine(xo, yo, xe, ye); + } + if (cce & 4) { + xe += GetUnit((GetValue(xo - xe) * GetValue(_clipBox.GetYMin() - ye)) / GetValue(yo - ye)); + ye = _clipBox.GetYMin(); + return _ClipLine(xo, yo, xe, ye); + } + if (cce & 8) { + xe += GetUnit((GetValue(xo - xe) * GetValue(_clipBox.GetYMax() - ye)) / GetValue(yo - ye)); + ye = _clipBox.GetYMax(); + return _ClipLine(xo, yo, xe, ye); + } + return true; +} + +bool View::_ClipBox(Box& box) const +// ******************************** +{ + box = box.GetIntersection(_clipBox); + return !box.IsEmpty(); +} + +void View::_OnExpose(const ScreenUnit& screenX, const ScreenUnit& screenY, const ScreenUnit& screenWidth, const ScreenUnit& screenHeight, bool update) +// **************************************************************************************************** +{ + if (!_drawingArea) return; + + if (!_hasBeenExposed) { + GdkWindow* window = _drawingArea->window; + GdkColormap* colormap = gdk_window_get_colormap(window); + GdkColor color; + color.red = 50 * 255; + color.green = 50 * 255; + color.blue = 50 * 255; + gdk_color_alloc(colormap, &color); + gdk_window_set_background(window, &color); + FitToContent(); + _backCenter = _center; + _backScale = _scale; + } + + Invalidate(screenX, screenY, screenX + screenWidth, screenY + screenHeight); + + if (update) Update(); +} + +void View::_OnResize(const ScreenUnit& screenWidth, const ScreenUnit& screenHeight) +// ******************************************************************************** +{ + _screenWidth = screenWidth; + _screenHeight = screenHeight; + + if (_drawingArea && _drawingArea->window) { + Point backCenter = _backCenter; + double backScale = _backScale; + double scale = _scale; + _scale = 0; // to force reframe + Reframe(_center, scale); + // to restore good values altered by the hack + _backCenter = backCenter; + _backScale = backScale; + } +} + +void View::_OnMouseEnter(const Point& position) +// ******************************************** +{ + for_each_command(command, GetCommands()) { + command->_OnMouseEnter(this, position); + end_for; + } + _spotIsDrawable = true; + _spotPosition = position; + _ShowSpot(); +} + +void View::_OnMouseMove(const Point& position, unsigned state) +// *********************************************************** +{ + _HideSpot(); + for_each_command(command, GetCommands()) { + command->_OnMouseMove(this, position, state); + end_for; + } + _spotPosition = position; + _ShowSpot(); +} + +void View::_OnMouseLeave(const Point& position) +// ******************************************** +{ + _HideSpot(); + _spotIsDrawable = false; + for_each_command(command, GetCommands()) { + command->_OnMouseLeave(this, position); + end_for; + } +} + +void View::_OnButtonPress(unsigned button, const Point& position, unsigned state) +// ****************************************************************************** +{ + Command* command = GetCommand(button); + if (command) { + _HideSpot(); + command->_OnButtonPress(this, position, state); + _ShowSpot(); + } +} + +void View::_OnButtonRelease(unsigned button, const Point& position, unsigned state) +// ******************************************************************************** +{ + Command* command = GetCommand(button); + if (command) { + _HideSpot(); + command->_OnButtonRelease(this, position, state); + _ShowSpot(); + } +} + +void View::SetDefaultColor (const string& name, unsigned short red, unsigned short green, unsigned short blue) +// *********************************************************************************************************** +{ + GdkColor* color = NULL; + if (name == "background" ) { color = &_backgroundColor; } + else if (name == "foreground" ) { color = &_foregroundColor; } + else if (name == "rubber" ) { color = &_rubberColor; } + else if (name == "phantom" ) { color = &_phantomColor; } + else if (name == "boundary" ) { color = &_boundaryColor; } + else if (name == "marker" ) { color = &_markerColor; } + else if (name == "selectionDraw") { color = &_selectionDrawColor; } + else if (name == "selectionFill") { color = &_selectionFillColor; } + else if (name == "grid" ) { color = &_gridColor; } + else if (name == "spot" ) { color = &_spotColor; } + else if (name == "ghost" ) { color = &_ghostColor; } + else { + throw Error ("Invalid View color name : " + name); + } + + color->red = red * 255; + color->green = green * 255; + color->blue = blue * 255; +} + +void View::SetColor (const string& name, unsigned short red, unsigned short green, unsigned short blue) +// **************************************************************************************************** +{ + GdkColor* color = gdk_color_new(red, green, blue); + GdkGC* gc; + + if (name == "background" ) { gc = _backgroundGC; } + else if (name == "foreground" ) { gc = _foregroundGC; } + else if (name == "rubber" ) { gc = _rubberGC; } + else if (name == "phantom" ) { gc = _phantomGC; } + else if (name == "boundary" ) { gc = _boundaryGC; } + else if (name == "marker" ) { gc = _markerGC; } + else if (name == "selectionDraw") { gc = _selectionDrawGC; } + else if (name == "selectionFill") { gc = _selectionFillGC; } + else if (name == "grid" ) { gc = _gridGC; } + else if (name == "spot" ) { gc = _spotGC; } + else if (name == "ghost" ) { gc = _ghostGC; } + else { + throw Error ("Invalid View color name : " + name); + } + + gdk_gc_set_foreground(gc, color); +} + +void View::SetRubberDisplayType(const RubberDisplayType& rubberdisplaytype) +// ************************************************************************ +{ + _rubberDisplayType = rubberdisplaytype; +} + +void View::SetTextDisplayState(const bool& isTextVisible) +// ************************************************************************ +{ + _isTextVisible = isTextVisible; +} + +// **************************************************************************************************** +// View::RubberDisplayType implementation +// **************************************************************************************************** + +View::RubberDisplayType::RubberDisplayType(const Type& type) +// ********************************************************* +: _type(type) +{ +} + +View::RubberDisplayType::RubberDisplayType(const RubberDisplayType& rubberdisplaytype) +// *********************************************************************************** +: _type(rubberdisplaytype._type) +{ +} + +View::RubberDisplayType& View::RubberDisplayType::operator=(const RubberDisplayType& rubberdisplaytype) +// **************************************************************************************************** +{ + _type = rubberdisplaytype._type; + return *this; +} + +string View::RubberDisplayType::_GetString() const +// *********************************************** +{ + switch (_type) { + case GEOMETRIC : return "GEOMETRIC"; + case BARYCENTRIC : return "BARYCENTRIC"; + case STEINER: return "STEINER"; + } + return "ABNORMAL"; +} + +Record* View::RubberDisplayType::_GetRecord() const +// ****************************************** +{ + Record* record = new Record(GetString(this)); + record->Add(GetSlot("Type", ((unsigned int*)((void*)&_type)))); + return record; +} + +} // End of Hurricane namespace. + + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/View.h b/hurricane/src/hurricane/grenier/View.h new file mode 100644 index 00000000..0b4aa60d --- /dev/null +++ b/hurricane/src/hurricane/grenier/View.h @@ -0,0 +1,395 @@ +// **************************************************************************************************** +// File: View.h +// Authors: R. Escassut +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** + +#ifndef HURRICANE_VIEW +#define HURRICANE_VIEW + +#include "DBo.h" +#include "Views.h" +#include "Transformation.h" +#include "BasicLayer.h" +#include "BasicLayers.h" +#include "Selector.h" +#include "Command.h" +#include "Occurrence.h" + +namespace Hurricane { + +class Cell; +class Go; +class DisplaySlot; + + + +// **************************************************************************************************** +// Special declaration +// **************************************************************************************************** + +typedef Unit ScreenUnit; +typedef Point ScreenPoint; +typedef Box ScreenBox; + + + +// **************************************************************************************************** +// View declaration +// **************************************************************************************************** + +class View : public DBo { +// ******************** + +// Types +// ***** + + public: typedef DBo Inherit; + + public: typedef map CommandMap; + public: typedef set SelectorSet; + + public: class RubberDisplayType { + // **************************** + + public: enum Type {GEOMETRIC=0, BARYCENTRIC=1, STEINER=2}; + + private: Type _type; + + public: RubberDisplayType(const Type& type = GEOMETRIC); + public: RubberDisplayType(const RubberDisplayType& rubberdisplaytype); + + public: RubberDisplayType& operator=(const RubberDisplayType& rubberdisplaytype); + + public: operator const Type&() const {return _type;}; + + public: const Type& GetType() const {return _type;}; + + public: string _GetTypeName() const { return _TName("View::RubberDisplayType"); }; + public: string _GetString() const; + public: Record* _GetRecord() const; + + }; + +// Attributes +// ********** + + //private: GtkWidget* _frame; + //private: GtkWidget* _drawingArea; + + private: Point _center; + private: double _scale; + private: Point _backCenter; + private: double _backScale; + + private: ScreenUnit _screenDx; + private: ScreenUnit _screenDy; + private: ScreenUnit _screenWidth; + private: ScreenUnit _screenHeight; + + private: bool _hasBeenExposed; + + private: Box _screenUpdateArea; + + private: Box _clipBox; + + //private: GdkDrawable* _drawable; + + // Default color settings. + private: static GdkColor _backgroundColor; + private: static GdkColor _foregroundColor; + private: static GdkColor _rubberColor; + private: static GdkColor _phantomColor; + private: static GdkColor _boundaryColor; + private: static GdkColor _markerColor; + private: static GdkColor _selectionDrawColor; + private: static GdkColor _selectionFillColor; + private: static GdkColor _gridColor; + private: static GdkColor _spotColor; + private: static GdkColor _ghostColor; + + private: GdkGC* _backgroundGC; + private: GdkGC* _foregroundGC; + private: GdkGC* _phantomGC; + private: GdkGC* _boundaryGC; + private: GdkGC* _rubberGC; + private: GdkGC* _markerGC; + private: GdkGC* _selectionDrawGC; + private: GdkGC* _selectionFillGC; + private: GdkGC* _gridGC; + private: GdkGC* _spotGC; + private: GdkGC* _ghostGC; + private: GdkGC* _drawGC; + private: GdkGC* _fillGC; + + private: CommandMap _commandMap; + + private: bool _gridIsVisible; + private: ScreenUnit _gridDisplayThreshold; + + private: bool _autoScrollIsEnabled; + private: bool _doubleBufferingIsEnabled; + private: bool _phantomsAreVisible; + private: bool _boundariesAreVisible; + private: bool _rubbersAreVisible; + private: bool _markersAreVisible; + private: bool _cutPointsAreVisible; + private: bool _selectionIsVisible; + private: bool _displaySlotsAreVisible; + private: bool _visualMapsAreVisible; + private: bool _spotIsVisible; + private: bool _spotIsDrawable; + private: Point _spotPosition; + + private: Layer::Mask _visibleBasicLayersMask; + + private: SelectorSet _selectorSet; + + private: RubberDisplayType _rubberDisplayType; + private: bool _isTextVisible; + + private: View* _nextOfCellViewSet; + +// Constructors +// ************ + + protected: View(); + +// Accessors +// ********* + + public: GtkWidget* GetFrame() const {return _frame;}; + public: GtkWidget* GetDrawingArea() const {return _drawingArea;}; + public: virtual Cell* GetCell() const = 0; + public: virtual Transformation GetTransformation() const = 0; + + public: const Point& GetCenter() const {return _center;}; + public: double GetScale() const {return _scale;}; + public: const Point& GetBackCenter() const {return _backCenter;}; + public: double GetBackScale() const {return _backScale;}; + + public: const ScreenUnit& GetScreenWidth() const {return _screenWidth;}; + public: const ScreenUnit& GetScreenHeight() const {return _screenHeight;}; + + public: ScreenUnit GetHalfScreenWidth() const {return _screenWidth / 2;}; + public: ScreenUnit GetHalfScreenHeight() const {return _screenHeight / 2;}; + + public: Unit GetX(const ScreenUnit& screenX) const; + public: Unit GetY(const ScreenUnit& screenY) const; + public: Unit GetSize(const ScreenUnit& screenSize) const; + public: Point GetPoint(const ScreenPoint& screenPoint) const; + public: Box GetBox(const ScreenBox& screenBox) const; + + public: ScreenUnit GetScreenX(const Unit& x) const; + public: ScreenUnit GetScreenY(const Unit& y) const; + public: ScreenUnit GetScreenSize(const Unit& size) const; + public: ScreenPoint GetScreenPoint(const Point& point) const; + public: ScreenBox GetScreenBox(const Box& box) const; + + public: virtual Box GetClientArea() const; + public: Box GetVisibleArea() const; + + public: Command* GetCommand(unsigned button) const; + public: Commands GetCommands() const {return GetCollection(_commandMap);}; + + public: const ScreenUnit& GetGridDisplayThreshold() const {return _gridDisplayThreshold;}; + + public: const Layer::Mask& GetVisibleBasicLayersMask() const {return _visibleBasicLayersMask;}; + public: BasicLayers GetVisibleBasicLayers() const; + + public: Selectors GetSelectors() const {return GetCollection(_selectorSet);}; + + public: const RubberDisplayType& GetRubberDisplayType() const {return _rubberDisplayType;}; + +// Predicates +// ********** + + public: bool GridIsVisible() const {return _gridIsVisible;}; + public: bool GridIsDrawable() const {return (_gridDisplayThreshold < GetScreenSize(GetGridStep()));}; + public: bool AutoScrollIsEnabled() const {return _autoScrollIsEnabled;}; + public: bool DoubleBufferingIsEnabled() const {return _doubleBufferingIsEnabled;}; + public: bool PhantomsAreVisible() const {return _phantomsAreVisible;}; + public: bool BoundariesAreVisible() const {return _boundariesAreVisible;}; + public: bool CutPointsAreVisible() const {return _cutPointsAreVisible;}; + public: bool RubbersAreVisible() const {return _rubbersAreVisible;}; + public: bool MarkersAreVisible() const {return _markersAreVisible;}; + public: bool SelectionIsVisible() const {return _selectionIsVisible;}; + public: bool DisplaySlotsAreVisible() const {return _displaySlotsAreVisible;}; + public: bool IsVisible(BasicLayer* basicLayer) const; + public: bool IsTextVisible() const {return _isTextVisible;}; + + public: bool IsSelected(Go* go) const; + public: bool IsSelected(const Occurrence& occurrence) const; + public: bool HasSomethingSelected() const {return !_selectorSet.empty();}; + +// Updators +// ******** + + public: void SetCell(Cell* cell); + public: void SetTransformation(const Transformation& transformation); + public: void ShowGrid(); + public: void HideGrid(); + public: void SetGridDisplayThreshold(const ScreenUnit& threshold); + public: void EnableAutoScroll() {_autoScrollIsEnabled = true;}; + public: void DisableAutoScroll() {_autoScrollIsEnabled = false;}; + public: void EnableDoubleBuffering() {_doubleBufferingIsEnabled = true;}; + public: void DisableDoubleBuffering() {_doubleBufferingIsEnabled = false;}; + public: void SetVisibleBasicLayersMask(const Layer::Mask& visibleBasicLayersMask); + public: void ShowPhantoms(); + public: void HidePhantoms(); + public: void ShowBoundaries(); + public: void HideBoundaries(); + public: void ShowCutPoints(); + public: void HideCutPoints(); + public: void ShowRubbers(); + public: void HideRubbers(); + public: void ShowMarkers(); + public: void HideMarkers(); + public: void ShowSelection(); + public: void HideSelection(); + public: void ShowDisplaySlots(); + public: void HideDisplaySlots(); + public: void ShowVisualMaps(); + public: void HideVisualMaps(); + public: void Show(BasicLayer* basicLayer); + public: void Hide(BasicLayer* basicLayer); + public: void ShowAllLayers(); + public: void HideAllLayers(); + public: void SetRubberDisplayType(const RubberDisplayType& rubberdisplaytype); + public: void SetTextDisplayState(const bool& isTextVisible); + + public: void Select(Go* go); + public: void Unselect(Go* go); + public: void Select(Occurrence& occurrence); + public: void Unselect(Occurrence& occurrence); + public: void UnselectAll(); + +// Managers +// ******** + + public: void Invalidate(const ScreenUnit& screenXo, const ScreenUnit& screenYo, const ScreenUnit& screenXe, const ScreenUnit& screenYe); + + public: void Invalidate(); + public: void Invalidate(const Box& area); + + public: virtual bool Update(bool useDoubleBuffering = false); + public: void Refresh(bool useDoubleBuffering = false); + public: void CheckForDisplayInterruption(); + + public: void VerticalScroll(const Unit& dy); + public: void HorizontalScroll(const Unit& dx); + public: void Scroll(const Unit& dx, const Unit& dy); + + public: void Reframe(const Point& center); + public: void Reframe(const Point& center, double scale); + public: void Reframe(const Box& area); + public: void ReframeBack(); + public: void FitToContent(); + + public: void DrawGhost(Command* command); + +// Display primitives +// ****************** + + public: void SetGCs(GdkGC* drawGC, GdkGC* fillGC); + + public: static void SetDefaultColor(const string& name, unsigned short red, unsigned short green, unsigned short blue); + public: void SetColor(const string& name, unsigned short red, unsigned short green, unsigned short blue); + + public: void DrawPoint(const Unit& x, const Unit& y, const ScreenUnit& screenSize); + public: void DrawPoint(const Point& position, const ScreenUnit& screenSize); + + public: void DrawLine(const Unit& xo, const Unit& yo, const Unit& xe, const Unit& ye); + public: void DrawLine(const Point& origin, const Point& extremity); + + public: void DrawLines(const vector& points, unsigned size); + public: void DrawPolygon(const vector& points, unsigned size); + + public: void DrawRectangle(const Unit& xo, const Unit& yo, const Unit& xe, const Unit& ye); + public: void DrawRectangle(const Point& origin, const Point& extremity); + public: void DrawRectangle(const Box& box); + + public: void DrawCircle(const Unit& x, const Unit& y, const Unit& radius); + public: void DrawCircle(const Point& center, const Unit& radius); + + public: void DrawString(const string& text, const Unit& x, const Unit& y); + + public: void _DrawDisplaySlot(DisplaySlot* displaySlot, const Box& ares, const Box& updateArea, const Transformation& transformation); + + public: void FillPolygon(const vector& points, unsigned size, bool solid = false); + + public: void FillRectangle(const Unit& xo, const Unit& yo, const Unit& xe, const Unit& ye, bool solid = false); + public: void FillRectangle(const Point& origin, const Point& extremity, bool solid = false); + public: void FillRectangle(const Box& box, bool solid = false); + + public: void FillCircle(const Unit& x, const Unit& y, const Unit& radius, bool solid = false); + public: void FillCircle(const Point& center, const Unit& radius, bool solid = false); + +// Others +// ****** + + protected: virtual void _PostCreate(); + + protected: virtual void _PreDelete(); + + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + public: GdkGC* _GetBackgroundGC() const {return _backgroundGC;}; + public: GdkGC* _GetForegroundGC() const {return _foregroundGC;}; + public: GdkGC* _GetPhantomGC() const {return _phantomGC;}; + public: GdkGC* _GetBoundaryGC() const {return _boundaryGC;}; + public: GdkGC* _GetRubberGC() const {return _rubberGC;}; + public: GdkGC* _GetMarkerGC() const {return _markerGC;}; + public: GdkGC* _GetSelectionDrawGC() const {return _selectionDrawGC;}; + public: GdkGC* _GetSelectionFillGC() const {return _selectionFillGC;}; + public: GdkGC* _GetGridGC() const {return _gridGC;}; + public: GdkGC* _GetGhostGC() const {return _ghostGC;}; + public: CommandMap& _GetCommandMap() {return _commandMap;}; + public: SelectorSet& _GetSelectorSet() {return _selectorSet;}; + public: View* _GetNextOfCellViewSet() const {return _nextOfCellViewSet;}; + + public: bool _DisplayHasBeenAborted(); + + public: virtual void _SetCell(Cell* cell) = 0; + public: virtual void _SetTransformation(const Transformation& transformation) = 0; + public: void _SetNextOfCellViewSet(View* view) {_nextOfCellViewSet = view;}; + + public: virtual void _PreRepaint(); + public: virtual void _PostRepaint(); + public: void _Repaint(const Box& area); + + public: void _DrawSpot(); + public: void _ShowSpot(); + public: void _HideSpot(); + + private: int _GetClipCode(const Unit& x, const Unit& y) const; + private: bool _ClipLine(Unit& xo, Unit& yo, Unit& xe, Unit& ye) const; + private: bool _ClipBox(Box& box) const; + + public: void _OnExpose(const ScreenUnit& screenX, const ScreenUnit& screenY, const ScreenUnit& screenWidth, const ScreenUnit& screenHeight, bool update); + public: void _OnResize(const ScreenUnit& screenWidth, const ScreenUnit& screenHeight); + public: void _OnMouseEnter(const Point& position); + public: void _OnMouseMove(const Point& position, unsigned state); + public: void _OnMouseLeave(const Point& position); + public: void _OnButtonPress(unsigned button, const Point& position, unsigned state); + public: void _OnButtonRelease(unsigned button, const Point& position, unsigned state); + +}; + + +} // End of Hurricane namespace. + + +SetNestedSlotAdapter(Hurricane::View) + +// **************************************************************************************************** +// Generic functions +// **************************************************************************************************** + + + +#endif // HURRICANE_VIEW + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/grenier/VisualMap.cpp b/hurricane/src/hurricane/grenier/VisualMap.cpp new file mode 100644 index 00000000..96ed0a3a --- /dev/null +++ b/hurricane/src/hurricane/grenier/VisualMap.cpp @@ -0,0 +1,162 @@ +#include "Error.h" +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +#include "Relation.h" +#include "Cell.h" + +#include "VisualMap.h" + +namespace Hurricane { + +static Name VisualMapsCellRelationName("VisualMapsCellRelation"); + +static StandardRelation* GetVisualMapRelation(const Cell* cell) +{ + Property* property = cell->GetProperty(VisualMapsCellRelationName); + if (!property) + return NULL; + else + { + StandardRelation* relation = dynamic_cast(property); + if (!relation) + throw Error("Bad Property type: Must be a Standard Relation"); + return relation; + } +} + +// **************************************************************************************************** +// VisualMap implementation +// **************************************************************************************************** + +VisualMap::VisualMap(Cell* cell,const Name& name) +// *********************** + : Inherit() + , _cell(cell) + , _name(name) + , _GCs() + , _isVisible(true) +{ + //_GC = gtk_gc_new(red, green, blue, pattern); + _GCs.resize(256); +} + + +void VisualMap::_PostCreate() +// *********************** +{ + Inherit::_PostCreate(); + StandardRelation* relation = GetVisualMapRelation(_cell); + if (!relation) + relation = StandardRelation::Create(_cell, VisualMapsCellRelationName); + Put(relation); +} + +void VisualMap::SetGC (unsigned short index, unsigned short red, unsigned short green, unsigned short blue, const string& pattern) +// *********************** +{ + if (_GCs[index]) + { + gdk_gc_destroy(_GCs[index]); + _GCs[index] = NULL; + } + _GCs[index] = gtk_gc_new(red, green, blue, pattern); + return; +} + +void VisualMap::Show() +// ********************* +{ + if (!_isVisible) { + _isVisible = true; + for_each_view(view, _cell->GetViews()) + { + view->Invalidate(); + end_for; + } + } +} + +void VisualMap::Hide() +// ********************* +{ + if (_isVisible) { + _isVisible = false; + for_each_view(view, _cell->GetViews()) + { + view->Invalidate(); + end_for; + } + } +} + +void VisualMap::_PreDelete() +// *************************** +{ + Inherit::_PreDelete(); + for (unsigned short i = 0 ; i < 255 ; i ++) + { + if (_GCs[i]) + { + gdk_gc_destroy(_GCs[i]); + _GCs[i] = NULL; + } + _GCs[i] = NULL; + } +} + +string VisualMap::_GetString() const +// *********************************** +{ + string s = Inherit::_GetString(); + s.insert(s.length() - 1, " " + GetString(GetName())); + return s; +} + +Record* VisualMap::_GetRecord() const +// ****************************** +{ + Record* record = Inherit::_GetRecord(); + if (record) { + record->Add(GetSlot("Cell", _cell)); + record->Add(GetSlot("Name", _name)); + record->Add(GetSlot("Is Visible", _isVisible)); + } + return record; +} + +VisualMaps GetVisualMaps(const Cell* cell) +{ + if (!cell) + throw Error("Null pointer on cell while getting display slots"); + + StandardRelation* relation = GetVisualMapRelation(cell); + if (!relation) + return VisualMaps(); + return relation->GetSlaveOwners().GetSubSet(); +} + +VisualMap* GetVisualMap(const Cell* cell,const Name& name) +{ + if (!cell) + throw Error("Null pointer on cell while getting display slots"); + + StandardRelation* relation = GetVisualMapRelation(cell); + if (!relation) + return NULL; + else + { + for_each_visual_map(visualMap,relation->GetSlaveOwners().GetSubSet()) + { + if (visualMap->GetName() == name) + return visualMap; + end_for; + } + return NULL; + } +} + + +} // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/grenier/VisualMap.h b/hurricane/src/hurricane/grenier/VisualMap.h new file mode 100644 index 00000000..bac1e474 --- /dev/null +++ b/hurricane/src/hurricane/grenier/VisualMap.h @@ -0,0 +1,80 @@ +#ifndef HURRICANE_VISUAL_MAP +// +// This file is part of the Tsunami Project. +// Copyright (c) 2001-2004 Laboratoire LIP6 - Departement ASIM +// Universite Pierre et Marie Curie. +// +#define HURRICANE_VISUAL_MAP + +#include "View.h" +#include "VisualMaps.h" + +namespace Hurricane { + +// **************************************************************************************************** +// VisualMap declaration +// **************************************************************************************************** + +class VisualMap : public DBo { +// *************************** + +// Types +// ***** + + public: typedef DBo Inherit; + +// Attributes +// ********** + private: Cell* _cell; + private: Name _name; + //private: QuadTree _quadTree; + private: vector _GCs; + private: bool _isVisible; + +// Constructors +// ************ + + protected: VisualMap(Cell* cell,const Name& name); + protected: virtual void _PostCreate(); + +// Destructor +// ********** + + protected: virtual void _PreDelete(); + +// Accessors +// ********* + + public: const Name& GetName() const {return _name;}; + +// Predicates +// ********** + + public: bool IsVisible() const {return _isVisible;}; + public: void Show(); + public: void Hide(); + +// Updators +// ******** + protected: void SetGC (unsigned short index, unsigned short red, unsigned short green, unsigned short blue, const string& pattern = "CC33CC33CC33CC33"); + +// Others +// ****** + public: virtual void _Draw(View* view, const Box& updateArea, const Transformation& transformation) = 0; + + public: virtual string _GetTypeName() const {return _TName("VisualMap");}; + public: virtual string _GetString() const; + public: virtual Record* _GetRecord() const; + +}; + +VisualMaps GetVisualMaps(const Cell* cell); + +VisualMap* GetVisualMap(const Cell* cell, const Name& name); + + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_VISUAL_MAP diff --git a/hurricane/src/hurricane/grenier/VisualMaps.h b/hurricane/src/hurricane/grenier/VisualMaps.h new file mode 100644 index 00000000..5a522e59 --- /dev/null +++ b/hurricane/src/hurricane/grenier/VisualMaps.h @@ -0,0 +1,56 @@ +#ifndef HURRICANE_VISUAL_MAPS +#define HURRICANE_VISUAL_MAPS + +#include "Collection.h" + +namespace Hurricane { + +class VisualMap; + + + +// **************************************************************************************************** +// VisualMaps declaration +// **************************************************************************************************** + +typedef GenericCollection VisualMaps; + + + +// **************************************************************************************************** +// VisualMapLocator declaration +// **************************************************************************************************** + +typedef GenericLocator VisualMapLocator; + + + +// **************************************************************************************************** +// VisualMapFilter declaration +// **************************************************************************************************** + +typedef GenericFilter VisualMapFilter; + + + +// **************************************************************************************************** +// for_each_view declaration +// **************************************************************************************************** + +#define for_each_visual_map(visualMap, visualMaps)\ +/*********************************/\ +{\ + VisualMapLocator _locator = visualMaps.GetLocator();\ + while (_locator.IsValid()) {\ + VisualMap* visualMap = _locator.GetElement();\ + _locator.Progress(); + + + +} // End of Hurricane namespace. + +#endif // HURRICANE_VISUAL_MAPS + +// **************************************************************************************************** +// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +// **************************************************************************************************** diff --git a/hurricane/src/hurricane/makefile.noAM b/hurricane/src/hurricane/makefile.noAM new file mode 100644 index 00000000..915be70e --- /dev/null +++ b/hurricane/src/hurricane/makefile.noAM @@ -0,0 +1,154 @@ +####################################################################################################### +# File: makefile +# Authors: R. Escassut +# Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +####################################################################################################### +# 21-10-2003 Alignement BULL-LIP6 + + +####################################################################################################### +# Global macros +####################################################################################################### + +_ROOT = $(HURRICANE_ROOT) +_TARGET = $(HURRICANE_TARGET) +_SYSTEM = $(HURRICANE_SYSTEM) +_CC = $(HURRICANE_CC) + +_LIB = $(_ROOT)/build/$(_TARGET)/lib/$(_SYSTEM)/$(_CC) +_DEP = $(_ROOT)/build/$(_TARGET)/dep/$(_SYSTEM)/$(_CC) +_BIN = $(_ROOT)/build/$(_TARGET)/bin/$(_SYSTEM)/$(_CC) + +include $(_ROOT)/build/$(_TARGET)/makefiles/$(_SYSTEM)/$(_CC)/makefile + + + +####################################################################################################### +# Local macros +####################################################################################################### + +_INCLUDES = -I$(_ROOT)/bitmaps \ + -I$(_ROOT)/pixmaps \ + $(_GTK_INCLUDES) + +_LIBRARY = $(_LIB)/libHurricane.a + +_OBJECTS = $(_LIBRARY)(BasicLayer.o) \ + $(_LIBRARY)(Box.o) \ + $(_LIBRARY)(Builder.o) \ + $(_LIBRARY)(Cell.o) \ + $(_LIBRARY)(CellCollections.o) \ + $(_LIBRARY)(Command.o) \ + $(_LIBRARY)(Commons.o) \ + $(_LIBRARY)(Component.o) \ + $(_LIBRARY)(CompositeLayer.o) \ + $(_LIBRARY)(Contact.o) \ + $(_LIBRARY)(DataBase.o) \ + $(_LIBRARY)(DBo.o) \ + $(_LIBRARY)(DRCError.o) \ + $(_LIBRARY)(DisplaySlot.o) \ + $(_LIBRARY)(Entity.o) \ + $(_LIBRARY)(Error.o) \ + $(_LIBRARY)(Exception.o) \ + $(_LIBRARY)(Go.o) \ + $(_LIBRARY)(GtkUtils.o) \ + $(_LIBRARY)(Hook.o) \ + $(_LIBRARY)(Horizontal.o) \ + $(_LIBRARY)(HyperNet.o) \ + $(_LIBRARY)(InputFile.o) \ + $(_LIBRARY)(Instance.o) \ + $(_LIBRARY)(Interruption.o) \ + $(_LIBRARY)(Interval.o) \ + $(_LIBRARY)(Layer.o) \ + $(_LIBRARY)(Library.o) \ + $(_LIBRARY)(MainView.o) \ + $(_LIBRARY)(MapView.o) \ + $(_LIBRARY)(Marker.o) \ + $(_LIBRARY)(Name.o) \ + $(_LIBRARY)(Net.o) \ + $(_LIBRARY)(NetExternalComponents.o) \ + $(_LIBRARY)(Occurrence.o) \ + $(_LIBRARY)(OutputFile.o) \ + $(_LIBRARY)(Pad.o) \ + $(_LIBRARY)(Path.o) \ + $(_LIBRARY)(Pin.o) \ + $(_LIBRARY)(Plug.o) \ + $(_LIBRARY)(Point.o) \ + $(_LIBRARY)(Primitive.o) \ + $(_LIBRARY)(Property.o) \ + $(_LIBRARY)(QuadTree.o) \ + $(_LIBRARY)(Quark.o) \ + $(_LIBRARY)(Record.o) \ + $(_LIBRARY)(Reference.o) \ + $(_LIBRARY)(Region.o) \ + $(_LIBRARY)(Relation.o) \ + $(_LIBRARY)(RoutingPad.o) \ + $(_LIBRARY)(Rubber.o) \ + $(_LIBRARY)(Segment.o) \ + $(_LIBRARY)(Selector.o) \ + $(_LIBRARY)(SharedName.o) \ + $(_LIBRARY)(SharedPath.o) \ + $(_LIBRARY)(Slice.o) \ + $(_LIBRARY)(Slot.o) \ + $(_LIBRARY)(Symbol.o) \ + $(_LIBRARY)(Tabulation.o) \ + $(_LIBRARY)(Tag.o) \ + $(_LIBRARY)(Technology.o) \ + $(_LIBRARY)(Timer.o) \ + $(_LIBRARY)(Transformation.o) \ + $(_LIBRARY)(Unit.o) \ + $(_LIBRARY)(UpdateSession.o) \ + $(_LIBRARY)(UserGo.o) \ + $(_LIBRARY)(Vertical.o) \ + $(_LIBRARY)(View.o) \ + $(_LIBRARY)(VisualMap.o) \ + $(_LIBRARY)(Warning.o) + +_DEPENDENCIES = $(_DEP)/libHurricane.dep + + + +####################################################################################################### +# Implicit rules +####################################################################################################### + +.PRECIOUS: $(_LIBRARY) + +.SUFFIXES: $(SUFFIXES) .cpp + +.cpp.a: + @echo "Compiling" $< + $(_CC) $(_CCFLAGS) $(_INCLUDES) -c $< + @ar crv $(_LIBRARY) $*.o > /dev/null + @rm $*.o + + + +####################################################################################################### +# Explicit rules +####################################################################################################### + +default: library + +library: $(_OBJECTS) + @echo "Updating" $(_LIBRARY) + @rm -f *.o + @ranlib $(_LIBRARY) + +clean: + @echo "Deleting" $(_LIBRARY) + @rm -f $(_LIBRARY) + +depend: + @echo "Updating" $(_DEPENDENCIES) + @makedepend -f $(_DEPENDENCIES) -p"$(_LIBRARY)(" -o".o)" -- $(_CCFLAGS) $(_INCLUDES) -- *.cpp >& makedepend.log + @rm $(_DEPENDENCIES).bak + @rm makedepend.log + +include $(_DEPENDENCIES) + + + +####################################################################################################### +# Copyright (c) BULL S.A. 2000-2004, All Rights Reserved +#######################################################################################################