NCBI C++ ToolKit
visible_range_service.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: visible_range_service.cpp 40888 2018-04-26 14:55:12Z katargir $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Roman Katargin
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
38 
40 
42 {
43 }
44 
46 {
47 }
48 
50 {
51  m_Clients.clear();
52 }
53 
55 {
56  LOG_POST(Info << "Initializing Visible Range Service...");
57  LoadSettings();
58  LOG_POST(Info << "Finished initializing Visible Range Service");
59 }
60 
62 {
63  LOG_POST(Info << "Shutting down Visible Range Service...");
65  SaveSettings();
66  LOG_POST(Info << "Finished shutting down Visible Range Service");
67 }
68 
70 {
71  _ASSERT(client);
72 
73  TClients::const_iterator it = std::find(m_Clients.begin(), m_Clients.end(), client);
74  if(it == m_Clients.end()) {
75  m_Clients.push_back(client);
76  } else {
77  ERR_POST("CVisibleRangeService::AttachClient() - client already registered");
78  }
79 }
80 
82 {
83  TClients::iterator it = std::find(m_Clients.begin(), m_Clients.end(), client);
84  if(it != m_Clients.end()) {
85  m_Clients.erase(it);
86  }
87  else {
88  ERR_POST("CVisibleRangeService::DetachClient() - client is not attached");
89  }
90 }
91 
94 {
95  static bool fReentry = false;
96  if (fReentry)
97  return;
98  CBoolGuard _guard(fReentry);
99 
100  _ASSERT(std::find(m_Clients.begin(), m_Clients.end(), source) != m_Clients.end());
101 
102  ITERATE(TClients, it, m_Clients) {
103  if (*it == source)
104  continue;
105  (**it).OnVisibleRangeChanged (vrange, source);
106  }
107 }
108 
110 {
111  m_RegPath = path + ".VisibleRange";
112 }
113 
114 static const char* kAutoBroadcast = "AutoBroadcast";
115 static const char* kPolicy = "Policy";
116 
118 {
119  if (!m_RegPath.empty()) {
121  CRegistryReadView view = gui_reg.GetReadView(m_RegPath);
126  }
127 }
128 
130 {
131  if (!m_RegPath.empty()) {
133  CRegistryWriteView view = gui_reg.GetWriteView(m_RegPath);
136  }
137 }
138 
CRegistryWriteView GetWriteView(const string &section)
get a read-write view at a particular level.
Definition: registry.cpp:462
static CGuiRegistry & GetInstance()
access the application-wide singleton
Definition: registry.cpp:400
CRegistryReadView GetReadView(const string &section) const
get a read-only view at a particular level.
Definition: registry.cpp:428
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
int GetInt(const string &key, int default_val=0) const
access a named key at this level, with no recursion
Definition: reg_view.cpp:230
bool GetBool(const string &key, bool default_val=false) const
Definition: reg_view.cpp:241
void Set(const string &key, int val)
access a named key at this level, with no recursion
Definition: reg_view.cpp:533
vector< IVisibleRangeClient * > TClients
virtual void BroadcastVisibleRange(const CVisibleRange &vrange, IVisibleRangeClient *source)
virtual void SaveSettings() const
virtual void AttachClient(IVisibleRangeClient *client)
virtual void DetachClient(IVisibleRangeClient *client)
virtual void SetRegistryPath(const string &path)
static void SetDefaultVisibleRangePolicy(EBasicPolicy policy)
static bool IsAutoBroadcast()
static EBasicPolicy GetDefaultVisibleRangePolicy()
static void SetAutoBroadcast(bool flag)
IVisibleRangeClient - represents an object that wants notifications about visible range changes.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1185
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
const CharType(& source)[N]
Definition: pointer.h:1149
static CNamedPipeClient * client
#define _ASSERT
static const char * kAutoBroadcast
static const char * kPolicy
Modified on Wed Sep 04 15:01:56 2024 by modify_doxy.py rev. 669887