| AnyConnect Secure Mobility Client 5.1.10.233

Preference.h
1/**************************************************************************
2* Copyright (c) 2008, 2022 Cisco Systems, Inc.
3* All Rights Reserved. Cisco Highly Confidential.
4***************************************************************************
5*
6* File: Preference.h
7* Date: 07/2008
8*
9***************************************************************************
10* Preference class declaration for the Client API.
11***************************************************************************/
12
13#ifndef _PREFERENCE_
14#define _PREFERENCE_
15
16/**
17* The Preference class represents a single preference setting that is read
18* from disk. Some preferences can be controlled by the user, as specified
19* by administrator policy. In these instances, the UI layer will represent
20* the controls/widgets used to modify a preference by rendering an associated
21* PromptEntry object, accessible via the getPromptEntry() method, similar to
22* the mechanism used to obtain user input in a ClientIfc::UserPromptCB call.
23*/
24
25#include "PreferenceBase.h"
26
27 class VPN_VPNAPI Preference : public PreferenceBase
28{
29
30 public:
31
32 /**
33 * Sets the value associated with this preference. Returns true on
34 * success, false if the value is not in the range of allowed values
35 * for this preference (e.g. setting a value of "fish" for a true/false
36 * preference).
37 */
38 bool setPreferenceValue(const tstring& value);
39
40
41 /**
42 * Returns the current value of this preference as returned by
43 * PromptEntry::getTrueValue(). The values "true" and "false" are
44 * returned for preferences represented by a checkbox.
45 */
46 const tstring& getPreferenceValue() const;
47
48
49 /**
50 * Returns the ID of this Preference. For a complete list of preference
51 * ID's see the ::PreferenceId enum in api.h.
52 */
53 const PreferenceId& getPreferenceId() const;
54
55
56 /**
57 * Returns a reference to an internal list of child preferences for this
58 * class. Callers may modify the value of the Preference objects contained
59 * within, but should not alter the list or delete individual objects.
60 */
61 const std::list<Preference*>& getChildren() const;
62
63
64 /**
65 * Returns a pointer to an internal PromptEntry used to modify the value
66 * of this Preference. By checking the type of the PromptEntry, an
67 * appropriate UI layer control/widget should be created that can be
68 * used to update the value of the preference. The caller should not
69 * delete the returned pointer.
70 *
71 * From the ::PromptType enum in api.h, Prompt_Combo and Prompt_Checkbox
72 * are used by this class.
73 *
74 * @see PromptEntry
75 */
76 PromptEntry* getPromptEntry() const;
77
78
79 Preference(PreferenceId preferenceId,
80 const tstring& label,
81 PromptType prefType,
82 const tstring& initialValue,
83 ApiStringMap* pOptions = NULL,
84 Preference* pParent = NULL);
85
86 virtual ~Preference() {};
87
88 /**
89 * Deep Copy Constructor
90 */
91 explicit Preference(
92 const Preference& existingPref)
93 :
94 PreferenceBase(existingPref)
95 {
96 }
97
98 /**
99 * Deep Copy Assignment Operator
100 */
101 Preference& operator=(const Preference& existingPref)
102 {
103 if (std::addressof(existingPref) != this)
104 {
105 PreferenceBase::operator=(existingPref);
106 }
107 return *this;
108 }
109
110};
111
112#endif // _PREFERENCE_
PromptType
PromptType
Definition api.h:258
PreferenceId
PreferenceId
Definition api.h:284
tstring
#define tstring
Definition api.h:35
Preference::operator=
Preference & operator=(const Preference &existingPref)
Definition Preference.h:101
Preference::getPromptEntry
PromptEntry * getPromptEntry() const
Preference::getPreferenceValue
const tstring & getPreferenceValue() const
Preference::Preference
Preference(const Preference &existingPref)
Definition Preference.h:91
Preference::getPreferenceId
const PreferenceId & getPreferenceId() const
Preference::getChildren
const std::list< Preference * > & getChildren() const
Preference::setPreferenceValue
bool setPreferenceValue(const tstring &value)
PromptEntry
Definition PromptEntry.h:40