- /*
- * ===========================================================================
- * PRODUCTION $Log: message_history.hpp,v $
- * PRODUCTION Revision 1000.1 2004/04/12 18:12:30 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.4
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_PLUGIN_MESSAGEHISTORY_HPP
- #define GUI_PLUGIN_MESSAGEHISTORY_HPP
- /* $Id: message_history.hpp,v 1000.1 2004/04/12 18:12:30 gouriano Exp $
- * ===========================================================================
- *
- * PUBLIC DOMAIN NOTICE
- * National Center for Biotechnology Information
- *
- * This software/database is a "United States Government Work" under the
- * terms of the United States Copyright Act. It was written as part of
- * the author's official duties as a United States Government employee and
- * thus cannot be copyrighted. This software/database is freely available
- * to the public for use. The National Library of Medicine and the U.S.
- * Government have not placed any restriction on its use or reproduction.
- *
- * Although all reasonable efforts have been taken to ensure the accuracy
- * and reliability of the software and data, the NLM and the U.S.
- * Government do not and cannot warrant the performance or results that
- * may be obtained by using this software or data. The NLM and the U.S.
- * Government disclaim all warranties, express or implied, including
- * warranties of performance, merchantability or fitness for any particular
- * purpose.
- *
- * Please cite the author in any work or product based on this material.
- *
- * ===========================================================================
- *
- * File Description:
- * This files contain definitions for plugin messages history.
- *
- * ===========================================================================
- */
- #include <corelib/ncbistd.hpp>
- #include <corelib/ncbiobj.hpp>
- #include <gui/plugin/PluginMessage.hpp>
- #include <gui/plugin/MessageHistoryInfo.hpp>
- #include <vector>
- BEGIN_NCBI_SCOPE
- // forward declarations
- class CPluginMessageHistory_CI;
- //======================= CPluginMessageHistory ===========================
- /*
- * NOTE: Messages can be ordered by the time they were entered into the
- * message queue which result in a linear data structure.
- * It can also be as a 'forest' where messages points to messages they
- * initiated (a tree stucture).
- * Though the underlying data structures supporst both views, currently
- * we support only the linear view at the user level.
- */
- class NCBI_XGBPLUGIN_EXPORT CPluginMessageHistory
- {
- public:
- // access
- static CPluginMessageHistory& Instance(void);
- // destructor
- virtual ~CPluginMessageHistory(void);
- // types
- typedef objects::CMessageHistoryInfo TInfo;
- typedef CPluginMessageHistory_CI const_iterator;
- // clear the current history
- void Clear();
- // Add message to history list
- void AddMessage(const objects::CPluginMessage&);
- // Returns the number of message in the history repository
- SIZE_TYPE Size(void) const;
- const TInfo& operator[](size_t) const;
- // iterator
- const_iterator begin(void) const;
- const_iterator end(void) const;
- private:
- friend class CPluginMessageHistory_CI;
- class CMessageHistoryEntry
- {
- public:
- // constructor
- CMessageHistoryEntry(const objects::CPluginMessage&);
- // destructor
- ~CMessageHistoryEntry(void);
- // copy constructor
- CMessageHistoryEntry(const CMessageHistoryEntry&);
- // assignment operator
- CMessageHistoryEntry& operator=(const CMessageHistoryEntry&);
- // types
- typedef objects::CMessageHistoryInfo TInfo;
- typedef size_t TPredecessor;
- typedef vector<size_t> TSuccessors;
- // typedef CMessageHistoryInfo TInfo
- const TInfo& GetInfo(void) const;
- // typedef size_t TPredecessor
- TPredecessor GetPredecessor(void) const;
- void SetPredecessor(const TPredecessor& value);
- // typedef vector< int > TSuccessors
- const TSuccessors& GetSuccessors(void) const;
- void AddSuccessor(size_t);
- private:
- // data
- TInfo m_Info;
- TPredecessor m_Predecessor;
- TSuccessors m_Successors;
- };
- // constructor
- CPluginMessageHistory(void);
- // Prohibit copy constructor and assignment operator
- CPluginMessageHistory(const CPluginMessageHistory&);
- CPluginMessageHistory& operator=(const CPluginMessageHistory&);
- // private types
- typedef vector< CMessageHistoryEntry > TEntries;
- // data
- static auto_ptr<CPluginMessageHistory> sm_Instance;
- TEntries m_Entries;
- };
- //====================== CPluginMessageHistory_CI ==========================
- class NCBI_XGBPLUGIN_EXPORT CPluginMessageHistory_CI
- {
- public:
- // types
- typedef CPluginMessageHistory::TInfo TInfo;
- typedef CPluginMessageHistory::TEntries TEntries;
- // copy constructor
- CPluginMessageHistory_CI(const CPluginMessageHistory_CI&);
- // assignment operator
- CPluginMessageHistory_CI& operator=(const CPluginMessageHistory_CI&);
- // increment & decrement operators
- CPluginMessageHistory_CI& operator++(void);
- CPluginMessageHistory_CI& operator--(void);
- // dereferencing
- const TInfo& operator*(void) const;
- const TInfo* operator->(void) const;
- // comparison
- bool operator==(const CPluginMessageHistory_CI& other);
- bool operator!=(const CPluginMessageHistory_CI& other);
- private:
- friend CPluginMessageHistory_CI CPluginMessageHistory::begin(void) const;
- friend CPluginMessageHistory_CI CPluginMessageHistory::end(void) const;
- // constructors
- CPluginMessageHistory_CI(void);
- CPluginMessageHistory_CI(CPluginMessageHistory::TEntries::const_iterator);
- const CPluginMessageHistory_CI operator++(int);
- const CPluginMessageHistory_CI operator--(int);
- // data
- CPluginMessageHistory::TEntries::const_iterator m_Iterator;
- };
- ///////////////////////////////////////////////////////////
- ///////////////////// inline methods //////////////////////
- ///////////////////////////////////////////////////////////
- //=============== CPluginMessageHistory =================
- inline
- SIZE_TYPE CPluginMessageHistory::Size(void) const
- {
- return m_Entries.size();
- }
- inline
- const objects::CMessageHistoryInfo&
- CPluginMessageHistory::operator[](size_t index) const
- {
- return m_Entries[index].GetInfo();
- }
- //============= CPluginMessageHistory_CI ================
- inline
- CPluginMessageHistory_CI::CPluginMessageHistory_CI(void)
- {
- }
- inline
- CPluginMessageHistory_CI::CPluginMessageHistory_CI
- (const CPluginMessageHistory_CI& other)
- {
- *this = other;
- }
- inline
- CPluginMessageHistory_CI& CPluginMessageHistory_CI::operator=
- (const CPluginMessageHistory_CI& other)
- {
- if ( this != &other ) {
- m_Iterator = other.m_Iterator;
- }
- return *this;
- }
- inline
- CPluginMessageHistory_CI::CPluginMessageHistory_CI
- (CPluginMessageHistory::TEntries::const_iterator iter)
- {
- m_Iterator = iter;
- }
- inline
- CPluginMessageHistory_CI& CPluginMessageHistory_CI::operator++(void)
- {
- ++m_Iterator;
- return *this;
- }
- inline
- CPluginMessageHistory_CI& CPluginMessageHistory_CI::operator--(void)
- {
- --m_Iterator;
- return *this;
- }
- inline
- const CPluginMessageHistory_CI::TInfo& CPluginMessageHistory_CI::operator*(void) const
- {
- return m_Iterator->GetInfo();
- }
- inline
- const CPluginMessageHistory_CI::TInfo* CPluginMessageHistory_CI::operator->(void) const
- {
- return &(m_Iterator->GetInfo());
- }
- inline
- bool CPluginMessageHistory_CI::operator==(const CPluginMessageHistory_CI& other)
- {
- return m_Iterator == other.m_Iterator;
- }
- inline
- bool CPluginMessageHistory_CI::operator!=(const CPluginMessageHistory_CI& other)
- {
- return !(*this == other);
- }
- ///////////////////////////////////////////////////////////
- ////////////////// end of inline methods //////////////////
- ///////////////////////////////////////////////////////////
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- *
- * $Log: message_history.hpp,v $
- * Revision 1000.1 2004/04/12 18:12:30 gouriano
- * PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.4
- *
- * Revision 1.4 2003/12/31 20:31:14 dicuccio
- * Added Clear()
- *
- * Revision 1.3 2003/08/22 15:54:48 dicuccio
- * General clean-up: Removed unneeded export specifiers from templates; removed
- * 'USING_SCOPE(objects)'
- *
- * Revision 1.2 2003/07/15 13:51:57 shomrat
- * Completion of history interface
- *
- * Revision 1.1 2003/07/14 10:52:10 shomrat
- * Initial Revision
- *
- *
- * ===========================================================================
- */
- #endif // GUI_PLUGIN_MESSAGEHISTORY_HPP