message_history.cpp
来自「ncbi源码」· C++ 代码 · 共 237 行
CPP
237 行
/* * =========================================================================== * 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_SCOPEUSING_SCOPE(objects);//======================== CPluginMessageHistory ===========================// static membersauto_ptr<CPluginMessageHistory> CPluginMessageHistory::sm_Instance;// accessCPluginMessageHistory& 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());}// constructorCPluginMessageHistory::CPluginMessageHistory(void){}// destructorCPluginMessageHistory::~CPluginMessageHistory(void){}void CPluginMessageHistory::Clear(){ m_Entries.clear();}// Add message to history listvoid CPluginMessageHistory::AddMessage(const CPluginMessage& msg){ CMessageHistoryEntry entry(msg); m_Entries.push_back(entry); // !!! update succesor}// iteratorCPluginMessageHistory::const_iterator CPluginMessageHistory::begin(void) const{ return m_Entries.begin();}CPluginMessageHistory::const_iterator CPluginMessageHistory::end(void) const{ return m_Entries.end();}//======================== CMessageHistoryEntry ============================// constructorCPluginMessageHistory::CMessageHistoryEntry::CMessageHistoryEntry(const CPluginMessage& msg) : m_Info(msg){}// destructorCPluginMessageHistory::CMessageHistoryEntry::~CMessageHistoryEntry(void){}// copy constructorCPluginMessageHistory::CMessageHistoryEntry::CMessageHistoryEntry(const CMessageHistoryEntry& other){ *this = other;}// assignment operatorCPluginMessageHistory::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 TInfoconst CMessageHistoryInfo& CPluginMessageHistory::CMessageHistoryEntry::GetInfo(void) const{ return m_Info;}// typedef size_t TPredecessorsize_t CPluginMessageHistory::CMessageHistoryEntry::GetPredecessor(void) const{ return m_Predecessor;}void CPluginMessageHistory::CMessageHistoryEntry::SetPredecessor(const size_t& value){ m_Predecessor = value;}// typedef vector< int > TSuccessorsconst 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*** ===========================================================================*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?