|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectbyucc.edif.EdifLibraryManager
public class EdifLibraryManager
Represents and manages a list of related EDIF libraries
(EdifLibrary). This object has a parent
EdifEnvironment object and a list of EdifLibrary objects.
Each library must have a unique name and the uniqueness of the names
is managed by a ArrayListNameSpaceResolver object.
The libraries within this object are related and must be managed according to the "define before use" rules of EDIF. This means that any EdifCell object instanced within a parent EdifCell object must be defined before the parent EdifCell is defined. This object manages the ordering of EdifCell objects within libraries and the ordering of the libraries. Major issues: 2. Remove getCell(String) method and fix references - see notes on method for this 3. Move addLeafCell and addCellDeep to EdifMergeParser - addLeafCell - called by addCellDeep - addCellDeep - Called by itself recursively - Called by replaceBlackBox 4. clean up "adding" - get rid of "findEarliest/Latest" methods - Come up with better way of determining library ordering - Use "names" for finding position rather than name 5. Clean up delete. - deleting should be fixed and cleaned up (safe deletes) addLibrary The purpose of this method is to add a library that is currently not a part of this manager and link it into this manager correctly. - throws NameDuplicationException if there is a name conflict - do not rename! A valid name must be given. - Do we need to go through and validate the references of cells in the added library to those libraries that have already been added? It seems like we should go through all of the previously defined libraries and match by name those library elements that are referenced by the cells in the library we are adding. EdifLibrary.findInstancedLibraryCells(EdifCell) - Should add a parameter that says whether to find instances by name or find instances by reference. addLeafCell - Used by only addCellDeep - This method doesn't seem to make sense here. This class can be used to help find the appropriate library, but most of the method should be performed somewhere else. It would probably best fit in the EdifMergeParser class. addCellDeep - used by EdifMergeParser. Move to this class EdifLibrary containsCell(EdifCell) - change to "getLibraryContainingCell". Return null if there is no library that contains the cell. This method performs a search based on reference, not name. Note that the "boolean EdifLibrary.containsCell(EdifCell)" method called by this method does not need a name change. deleteCell - Get rid of this method. Call the EdifLibrary version as needed. * We need a better way of managing the deletion of cells in the libraries. It is possible that a cell is deleted but there are still references to the cell. We would want to generate an exception when this occurs ("ReferencedCell deletion exception"). The delete code would need to check all successor libraries to see if the cell was referenced and if it was, generate an exception. findBlackBoxes - keep. Methods in EdifLibraryManager may look much the same as EdifLibrary findCellInstancesOf - OK. Bad name (should be findInstancesOf(EdifCell)) however, there are similar methods: EdifLibrary.findCellInstancesOf(EdifCell) EdifCell.findCellInstancesOf(EdifCell) (This is worth doing at some point) Only findEarliestPositionToAdd is used by any method (addLibrary). All of these methods can be removed so long as the "library ordering" problem is solved. This ordering is needed by "addLibrary" to make sure a library is added at the proper time (this goes under the addLibrary issue). findEarliestLibraryToAdd findEarliestPositionToAdd findLatestLibraryToAdd findLastestPositionToAdd findEarliestPositionToAdd - calls EdifLibrary.findInstancedLibraryCells(EdifLibrary) - calls EdifLibrary.findInstancedLibraryCells(EdifCell) - Uses reference matching to see if the cell uses the library. It should use name matching. findNonReferencedCells() - keep this method. getCell(String) - this method has problems as it is possible to have more than one EdifCell with the same name but in different libraries. Need to use "getCells" method and fix all references to this method. getCells() ok getCells(String) ok getFirstPrimitiveLibrary - this is an awkward method. Perhaps there should be a different class that manages primitive libraries. I suppose it is ok here. getLibraries() ok getLibrary(String) - need to fix for lower case name compare nameClash() - keep this method but modify it so that it conforms to some interface. Give a EdifNameable as a parameter. pruneNonReferencedCells() - keep method (useful). Update as necessary. - Don't call delete method as a part of this class. Instead, do the following for each EdifCell object that you get from the findNonReferencedCells: - call deleteCell on the library in which the cell resides. tagLeafCellsAsPrimitives() - awkward. Need to have a special package that handles all of this primitive handling. I think the best place for this would e byucc.edif.libraries (although primitives would be a better name). Why would you want to tag all libraries as primitives? This makes no sense (used by EdifRandomCircuit). tagPrimitives() - move to the new Primitive handling classes. toEdif toString trimToSize validateOrder - this is awkward. The data structure should always be valid. Track down when and how this is used and remove this method. Primitive handling: - create new class byucc.edif.libraries.PrimitiveHandling - tagLeafCellsAsPrimitives method for tagging
EdifLibrary| Field Summary | |
|---|---|
private EdifEnvironment |
_edifEnvironment
The EdifEnvironment that points to this library manager. |
private EdifNameSpaceList<EdifLibrary> |
_libraries
The EdifLibrary objects of this file. |
| Constructor Summary | |
|---|---|
EdifLibraryManager(EdifEnvironment edifFile)
Construct an EdifLibraryManager Object with the specified EdifEnvironment. |
|
| Method Summary | |
|---|---|
boolean |
addLibrary(EdifLibrary library)
Add a library to this library manager, and sets its library manager to 'this' TODO: should this method even exist? |
EdifLibrary |
containsCell(EdifCell cell)
Search for the given cell among all libraries. |
boolean |
containsLibrary(EdifLibrary lib)
|
boolean |
deleteCell(EdifCell cell,
boolean force)
Delete a cell from the library manager, and return whether or not the delete was successful. |
java.util.Collection |
findBlackBoxes()
This method will search through all EdifCells in the current Manager and determine which cells are not defined. |
java.util.Collection |
findCellInstancesOf(EdifCell cell)
This method will return a list of EdifCellInstances in the entire libraryManager that reference the passed in cell. |
EdifLibrary |
findEarliestLibraryToAdd(EdifCell cell,
boolean addToPrimitiveLibraryOK)
This method returns the earliest library that this cell can be added to. |
int |
findEarliestPositionToAdd(EdifLibrary add)
Return the earliest position to add the library within the collection of libraries, so as to avoid violating the define before use rule. |
EdifLibrary |
findLatestLibraryToAdd(EdifCell cell,
boolean addToPrimitiveLibraryOK)
This method returns the latest library that this cell can be added to. |
int |
findLatestPositionToAdd(EdifLibrary add)
Return the latest position to add the library within the collection of libraries, so as to avoid violating the define before use rule. |
java.util.Collection<EdifCell> |
findNonReferencedCells(EdifCell topCell)
Starting at the top cell, find all cells referenced by it either directly or indirectly through recursion and return a Collection of EdifCells that are not referenced. |
EdifCell |
getCell(java.lang.String name)
Return the first cell whose name matches the give String. |
java.util.List |
getCells()
This method will return a List of all cells in the library manager. |
java.util.Collection<EdifCell> |
getCells(java.lang.String name)
Return all the EdifCell objects whose name matches the give String. |
java.util.List<java.util.List<EdifLibrary>> |
getDFSForest()
|
EdifEnvironment |
getEdifEnvironment()
Return the file pointing to this library manager. |
EdifLibrary |
getFirstPrimitiveLibrary()
Return the first primitive library in the collection of libraries. |
java.util.List<EdifLibrary> |
getLibraries()
Return the libraries contained by this library manager. |
EdifLibrary |
getLibrary(java.lang.String lib)
Return the library based on the string lib. |
EdifNameable |
getUniqueLibraryNameable(EdifLibrary lib)
|
EdifNameable |
getUniqueLibraryNameable(EdifNameable en)
|
java.util.List<EdifLibrary> |
getValidLibraryOrder()
|
java.util.Iterator |
iterator()
Return iterator of the EdifLibrary objects contained within this object. |
boolean |
nameClash(EdifLibrary lib)
Return true if the library can be added to the library name space, otherwise false. |
void |
pruneNonReferencedCells()
Prune cells that are not referenced (recursively) by the top cell. |
void |
pruneNonReferencedCells(EdifCell topCell)
Prune cells that are not referenced (recursively) by the top cell. |
void |
toEdif(EdifPrintWriter epw)
Print the Edif equivalent of this EdifLibraryManager. |
java.lang.String |
toString()
|
void |
trimToSize()
Trim to size all Trimmable objects in this library manager. |
private void |
visitCell(EdifCell cell,
java.util.Set<EdifCell> visited)
|
private void |
visitLib(EdifLibrary lib,
java.util.List<EdifLibrary> currentTree,
java.util.List<EdifLibrary> unvisitedLibs,
java.util.List<EdifLibrary> finishedLibs)
Visit a library during the depth first search topological sort. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private EdifEnvironment _edifEnvironment
private EdifNameSpaceList<EdifLibrary> _libraries
| Constructor Detail |
|---|
public EdifLibraryManager(EdifEnvironment edifFile)
edifFile - The EdifEnvironment that contains this
EdifLibraryManager| Method Detail |
|---|
public boolean addLibrary(EdifLibrary library)
throws EdifNameConflictException
library - The library to add into this manager, defaulted
to add at the earliest position
EdifNameConflictExceptionfindLatestPositionToAdd(EdifLibrary)public EdifLibrary containsCell(EdifCell cell)
public boolean containsLibrary(EdifLibrary lib)
public boolean deleteCell(EdifCell cell,
boolean force)
cell - The cell to be deleted.force - Forces the cell to be deleted even if it's still
referenced within the library manager.
EdifLibrary.deleteCell(EdifCell,boolean)public java.util.Collection findBlackBoxes()
EdifLibrary.findBlackBoxes()public java.util.Collection findCellInstancesOf(EdifCell cell)
cell - The cell to check references for
EdifLibrary.findCellInstancesOf(EdifCell)
public EdifLibrary findEarliestLibraryToAdd(EdifCell cell,
boolean addToPrimitiveLibraryOK)
cell - The cell to be added into which library.addToPrimitiveLibraryOK - Specifies whether or not it is
ok to add the cell to a primitive library.
findEarliestPositionToAdd(EdifLibrary)public int findEarliestPositionToAdd(EdifLibrary add)
add - The library to add to the earliest position
findEarliestPositionToAdd(EdifLibrary)
public EdifLibrary findLatestLibraryToAdd(EdifCell cell,
boolean addToPrimitiveLibraryOK)
cell - The cell to be added into which library.addToPrimitiveLibraryOK - Specifies whether or not it is
ok to add the cell to a primitive library.
findLatestPositionToAdd(EdifLibrary)public int findLatestPositionToAdd(EdifLibrary add)
add - The library to add to the latest position
EdifLibraryManager#findPositionToAddpublic java.util.Collection<EdifCell> findNonReferencedCells(EdifCell topCell)
public EdifCell getCell(java.lang.String name)
name - The name of the cell to return
EdifLibrary.getCell(String)public java.util.List getCells()
public java.util.Collection<EdifCell> getCells(java.lang.String name)
name - The name of the cell to return
EdifLibrary.getCell(String)public java.util.List<java.util.List<EdifLibrary>> getDFSForest()
public EdifEnvironment getEdifEnvironment()
public EdifLibrary getFirstPrimitiveLibrary()
public java.util.List<EdifLibrary> getLibraries()
public EdifLibrary getLibrary(java.lang.String lib)
lib - The String that will be used to find the library
public java.util.List<EdifLibrary> getValidLibraryOrder()
public java.util.Iterator iterator()
public boolean nameClash(EdifLibrary lib)
lib - The library to chech to see if there is a name clash
with this libraries of this library manager
public void pruneNonReferencedCells(EdifCell topCell)
topCell - the design's top cellpublic void pruneNonReferencedCells()
public EdifNameable getUniqueLibraryNameable(EdifNameable en)
public EdifNameable getUniqueLibraryNameable(EdifLibrary lib)
public void toEdif(EdifPrintWriter epw)
toEdif in interface EdifOutepw - The EdifPrintWriter Object that the interfacing
Object will write EDIF data topublic java.lang.String toString()
toString in class java.lang.Objectpublic void trimToSize()
trimToSize in interface Trimable
private void visitLib(EdifLibrary lib,
java.util.List<EdifLibrary> currentTree,
java.util.List<EdifLibrary> unvisitedLibs,
java.util.List<EdifLibrary> finishedLibs)
lib - The EdifLibrary to visitcurrentLib - A List of libraries to add libraries tounvisitedLibs - A List of unvisited librariesfinishedLibs - A List of finished libraries
private void visitCell(EdifCell cell,
java.util.Set<EdifCell> visited)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||