Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 4, 2013, 10:47:26 PM (12 years ago)
Author:
landauf
Message:

small refactoring: un-singletonized ConsoleWriter, LogWriter, and MemoryWriter - instead the instances are now kept by OutputManager

Location:
code/branches/testing/src/libraries/util/output
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/testing/src/libraries/util/output/ConsoleWriter.cc

    r9531 r9536  
    6666
    6767    /**
    68         @brief Returns the only existing instance of this class.
    69     */
    70     /*static*/ ConsoleWriter& ConsoleWriter::getInstance()
    71     {
    72         static ConsoleWriter instance;
    73         return instance;
    74     }
    75 
    76     /**
    7768        @brief Inherited function from BaseWriter, writes output to the console using std::cout.
    7869    */
  • code/branches/testing/src/libraries/util/output/ConsoleWriter.h

    r9535 r9536  
    5454            virtual ~ConsoleWriter();
    5555
    56             static ConsoleWriter& getInstance();
    57 
    5856            void enable();
    5957            void disable();
  • code/branches/testing/src/libraries/util/output/LogWriter.cc

    r8858 r9536  
    7676
    7777    /**
    78         @brief Returns the only existing instance of this class.
    79     */
    80     /*static*/ LogWriter& LogWriter::getInstance()
    81     {
    82         static LogWriter instance;
    83         return instance;
    84     }
    85 
    86     /**
    8778        @brief Opens the log-file in order to write output to it.
    8879    */
     
    133124
    134125        // request old output from MemoryWriter
    135         MemoryWriter::getInstance().resendOutput(this);
     126        OutputManager::getInstance().getMemoryWriter().resendOutput(this);
    136127    }
    137128
  • code/branches/testing/src/libraries/util/output/LogWriter.h

    r9535 r9536  
    6161            virtual ~LogWriter();
    6262
    63             static LogWriter& getInstance();
    64 
    6563            void setLogPath(const std::string& path);
    6664
  • code/branches/testing/src/libraries/util/output/MemoryWriter.cc

    r8858 r9536  
    5353
    5454    /**
    55         @brief Returns the only existing instance of this singleton class.
    56     */
    57     /*static*/ MemoryWriter& MemoryWriter::getInstance()
    58     {
    59         static MemoryWriter instance;
    60         return instance;
    61     }
    62 
    63     /**
    6455        @brief Implementation of the output() function inherited from OutputListener, stores the received output in memory.
    6556    */
  • code/branches/testing/src/libraries/util/output/MemoryWriter.h

    r9535 r9536  
    7171            virtual ~MemoryWriter();
    7272
    73             static MemoryWriter& getInstance();
    74 
    7573            void resendOutput(OutputListener* listener) const;
    7674            void disable();
  • code/branches/testing/src/libraries/util/output/OutputManager.cc

    r9533 r9536  
    8888        static OutputManager& instance = OutputManager::getInstance();
    8989
    90         static MemoryWriter& memoryWriterInstance = MemoryWriter::getInstance(); (void)memoryWriterInstance;
    91         static ConsoleWriter& consoleWriterInstance = ConsoleWriter::getInstance(); (void)consoleWriterInstance;
    92         static LogWriter& logWriterInstance = LogWriter::getInstance(); (void)logWriterInstance;
    93 
     90        static MemoryWriter& memoryWriterInstance = OutputManager::getInstance().getMemoryWriter(); (void)memoryWriterInstance;
     91        static ConsoleWriter& consoleWriterInstance = OutputManager::getInstance().getConsoleWriter(); (void)consoleWriterInstance;
     92        static LogWriter& logWriterInstance = OutputManager::getInstance().getLogWriter(); (void)logWriterInstance;
     93
     94        return instance;
     95    }
     96
     97    /**
     98     * @brief Returns the main instance of MemoryWriter which is managed by the OutputManager singleton.
     99     * @note If OutputManager is ever un-singletonized, this instance must not remain static.
     100     */
     101    MemoryWriter& OutputManager::getMemoryWriter()
     102    {
     103        static MemoryWriter instance;
     104        return instance;
     105    }
     106
     107    /**
     108     * @brief Returns the main instance of ConsoleWriter which is managed by the OutputManager singleton.
     109     * @note If OutputManager is ever un-singletonized, this instance must not remain static.
     110     */
     111    ConsoleWriter& OutputManager::getConsoleWriter()
     112    {
     113        static ConsoleWriter instance;
     114        return instance;
     115    }
     116
     117    /**
     118     * @brief Returns the main instance of LogWriter which is managed by the OutputManager singleton.
     119     * @note If OutputManager is ever un-singletonized, this instance must not remain static.
     120     */
     121    LogWriter& OutputManager::getLogWriter()
     122    {
     123        static LogWriter instance;
    94124        return instance;
    95125    }
  • code/branches/testing/src/libraries/util/output/OutputManager.h

    r9535 r9536  
    7272            static OutputManager& getInstanceAndCreateListeners();
    7373
     74            MemoryWriter& getMemoryWriter();
     75            ConsoleWriter& getConsoleWriter();
     76            LogWriter& getLogWriter();
     77
    7478            void pushMessage(OutputLevel level, const OutputContextContainer& context, const std::string& message);
    7579
Note: See TracChangeset for help on using the changeset viewer.