NCBI C++ ToolKit
phone_home_policy.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef CORELIB___PHONE_HOME_POLICY__HPP
2 #define CORELIB___PHONE_HOME_POLICY__HPP
3 
4 /* $Id: phone_home_policy.hpp 102254 2024-04-11 13:58:45Z ivanov $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Denis Vakatov, Vladimir Ivanov
30  *
31  *
32  */
33 
34 /// @file phone_home_policy.hpp
35 /// Define IPhoneHomePolicy, interface class for Phone Home Policy.
36 /// https://confluence.ncbi.nlm.nih.gov/pages/viewpage.action?pageId=184682676
37 ///
38 /// For the sample implementation see:
39 /// src/sample/app/connect/ncbi_usage_report_phonehome_sample.cpp
40 
41 
42 #include <corelib/version_api.hpp>
43 #include <common/ncbi_build_info.h>
44 
45 
47 
48 /** @addtogroup AppFramework
49  *
50  * @{
51  */
52 
54 
55 
56 /// Interface class for Phone Home Policy.
57 ///
58 /// Phone Home Policy is disabled by default. It should be explicitly enabled
59 /// in the Apply() method, based on passed to te application command line arguments
60 /// or previously saved configuration.
61 ///
63 {
64 public:
65  /// Constructor
67  /// Destructor
68  virtual ~IPhoneHomePolicy() { Finish(); };
69 
70  /// Apply policy for an application.
71  ///
72  /// For example, iIt can get and check program arguments, and call any other methods
73  /// depending on it. Automatically called from CNcbiApplication::SetPhoneHomePolicy().
74  /// @param app
75  /// Pointer to the CNcbiApplicationAPI instance.
76  /// @sa CNcbiApplication::SetPhoneHomePolicy, CNcbiApplication::GetPhoneHomePolicy
77  ///
78  virtual void Apply(CNcbiApplicationAPI* app) = 0;
79 
80  /// Print a message about collecting data, disablig tracking and privacy policies.
81  virtual void Print() = 0;
82 
83  /// Save policy configuration.
84  virtual void Save() = 0;
85 
86  /// Restore policy configuration.
87  virtual void Restore() = 0;
88 
89  /// Initialize policy/reporting API.
90  virtual void Init() {};
91 
92  /// Deinitialize policy/reporting API.
93  /// Redefine if you want to gracefully terminate reporting API.
94  /// Automatically called from the destructor.
95  virtual void Finish() {};
96 
97  /// Return current policy status (enabbed/disabled).
98  virtual bool IsEnabled() const { return m_IsEnabled; };
99 
100  /// Set policy status (enabbed/disabled).
101  virtual void SetEnabled(bool enabled = true) { m_IsEnabled = enabled; };
102 
103 protected:
104  bool m_IsEnabled; ///< Enable/disable tracking status
105 };
106 
107 
108 /* @} */
109 
110 
112 
113 #endif // CORELIB___PHONE_HOME_POLICY__HPP
CNcbiApplicationAPI –.
Interface class for Phone Home Policy.
#define false
Definition: bool.h:36
virtual ~IPhoneHomePolicy()
Destructor.
virtual void Save()=0
Save policy configuration.
IPhoneHomePolicy()
Constructor.
virtual void Init()
Initialize policy/reporting API.
virtual void Restore()=0
Restore policy configuration.
virtual void SetEnabled(bool enabled=true)
Set policy status (enabbed/disabled).
bool m_IsEnabled
Enable/disable tracking status.
virtual void Apply(CNcbiApplicationAPI *app)=0
Apply policy for an application.
virtual bool IsEnabled() const
Return current policy status (enabbed/disabled).
virtual void Print()=0
Print a message about collecting data, disablig tracking and privacy policies.
virtual void Finish()
Deinitialize policy/reporting API.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
Modified on Sun May 19 04:42:17 2024 by modify_doxy.py rev. 669887