com.sun.electric.database
Class Snapshot

java.lang.Object
  extended by com.sun.electric.database.Snapshot

public class Snapshot
extends java.lang.Object


Field Summary
 ImmutableArrayList<CellBackup> cellBackups
           
 int[] cellGroups
           
 Environment environment
           
 CellId[] groupMainSchematics
           
 IdManager idManager
           
 ImmutableArrayList<LibraryBackup> libBackups
           
 int snapshotId
           
 TechPool techPool
           
 Tool tool
           
 
Constructor Summary
Snapshot(IdManager idManager)
          Creates empty snapshot.
 
Method Summary
 boolean cellBoundsDefined()
          Checks if all cell bounds are defined.
 void check()
          Checks invariant of this Snapshot.
 Artwork getArtwork()
          Returns Artwork technology in this database
 CellBackup getCell(CellId cellId)
           
 CellBackup getCell(int cellIndex)
           
 ERectangle getCellBounds(CellId cellId)
           
 ERectangle getCellBounds(int cellIndex)
           
 CellRevision getCellRevision(CellId cellId)
           
 CellRevision getCellRevision(int cellIndex)
           
 java.util.Collection<CellId> getCellsDownTop()
           
 java.util.List<CellId> getChangedCells(Snapshot oldSnapshot)
           
 java.util.List<LibId> getChangedLibraries(Snapshot oldSnapshot)
           
 Generic getGeneric()
          Returns Generic technology in this database
 LibraryBackup getLib(LibId libId)
           
 Schematics getSchematics()
          Returns Schematic technology in this database
 java.util.Map<Setting,java.lang.Object> getSettings()
          Returns map from Setting to its value in this Snapshot
 Technology getTech(TechId techId)
          Get Technology by TechId TechId must belong to same IdManager as TechPool
 TechPool getTechPool()
          Returns TechPool of this Snapshot
static CellName makeCellGroupName(java.util.Collection<CellName> cellNames)
          Returns group name of group with specified CellNames.
static Snapshot readSnapshot(IdReader reader, Snapshot oldSnapshot)
           
 void setCellBounds(CellId cellId, ERectangle r)
          Sets cell bounds for a cell with given CellId
 Snapshot with(Tool tool, Environment environment, CellBackup[] cellBackupsArray, ERectangle[] cellBoundsArray, LibraryBackup[] libBackupsArray)
          Creates a new instance of Snapshot which differs from this Snapshot.
 Snapshot withRenamedIds(IdMapper idMapper, CellId fromGroup, java.lang.String toGroup)
          Returns Snapshot which differs from this Snapshot by renamed Ids.
 void writeDiffs(IdWriter writer, Snapshot oldSnapshot)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

idManager

public final IdManager idManager

snapshotId

public final int snapshotId

tool

public final Tool tool

cellBackups

public final ImmutableArrayList<CellBackup> cellBackups

cellGroups

public final int[] cellGroups

groupMainSchematics

public final CellId[] groupMainSchematics

libBackups

public final ImmutableArrayList<LibraryBackup> libBackups

environment

public final Environment environment

techPool

public final TechPool techPool
Constructor Detail

Snapshot

public Snapshot(IdManager idManager)
Creates empty snapshot.

Method Detail

with

public Snapshot with(Tool tool,
                     Environment environment,
                     CellBackup[] cellBackupsArray,
                     ERectangle[] cellBoundsArray,
                     LibraryBackup[] libBackupsArray)
Creates a new instance of Snapshot which differs from this Snapshot. Four array parameters are supplied. Each parameter may be null if its contents is the same as in this Snapshot.

Parameters:
tool - Tool which initiated database changes.
environment - Environment of this Snapshot
cellBackupsArray - array indexed by cellIndex of new CellBackups.
cellBoundsArray - array indexed by cellIndex of cell bounds.
libBackupsArray - array indexed by libIndex of LibraryBackups.
Returns:
new snapshot which differs froms this Snapshot or this Snapshot.
Throws:
java.lang.IllegalArgumentException - on invariant violation.
ArrayOutOfBoundsException - on some invariant violations.

setCellBounds

public void setCellBounds(CellId cellId,
                          ERectangle r)
Sets cell bounds for a cell with given CellId

Parameters:
cellId - given CellId
r - cell boubds
Throws:
java.lang.IllegalArgumentException - if snapshot has not cell with given cellId or on bounds conflict.

withRenamedIds

public Snapshot withRenamedIds(IdMapper idMapper,
                               CellId fromGroup,
                               java.lang.String toGroup)
Returns Snapshot which differs from this Snapshot by renamed Ids.

Parameters:
idMapper - a map from old Ids to new Ids.
Returns:
Snapshot with renamed Ids.

getChangedLibraries

public java.util.List<LibId> getChangedLibraries(Snapshot oldSnapshot)

getChangedCells

public java.util.List<CellId> getChangedCells(Snapshot oldSnapshot)

getCellsDownTop

public java.util.Collection<CellId> getCellsDownTop()

getCell

public CellBackup getCell(CellId cellId)

getCellRevision

public CellRevision getCellRevision(CellId cellId)

getCell

public CellBackup getCell(int cellIndex)

getCellRevision

public CellRevision getCellRevision(int cellIndex)

makeCellGroupName

public static CellName makeCellGroupName(java.util.Collection<CellName> cellNames)
Returns group name of group with specified CellNames. Name of cell group is a base name of main schematics cell if any. Otherwise it is a shortest base name among cells in the group.

Parameters:
cellNames - collection of CellNames in a group.
Returns:
name of cell group.
Throws:
InvalidArgumentException - if cellNames is empty

getCellBounds

public ERectangle getCellBounds(CellId cellId)

getCellBounds

public ERectangle getCellBounds(int cellIndex)

getTechPool

public TechPool getTechPool()
Returns TechPool of this Snapshot


getTech

public Technology getTech(TechId techId)
Get Technology by TechId TechId must belong to same IdManager as TechPool

Parameters:
techId - TechId to find
Returns:
Technology b giben TechId or null
Throws:
java.lang.IllegalArgumentException - of TechId is not from this IdManager

getArtwork

public Artwork getArtwork()
Returns Artwork technology in this database


getGeneric

public Generic getGeneric()
Returns Generic technology in this database


getSchematics

public Schematics getSchematics()
Returns Schematic technology in this database


getSettings

public java.util.Map<Setting,java.lang.Object> getSettings()
Returns map from Setting to its value in this Snapshot


getLib

public LibraryBackup getLib(LibId libId)

writeDiffs

public void writeDiffs(IdWriter writer,
                       Snapshot oldSnapshot)
                throws java.io.IOException
Throws:
java.io.IOException

readSnapshot

public static Snapshot readSnapshot(IdReader reader,
                                    Snapshot oldSnapshot)
                             throws java.io.IOException
Throws:
java.io.IOException

cellBoundsDefined

public boolean cellBoundsDefined()
Checks if all cell bounds are defined.

Returns:
true if all cell bounds are defined.

check

public void check()
Checks invariant of this Snapshot.

Throws:
java.lang.IllegalArgumentException - on invariant violation.
ArrayOutOfBoundsException - on some invariant violations.
java.lang.AssertionError - if invariant is broken.
java.lang.AssertionError - if invariant is broken.