- /*
- * ===========================================================================
- * PRODUCTION $Log: message_history.cpp,v $
- * PRODUCTION Revision 1000.2 2004/06/01 20:44:05 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: message_history.cpp,v 1000.2 2004/06/01 20:44:05 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.
- *
- * ===========================================================================
- */
- // standard includes
- #include <ncbi_pch.hpp>
- #include <corelib/ncbistd.hpp>
- #include <corelib/ncbimtx.hpp>
- #include <gui/core/message_history.hpp>
- #include <gui/plugin/PluginMessage.hpp>
- #include <gui/plugin/MessageHistoryInfo.hpp>
- BEGIN_NCBI_SCOPE
- USING_SCOPE(objects);
- //======================== CPluginMessageHistory ===========================
- // static members
- auto_ptr<CPluginMessageHistory> CPluginMessageHistory::sm_Instance;
- // access
- CPluginMessageHistory& CPluginMessageHistory::Instance(void)
- {
- DEFINE_STATIC_FAST_MUTEX(s_Mutex);
- if ( sm_Instance.get() == 0 ) {
- CFastMutexGuard guard(s_Mutex);
- if ( sm_Instance.get() == 0 ) {
- sm_Instance.reset(new CPluginMessageHistory);
- }
- }
- return *(sm_Instance.get());
- }
- // constructor
- CPluginMessageHistory::CPluginMessageHistory(void)
- {
- }
- // destructor
- CPluginMessageHistory::~CPluginMessageHistory(void)
- {
- }
- void CPluginMessageHistory::Clear()
- {
- m_Entries.clear();
- }
- // Add message to history list
- void CPluginMessageHistory::AddMessage(const CPluginMessage& msg)
- {
- CMessageHistoryEntry entry(msg);
- m_Entries.push_back(entry);
- // !!! update succesor
- }
- // iterator
- CPluginMessageHistory::const_iterator CPluginMessageHistory::begin(void) const
- {
- return m_Entries.begin();
- }
- CPluginMessageHistory::const_iterator CPluginMessageHistory::end(void) const
- {
- return m_Entries.end();
- }
- //======================== CMessageHistoryEntry ============================
- // constructor
- CPluginMessageHistory::
- CMessageHistoryEntry::CMessageHistoryEntry(const CPluginMessage& msg) :
- m_Info(msg)
- {
- }
- // destructor
- CPluginMessageHistory::CMessageHistoryEntry::~CMessageHistoryEntry(void)
- {
- }
- // copy constructor
- CPluginMessageHistory::CMessageHistoryEntry::CMessageHistoryEntry
- (const CMessageHistoryEntry& other)
- {
- *this = other;
- }
- // assignment operator
- CPluginMessageHistory::CMessageHistoryEntry&
- CPluginMessageHistory::CMessageHistoryEntry::operator=
- (const CMessageHistoryEntry& other)
- {
- if ( this != &other ) {
- m_Info.SetId(other.m_Info.GetId());
- m_Info.SetDescription(other.m_Info.GetDescription());
- m_Info.SetReply_to(other.m_Info.GetReply_to());
- m_Info.ResetTime();
- if (other.m_Info.CanGetTime()) {
- m_Info.SetTime(other.m_Info.GetTime());
- }
- m_Predecessor = other.m_Predecessor;
- m_Successors = other.m_Successors;
- }
- return *this;
- }
- // typedef CMessageHistoryInfo TInfo
- const CMessageHistoryInfo&
- CPluginMessageHistory::CMessageHistoryEntry::GetInfo(void) const
- {
- return m_Info;
- }
- // typedef size_t TPredecessor
- size_t CPluginMessageHistory::CMessageHistoryEntry::GetPredecessor(void) const
- {
- return m_Predecessor;
- }
- void CPluginMessageHistory::CMessageHistoryEntry::SetPredecessor
- (const size_t& value)
- {
- m_Predecessor = value;
- }
- // typedef vector< int > TSuccessors
- const vector<size_t>&
- CPluginMessageHistory::CMessageHistoryEntry::GetSuccessors(void) const
- {
- return m_Successors;
- }
- void CPluginMessageHistory::CMessageHistoryEntry::AddSuccessor(size_t index)
- {
- m_Successors.push_back(index);
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- *
- * $Log: message_history.cpp,v $
- * Revision 1000.2 2004/06/01 20:44:05 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9
- *
- * Revision 1.9 2004/05/21 22:27:40 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.8 2004/03/31 16:26:06 ucko
- * +ncbimtx.hpp (no longer included via PluginMessage.hpp)
- *
- * Revision 1.7 2004/03/24 13:55:29 friedman
- * Fixed mutex comment
- *
- * Revision 1.6 2004/03/23 19:36:42 friedman
- * Replaced 'static CFastMutex' with DEFINE_STATIC_FAST_MUTEX
- *
- * Revision 1.5 2003/12/31 20:26:52 dicuccio
- * Added Clear()
- *
- * Revision 1.4 2003/10/27 17:36:54 dicuccio
- * Formatting changes
- *
- * Revision 1.3 2003/07/18 14:38:17 dicuccio
- * Fixed: make sure to check for optional members before calling Get...()
- *
- * Revision 1.2 2003/07/15 13:53:10 shomrat
- * Completion of message history module.
- *
- * Revision 1.1 2003/07/14 10:59:40 shomrat
- * Initial Revision
- *
- *
- * ===========================================================================
- */