|
Gridarta Editor
|
Maintains a MapsIndex for the maps directory. More...
Inheritance diagram for net.sf.gridarta.model.index.MapsIndexer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:
Collaboration diagram for net.sf.gridarta.model.index.MapsIndexer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:Classes | |
| enum | State |
| Indexer states. More... | |
Public Member Functions | |
| MapsIndexer (@NotNull final MapsIndex mapsIndex, @NotNull final MapManager< G, A, R > mapManager, @NotNull final ProjectSettings projectSettings) | |
| Creates a new instance. More... | |
| void | start () |
| Starts indexing. More... | |
| void | stop () throws InterruptedException |
| Stops indexing. More... | |
| void | waitForIdle () throws InterruptedException |
| Blocks the calling thread until all pending maps have been indexed. More... | |
Private Member Functions | |
| void | indexPendingMaps () |
| Indexes one pending map from mapsIndex. More... | |
| void | loadMapsIndex () |
| Loads mapsIndex from its cache file. More... | |
| void | reportStateChange () |
| Logs a changed value of state. More... | |
| void | saveMapsIndex () |
| Saves mapsIndex to its cache file if modified. More... | |
| void | scanMapsDirectoryInt (@NotNull final MapFile dir, @NotNull final String mapPath) |
| Scans a directory for files. More... | |
| void | setState (@NotNull final State state) |
| Sets a new value to state. More... | |
| void | updateMapsDirectory () |
| Checks whether newMapsDirectory has been set and updates mapsDirectory accordingly. More... | |
Static Private Member Functions | |
| static File | getCacheFile (@NotNull final File mapsDirectory) |
| Returns the cache file for a given maps directory. More... | |
Private Attributes | |
| final IndexListener< MapFile > | indexListener |
| The IndexListener attached to mapsIndex to detect newly added pending maps. More... | |
| final MapControlListener< G, A, R > | mapControlListener |
| The MapControlListener attached to all opened maps. More... | |
| final MapManager< G, A, R > | mapManager |
| The MapManager for loading map files. More... | |
| final MapManagerListener< G, A, R > | mapManagerListener |
| The MapManagerListener attached to mapManager to detect current map changes. More... | |
| File | mapsDirectory |
| The currently indexed maps directory. More... | |
| final MapsIndex | mapsIndex |
| The MapsIndex being updated. More... | |
| final Semaphore | mapsIndexSemaphore = new Semaphore(1) |
| A pending map may exist in mapsIndex if a permit is available. More... | |
| File | newMapsDirectory |
| The maps directory to index. More... | |
| final ProjectSettings | projectSettings |
| The ProjectSettings instance. More... | |
| final ProjectSettingsListener | projectSettingsListener |
| The ProjectSettingsListener attached to projectSettings for tracking changed maps directories. More... | |
| final Runnable | runnable |
| The Runnable scanning the maps directory and updating the index. More... | |
| State | state = State.INIT |
| The indexer state. More... | |
| final Object | syncMapsDirectory = new Object() |
| The object for synchronizing access to mapsDirectory and newMapsDirectory. More... | |
| final Object | syncState = new Object() |
| The object for synchronizing access to state. More... | |
| final Thread | thread = new Thread(runnable, "indexer") |
| The Thread executing runnable. More... | |
Static Private Attributes | |
| static final Category | LOG = Logger.getLogger(MapsIndexer.class) |
| The Logger for printing log messages. More... | |
Maintains a MapsIndex for the maps directory.
Changed maps are tracked and the index is updated.
Definition at line 57 of file MapsIndexer.java.
| net.sf.gridarta.model.index.MapsIndexer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.MapsIndexer | ( | @NotNull final MapsIndex | mapsIndex, |
| @NotNull final MapManager< G, A, R > | mapManager, | ||
| @NotNull final ProjectSettings | projectSettings | ||
| ) |
Creates a new instance.
| mapsIndex | the maps index to update |
| mapManager | the map manager for loading map files |
| projectSettings | the project settings instance; defines the indexed maps directory |
Definition at line 285 of file MapsIndexer.java.
|
staticprivate |
Returns the cache file for a given maps directory.
| mapsDirectory | the maps directory |
Definition at line 490 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexer< G, A, R >.loadMapsIndex(), and net.sf.gridarta.model.index.MapsIndexer< G, A, R >.saveMapsIndex().
Here is the caller graph for this function:
|
private |
Indexes one pending map from mapsIndex.
Does nothing if no pending map exists.
Definition at line 455 of file MapsIndexer.java.
|
private |
Loads mapsIndex from its cache file.
Definition at line 406 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexer< G, A, R >.updateMapsDirectory().
Here is the caller graph for this function:
|
private |
Logs a changed value of state.
Definition at line 547 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexer< G, A, R >.MapsIndexer(), and net.sf.gridarta.model.index.MapsIndexer< G, A, R >.setState().
Here is the caller graph for this function:
|
private |
Saves mapsIndex to its cache file if modified.
Definition at line 373 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexer< G, A, R >.stop(), and net.sf.gridarta.model.index.MapsIndexer< G, A, R >.updateMapsDirectory().
Here is the caller graph for this function:
|
private |
Scans a directory for files.
Adds all files found to mapsIndex.
| dir | the directory to scan |
| mapPath | the map path corresponding to dir |
Definition at line 435 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexer< G, A, R >.scanMapsDirectoryInt(), and net.sf.gridarta.model.index.MapsIndexer< G, A, R >.updateMapsDirectory().
Here is the caller graph for this function:
|
private |
Sets a new value to state.
Logs changed values.
| state | the new state |
Definition at line 532 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexer< G, A, R >.indexPendingMaps(), and net.sf.gridarta.model.index.MapsIndexer< G, A, R >.updateMapsDirectory().
Here is the caller graph for this function:| void net.sf.gridarta.model.index.MapsIndexer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.start | ( | ) |
Starts indexing.
Must not be called more than once.
Definition at line 295 of file MapsIndexer.java.
Referenced by net.sf.gridarta.gui.dialog.gomap.GoMapDialogManager< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.GoMapDialogManager(), net.sf.gridarta.model.index.MapsIndexerTest.test1(), and net.sf.gridarta.model.index.MapsIndexerTest.test2().
Here is the caller graph for this function:| void net.sf.gridarta.model.index.MapsIndexer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.stop | ( | ) | throws InterruptedException |
Stops indexing.
Must not be called more than once or before start() has been called.
| InterruptedException | if the current thread was interrupted |
Definition at line 310 of file MapsIndexer.java.
Referenced by net.sf.gridarta.gui.dialog.gomap.GoMapDialogManager< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.GoMapDialogManager(), and net.sf.gridarta.model.index.MapsIndexerTest.test1().
Here is the caller graph for this function:
|
private |
Checks whether newMapsDirectory has been set and updates mapsDirectory accordingly.
Definition at line 347 of file MapsIndexer.java.
| void net.sf.gridarta.model.index.MapsIndexer< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.waitForIdle | ( | ) | throws InterruptedException |
Blocks the calling thread until all pending maps have been indexed.
| InterruptedException | if the current thread was interrupted during wait |
Definition at line 335 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexerTest.test1(), and net.sf.gridarta.model.index.MapsIndexerTest.test2().
Here is the caller graph for this function:
|
private |
The IndexListener attached to mapsIndex to detect newly added pending maps.
Definition at line 219 of file MapsIndexer.java.
|
staticprivate |
The Logger for printing log messages.
Definition at line 63 of file MapsIndexer.java.
|
private |
The MapControlListener attached to all opened maps.
Definition at line 186 of file MapsIndexer.java.
|
private |
The MapManager for loading map files.
Definition at line 81 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexer< G, A, R >.MapsIndexer().
|
private |
The MapManagerListener attached to mapManager to detect current map changes.
Definition at line 154 of file MapsIndexer.java.
|
private |
The currently indexed maps directory.
Definition at line 100 of file MapsIndexer.java.
|
private |
The MapsIndex being updated.
Definition at line 75 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexer< G, A, R >.MapsIndexer().
|
private |
A pending map may exist in mapsIndex if a permit is available.
Definition at line 69 of file MapsIndexer.java.
|
private |
The maps directory to index.
If
, mapsDirectory is valid.
Definition at line 107 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexer< G, A, R >.updateMapsDirectory().
|
private |
The ProjectSettings instance.
Definition at line 87 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexer< G, A, R >.MapsIndexer().
|
private |
The ProjectSettingsListener attached to projectSettings for tracking changed maps directories.
Definition at line 203 of file MapsIndexer.java.
|
private |
The Runnable scanning the maps directory and updating the index.
Definition at line 252 of file MapsIndexer.java.
|
private |
The indexer state.
Definition at line 119 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexer< G, A, R >.setState().
|
private |
The object for synchronizing access to mapsDirectory and newMapsDirectory.
Definition at line 94 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexer< G, A, R >.start(), net.sf.gridarta.model.index.MapsIndexer< G, A, R >.stop(), and net.sf.gridarta.model.index.MapsIndexer< G, A, R >.updateMapsDirectory().
|
private |
The object for synchronizing access to state.
Definition at line 113 of file MapsIndexer.java.
Referenced by net.sf.gridarta.model.index.MapsIndexer< G, A, R >.setState(), and net.sf.gridarta.model.index.MapsIndexer< G, A, R >.waitForIdle().
|
private |
The Thread executing runnable.
Definition at line 276 of file MapsIndexer.java.