test_msg.cpp
来自「ncbi源码」· C++ 代码 · 共 158 行
CPP
158 行
/* * =========================================================================== * PRODUCTION $Log: test_msg.cpp,v $ * PRODUCTION Revision 1000.2 2004/06/01 21:05:25 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5 * PRODUCTION * =========================================================================== *//* $Id: test_msg.cpp,v 1000.2 2004/06/01 21:05:25 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. * * =========================================================================== * * Authors: Lou Friedman * * File Description: * Test messgae pool. */#include <ncbi_pch.hpp>#include <corelib/ncbiobj.hpp>#include <gui/utils/msg_pool.hpp>#include <string>BEGIN_NCBI_SCOPEclass CMsgPoolTester : public CObject {public: enum MsgSet1 { M1_1 = 1, M1_2, M1_3 }; enum MsgSet2 { M2_1 = 11, M2_2, M2_3 }; CMsgPoolTester(std::string name) : m_Name(name) {} ~CMsgPoolTester() {} string m_Name; void MessageEventHandler(MsgSet1 msg, const void* ud); void MessageEventHandler(MsgSet2 msg, const void* ud); }; void CMsgPoolTester::MessageEventHandler(MsgSet1 msg, const void* ud) { string str_msg; cout << m_Name << " received message " << msg << " of MsgSet1" << endl; }void CMsgPoolTester::MessageEventHandler(MsgSet2 msg, const void* ud) { string str_msg; cout << m_Name << " received message " << msg << " of MsgSet2" << endl; }END_NCBI_SCOPEUSING_NCBI_SCOPE;int main (){ CMsgPoolMgr<CMsgPoolTester>* mgr = new(CMsgPoolMgr<CMsgPoolTester>); CMsgPoolTester t1("t1"); CMsgPoolTester t2("t2"); CMsgPoolTester t3("t3"); CMsgPoolTester t4("t4"); CMsgPoolTester t5("t5");// CMsgPool<CMsgPoolTester> p1("p1"); mgr->CreatePool("p1"); CMsgPool<CMsgPoolTester>& p1 = *(mgr->FindPool("p1")); p1.Join(t1); p1.Join(t3); p1.Join(t4); p1.Join(t5);// CMsgPool<CMsgPoolTester> p2("p2"); mgr->CreatePool("p2"); CMsgPool<CMsgPoolTester>& p2 = *(mgr->FindPool("p2")); p2.Join(t2); p2.Join(t2); p2.Join(t3); p2.Join(t5); p1.PostMessage(CMsgPoolTester::M1_2, NULL); p1.Leave(t3); p1.Leave(t3); p1.PostMessage(CMsgPoolTester::M1_1, NULL); p2.PostMessage(CMsgPoolTester::M2_3, NULL); delete mgr;// mgr->DeleteMessagePool("p1");// mgr->DeleteMsgPool("p2");}/* * =========================================================================== * $Log: test_msg.cpp,v $ * Revision 1000.2 2004/06/01 21:05:25 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.5 * * Revision 1.5 2004/05/21 22:27:51 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.4 2003/12/31 21:08:31 dicuccio * Changed FindMessagePool() to FindPool() * * Revision 1.3 2003/12/31 20:33:01 dicuccio * Updated to reflect API changes in CMessagePoolMgr * * Revision 1.2 2003/12/22 21:46:54 ucko * Tweaked signature of MessageEventHandler per current msg_pool API. * * Revision 1.1 2003/09/12 17:41:02 friedman * Initial revision * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?