001 package nl.cwi.sen1.visplugin; 002 003 import nl.cwi.sen1.relationstores.Factory; 004 import aterm.pure.PureFactory; 005 006 /** 007 * A Singleton class to share a single factory instance. 008 * @author A. Belgraver 009 * @author R. van Remortel 010 * @date 20-2-2007 011 */ 012 public class VisualizationFactorySingleton { 013 014 private static Factory m_factory = null; 015 private static PureFactory m_pureFactory = null; 016 017 /** 018 * Get the factory instance. 019 * @author A. Belgraver 020 * @author R. van Remortel 021 * @return a new Factory (if none is present) 022 * @date 20-2-2007 023 */ 024 public static Factory getFactoryInstance() { 025 createInstances(); 026 return m_factory; 027 } 028 029 /** 030 * Get the factory instance. 031 * @author A. Belgraver 032 * @author R. van Remortel 033 * @return a new Factory (if none is present) 034 * @date 20-2-2007 035 */ 036 public static PureFactory getPureFactoryInstance() { 037 createInstances(); 038 return m_pureFactory; 039 } 040 041 /** 042 * Allows for initialization of the factories with the factories given by 043 * the MetaStudio. 044 * 045 * @param pureFactory Pure factory. 046 * @param factory RStore factory. 047 * 048 * @author Arend van Beelen 049 * @date 13-03-2007 050 */ 051 public static void initInstances(PureFactory pureFactory, Factory factory) { 052 m_pureFactory = pureFactory; 053 m_factory = factory; 054 } 055 056 private static void createInstances() { 057 if (m_factory == null) { 058 m_pureFactory = new PureFactory(); 059 m_factory = Factory.getInstance(m_pureFactory); 060 } 061 } 062 063 }