GraphTypes.hs revision 331603b37dec12e37e2e1df9634ef0f2c5c73ddf
9658657e918981d91c8647ed8c220464f10a6235Christian MaederModule : $Header$
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederDescription : Types for the Central GUI of Hets
e6d40133bc9f858308654afb1262b8b483ec5922Till MossakowskiCopyright : (c) Jorina Freya Gerken, Till Mossakowski, Uni Bremen 2002-2006
d5fe06af711a6912ae028ebf873eada4ee8733f8Christian MaederLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederMaintainer : till@informatik.uni-bremen.de
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederStability : provisional
b53688bfed888214b485cf76439d57262d80e0a7Christian MaederPortability : non-portable (imports Logic)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder , ConversionMaps(..)
a7a43d265fef55ddfd7c4412cd96c621ef9738ffChristian Maeder , DGraphAndAGraphNode
a7a43d265fef55ddfd7c4412cd96c621ef9738ffChristian Maeder , DGraphAndAGraphEdge
a7a43d265fef55ddfd7c4412cd96c621ef9738ffChristian Maeder , InternalNames(..)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder , DaVinciGraphTypeSyn
ae35311385999d91f812155fe99439724d54063bChristian Maeder , emptyConversionMaps
9e6789e67e329416d7f3acf0e7b8367b8dea991bnotanartist , tryLockGlobal
50a3afe91cef447a03d579976c179dc266290c93Christian Maeder , unlockGlobal
eaa88a5cefdc814e61039c5dcc1bffc324a2f93eChristian Maederimport GUI.AbstractGraphView(Descr, GraphInfo, initgraphs)
697e63e30aa3c309a1ef1f9357745111f8dfc5a9Christian Maederimport Common.Id(nullRange)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederimport Common.Doc(text, ($+$))
8e537a087207fb2ea9073ea66776c36b821a58c6Christian Maederimport Common.DocUtils(Pretty, pretty)
9e6789e67e329416d7f3acf0e7b8367b8dea991bnotanartistimport qualified Common.InjMap as InjMap
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederimport Driver.Options(HetcatsOpts, defaultHetcatsOpts)
46b1095ba983ce859e17c2a12f48b50583b7150cChristian Maederimport DaVinciGraph
411392046c2ba1752cde81eaa92a95a2c28b672dChristian Maederimport GraphDisp
f527d5da7cd679c1a9b50a4906a0c12d395a6087Christian Maeder{- Maps used to track which node resp edge of the abstract graph
9175e29c044318498a40f323f189f9dfd50378efChristian Maedercorrespondes with which of the development graph and vice versa and
9175e29c044318498a40f323f189f9dfd50378efChristian Maederone Map to store which libname belongs to which development graph-}
eaa88a5cefdc814e61039c5dcc1bffc324a2f93eChristian Maederdata ConversionMaps = ConversionMaps
eaa88a5cefdc814e61039c5dcc1bffc324a2f93eChristian Maeder { dgAndabstrNode :: DGraphAndAGraphNode
eaa88a5cefdc814e61039c5dcc1bffc324a2f93eChristian Maeder , dgAndabstrEdge :: DGraphAndAGraphEdge
eaa88a5cefdc814e61039c5dcc1bffc324a2f93eChristian Maeder } deriving Show
eaa88a5cefdc814e61039c5dcc1bffc324a2f93eChristian Maeder-- | Pretty instance for ConversionMaps
eaa88a5cefdc814e61039c5dcc1bffc324a2f93eChristian Maederinstance Pretty ConversionMaps where
eaa88a5cefdc814e61039c5dcc1bffc324a2f93eChristian Maeder pretty convMaps =
eaa88a5cefdc814e61039c5dcc1bffc324a2f93eChristian Maeder text "dg2abstrNode"
46b207daf66b64930a59f3615c8b127aac0b8e43Christian Maeder $+$ pretty (InjMap.getAToB $ dgAndabstrNode convMaps)
024703c9d1326c23e307c0b0d453ed3358e87fe4cmaeder $+$ text "dg2abstrEdge"
46b1095ba983ce859e17c2a12f48b50583b7150cChristian Maeder $+$ pretty (InjMap.getAToB $ dgAndabstrEdge convMaps)
46b1095ba983ce859e17c2a12f48b50583b7150cChristian Maeder $+$ text "abstr2dgNode"
4cc271fa22221d0d20cf303553f86c4e3b1a56e4Christian Maeder $+$ pretty (InjMap.getBToA $ dgAndabstrNode convMaps)
c8a9d35be2207e0d4fbd26a2411e1ba17e3e4c96Christian Maeder $+$ text "abstr2dgEdge"
c2257f94016aeb9e5c3ff3d4d675a81f8f873f0dChristian Maeder $+$ pretty (InjMap.getBToA $ dgAndabstrEdge convMaps)
4cc271fa22221d0d20cf303553f86c4e3b1a56e4Christian Maeder-- | types of the Maps above
3986813db69106b9bb1b62faa77532af42512a0cChristian Maedertype DGraphAndAGraphNode = InjMap.InjMap (LIB_NAME, Node) Descr
596a8e9039bd2f42c09cc0da4a57c8073f96fbddChristian Maedertype DGraphAndAGraphEdge =
596a8e9039bd2f42c09cc0da4a57c8073f96fbddChristian Maeder InjMap.InjMap (LIB_NAME, (Descr, Descr, String)) Descr
eaa88a5cefdc814e61039c5dcc1bffc324a2f93eChristian Maederdata InternalNames =
46b1095ba983ce859e17c2a12f48b50583b7150cChristian Maeder InternalNames { showNames :: Bool
e982190515f83fe6615436530ebe89bb320770d6Christian Maeder , updater :: [(String,(String -> String) -> IO ())]
f04e8f3ff56405901be968fd4c6e9769239f1a9bKlaus Luettich-- | Global datatype for all GUI functions
08d506ebb78da1e8656a73a349492e042f4c9f72Christian Maederdata GInfo = GInfo
46b1095ba983ce859e17c2a12f48b50583b7150cChristian Maeder libEnvIORef :: IORef LibEnv
53a3042e1da2253fd3f103bfef4deb47fc0bf6a6Ewaryst Schulz , gi_hetcatsOpts :: HetcatsOpts
53a3042e1da2253fd3f103bfef4deb47fc0bf6a6Ewaryst Schulz , windowCount :: MVar Integer
53a3042e1da2253fd3f103bfef4deb47fc0bf6a6Ewaryst Schulz , exitMVar :: MVar ()
38824a7dba4f7d82532afec67e0b594a5af5d76bChristian Maeder , globalLock :: MVar ()
38824a7dba4f7d82532afec67e0b594a5af5d76bChristian Maeder , globalHist :: MVar ([[LIB_NAME]],[[LIB_NAME]])
38824a7dba4f7d82532afec67e0b594a5af5d76bChristian Maeder , functionLock :: MVar ()
32607d06fe7826eb0711c19d348ee4e395f2577aChristian Maeder , descrIORef :: IORef Descr
411588cc915b27cef4e7e66fb23e67514b3a0c92Christian Maeder , conversionMapsIORef :: IORef ConversionMaps
9e6789e67e329416d7f3acf0e7b8367b8dea991bnotanartist , graphId :: Descr
411588cc915b27cef4e7e66fb23e67514b3a0c92Christian Maeder , nextGraphId :: IORef Descr
21dbca247d5964daf2c5abd2de2ac1101e3e1ef4Christian Maeder , gi_LIB_NAME :: LIB_NAME
ec351e60425e2f99448cb44e933d3828f8025dddChristian Maeder , gi_GraphInfo :: GraphInfo
56440c7ae61e7277a3494452d0165ee52e677b29Christian Maeder , internalNamesIORef :: IORef InternalNames
e4f0eaffd002e9e553ee113be33f9aa6e4181c43Christian Maeder -- show internal names?
961978c71545e0177683279f8b63358b3e3804b8Christian Maeder , visibleNodesIORef :: IORef [[Node]]
961978c71545e0177683279f8b63358b3e3804b8Christian Maeder , proofGUIMVar :: GUIMVar
3ec3a22fe2b9c38a3575c98a82b4e3f988af64a6Eugen Kuksa{- | Type of the convertGraph function. Used as type of a parameter of some
3ec3a22fe2b9c38a3575c98a82b4e3f988af64a6Eugen Kuksa functions in GraphMenu and GraphLogic. -}
3ec3a22fe2b9c38a3575c98a82b4e3f988af64a6Eugen Kuksatype ConvFunc = GInfo -> String -> LibFunc
4c872eeb600fe8479dbda395405cf13c3d573c24Soeren D. Schulze -> IO (Descr, GraphInfo, ConversionMaps)
64c2422e1ba0691556a6639e959820add102315cChristian Maedertype LibFunc = GInfo -> IO DaVinciGraphTypeSyn
4c8d3c5a9e938633f6147b5a595b9b93bfca99e6Christian Maedertype DaVinciGraphTypeSyn =
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder Graph DaVinciGraph
63da71bfb4226f504944b293fb77177ebcaea7d4Ewaryst Schulz DaVinciGraphParms
f8cc2399c16fcda7e3bf9d901a0de0cc8a455f86Ewaryst Schulz DaVinciNodeType
b83ff3749d99d03b641adee264b781039a551addChristian Maeder DaVinciNodeTypeParms
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder DaVinciArcType
520c5bce318eff52d9315f7c4491c3381a0c4336Christian Maeder DaVinciArcTypeParms
0850c3e5fb6285405ebaeb5aa433985203ac892dEwaryst Schulz-- | Creates empty conversionmaps
bdf2e01977470bedcb4425e2dadabc9e9f6ba149Ewaryst SchulzemptyConversionMaps :: ConversionMaps
bdf2e01977470bedcb4425e2dadabc9e9f6ba149Ewaryst SchulzemptyConversionMaps =
bdf2e01977470bedcb4425e2dadabc9e9f6ba149Ewaryst Schulz ConversionMaps { dgAndabstrNode = InjMap.empty::DGraphAndAGraphNode
0850c3e5fb6285405ebaeb5aa433985203ac892dEwaryst Schulz , dgAndabstrEdge = InjMap.empty::DGraphAndAGraphEdge
0850c3e5fb6285405ebaeb5aa433985203ac892dEwaryst Schulz-- | Creates an empty GInfo
e49fd57c63845c7806860a9736ad09f6d44dbaedChristian MaederemptyGInfo :: IO GInfo
4067eba4f5605d9569d78085deb1a27f08ac34e2Christian MaederemptyGInfo = do
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder iorLE <- newIORef emptyLibEnv
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder iorD <- newIORef (0 :: Descr)
bbba6dd86153aacb0f662b182b128df0eb09fd54Christian Maeder iorNGI <- newIORef (0 :: Descr)
4067eba4f5605d9569d78085deb1a27f08ac34e2Christian Maeder iorCM <- newIORef emptyConversionMaps
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder graphInfo <- initgraphs
a43c1a7fa08c12524415386aa13a566cc9e53a4fChristian Maeder iorIN <- newIORef $ InternalNames False []
034d9e2e9ada5aaa5665180720744d51166dacd4Christian Maeder iorVN <- newIORef ([] :: [[Node]])
024703c9d1326c23e307c0b0d453ed3358e87fe4cmaeder guiMVar <- newEmptyMVar
024703c9d1326c23e307c0b0d453ed3358e87fe4cmaeder gl <- newEmptyMVar
427ff3172ae2dfebe3c8fc972735158999997e8aChristian Maeder fl <- newEmptyMVar
427ff3172ae2dfebe3c8fc972735158999997e8aChristian Maeder exit <- newEmptyMVar
72079df98b3cb7cc1fd82a0a24984893dcd05ecaEwaryst Schulz wc <- newMVar 0
5ca1fe655d7d4e35e59a082b5955b306643329d0Ewaryst Schulz gh <- newMVar ([],[])
5f2c34b8971f9ca7e63364b69e167851d001168eEwaryst Schulz return $ GInfo { libEnvIORef = iorLE
5f2c34b8971f9ca7e63364b69e167851d001168eEwaryst Schulz , descrIORef = iorD
bdf2e01977470bedcb4425e2dadabc9e9f6ba149Ewaryst Schulz , conversionMapsIORef = iorCM
0850c3e5fb6285405ebaeb5aa433985203ac892dEwaryst Schulz , graphId = 0
5f2c34b8971f9ca7e63364b69e167851d001168eEwaryst Schulz , nextGraphId = iorNGI
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder , gi_LIB_NAME = Lib_id $ Indirect_link "" nullRange "" noTime
4d54e7814b18ce142359c92a5868e6dcff9219b5Christian Maeder , gi_GraphInfo = graphInfo
ce900a84ed9d9882c64fccbd6300f6b0d67efa82Christian Maeder , internalNamesIORef = iorIN
48a98aa04f4c2c1f5f8f79c007e1ff95e699b31aFlorian Mossakowski , gi_hetcatsOpts = defaultHetcatsOpts
aad8b6ac810a08fca14ce0fbbf324fcce5305ad6Christian Maeder , visibleNodesIORef = iorVN
4067eba4f5605d9569d78085deb1a27f08ac34e2Christian Maeder , proofGUIMVar = guiMVar
aad8b6ac810a08fca14ce0fbbf324fcce5305ad6Christian Maeder , windowCount = wc
53e165a53dfa59f717588d1f8236c9a763826525Christian Maeder , exitMVar = exit
53e165a53dfa59f717588d1f8236c9a763826525Christian Maeder , globalLock = gl
1937dccb04b363364f7a7de17fdaae1d70583af9Christian Maeder , globalHist = gh
aad8b6ac810a08fca14ce0fbbf324fcce5305ad6Christian Maeder , functionLock = fl
4067eba4f5605d9569d78085deb1a27f08ac34e2Christian Maeder-- | Creates an empty GInfo
08d506ebb78da1e8656a73a349492e042f4c9f72Christian MaedercopyGInfo :: GInfo -> IO GInfo
08d506ebb78da1e8656a73a349492e042f4c9f72Christian MaedercopyGInfo gInfo = do
d27d203b3f42f0e0ecea00e3f19f55f66045bd96Christian Maeder iorD <- newIORef (0 :: Descr)
d27d203b3f42f0e0ecea00e3f19f55f66045bd96Christian Maeder iorNGI <- newIORef (0 :: Descr)
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder iorCM <- newIORef emptyConversionMaps
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder graphInfo <- initgraphs
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder iorIN <- newIORef $ InternalNames False []
4067eba4f5605d9569d78085deb1a27f08ac34e2Christian Maeder iorVN <- newIORef ([] :: [[Node]])
074f8feaf71e0b71a95145e7439746f8eb8e2a7cChristian Maeder guiMVar <- newEmptyMVar
c1d06b3018b34ede2b3fb6c7fe2ad28cd5ce5b68Christian Maeder return $ gInfo { descrIORef = iorD
53a3042e1da2253fd3f103bfef4deb47fc0bf6a6Ewaryst Schulz , conversionMapsIORef = iorCM
53a3042e1da2253fd3f103bfef4deb47fc0bf6a6Ewaryst Schulz , graphId = 0
53a3042e1da2253fd3f103bfef4deb47fc0bf6a6Ewaryst Schulz , nextGraphId = iorNGI
53a3042e1da2253fd3f103bfef4deb47fc0bf6a6Ewaryst Schulz , gi_LIB_NAME = Lib_id $ Indirect_link "" nullRange "" noTime
ea8e98e298f33f9362293f392c8fb192722b8904Eugen Kuksa , gi_GraphInfo = graphInfo
ab9b86500ed66416e1a7c01be54491ed72c7d633Christian Maeder , internalNamesIORef = iorIN
e6ac593966607b1da5b619e0f9492d37820eed74Christian Maeder , visibleNodesIORef = iorVN
f6b2c6c33c635279973b8f378470da7dbb8ecee8Christian Maeder , proofGUIMVar = guiMVar
f6b2c6c33c635279973b8f378470da7dbb8ecee8Christian Maeder{- | Acquire the global lock. If already locked it waits till it is unlocked
f6b2c6c33c635279973b8f378470da7dbb8ecee8Christian MaederlockGlobal :: GInfo -> IO ()
63719301448519453f66383f4e583d9fd5b89ecbChristian MaederlockGlobal (GInfo { globalLock = lock }) = putMVar lock ()
e6ac593966607b1da5b619e0f9492d37820eed74Christian Maeder-- | Tries to acquire the global lock. Return False if already acquired.
11c3a215d5cf043181e83929f1ce214df65cb587Christian MaedertryLockGlobal :: GInfo -> IO Bool
e6ac593966607b1da5b619e0f9492d37820eed74Christian MaedertryLockGlobal (GInfo { globalLock = lock }) = tryPutMVar lock ()
ab9b86500ed66416e1a7c01be54491ed72c7d633Christian Maeder-- | Releases the global lock.
ab9b86500ed66416e1a7c01be54491ed72c7d633Christian MaederunlockGlobal :: GInfo -> IO ()
ab9b86500ed66416e1a7c01be54491ed72c7d633Christian MaederunlockGlobal (GInfo { globalLock = lock }) = do
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder unlocked <- tryTakeMVar lock
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder case unlocked of
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder Just () -> return ()
63719301448519453f66383f4e583d9fd5b89ecbChristian Maeder Nothing -> error "Global lock wasn't locked."