module Simulation.Aivika.Experiment.Base.FileRenderer where
import Control.Monad
import Control.Monad.Trans
import System.Directory
import System.FilePath
import Simulation.Aivika.Trans.Exception
import Simulation.Aivika.Experiment.Types
import Simulation.Aivika.Experiment.Base.ExperimentWriter
data FileRenderer a = FileRenderer a ExperimentFilePath
type FileGenerator a = ExperimentGenerator (FileRenderer a)
instance ExperimentRendering (FileRenderer a) where
data ExperimentContext (FileRenderer a) = FileContext
type ExperimentEnvironment (FileRenderer a) = FilePath
type ExperimentMonad (FileRenderer a) = ExperimentWriter
liftExperiment r = runExperimentWriter
prepareExperiment e (FileRenderer _ path0) =
do path <- resolveFilePath "" path0
liftIO $ do
when (experimentVerbose e) $
do putStr "Updating directory "
putStrLn path
createDirectoryIfMissing True path
return path
renderExperiment e r reporters path = return ()
onExperimentCompleted e r path = return ()
onExperimentFailed e r path e' = throwComp e'