CFx SDK Documentation  2023 SP0
FxProfile.h
Go to the documentation of this file.
1 //
2 // (C) Copyright 2005-2022 by Graebert GmbH.
3 //
4 // Permission to use, copy, modify, and distribute this software in
5 // object code form for any purpose and without fee is hereby granted,
6 // provided that the above copyright notice appears in all copies and
7 // that both that copyright notice and the limited warranty and
8 // restricted rights notice below appear in all supporting
9 // documentation.
10 //
11 // GRAEBERT PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
12 // GRAEBERT SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
13 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. GRAEBERT GMBH
14 // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
15 // UNINTERRUPTED OR ERROR FREE.
16 
17 #pragma once
18 
19 #include "DDKERNEL.h"
20 
21 #include "FxString.h"
22 
23 #include "FxPragmaPush.h"
24 
25 class CFxProfileStorage;
26 class CFxSettings;
27 class CFxSystemFiles;
28 class CFxRecentFiles;
29 class CFxPreferences;
30 
37 {
38 public:
39  virtual ~CFxProfile() {};
40 
41  virtual CFxString GetName() const = 0;
42 
43  virtual CFxString GetDescription() const = 0;
44 
45  /*
46  Description:
47  CFxSettings class provides low-level access to the profile
48  internal data
49  */
50  virtual CFxSettings* GetSettings() = 0;
51 
52  /*
53  Description:
54  CFxProfileStorage class provides low-level access to the profile
55  internal data
56  */
57  virtual CFxProfileStorage* GetStorage( bool bCreateIfNotExists ) = 0;
58 
59  /*
60  Description:
61  CFxSystemFiles class provides access to the system paths that are
62  stored in the profile
63  */
65 
66  /*
67  Description:
68  CFxRecentFiles class provides access to the recent files that are
69  stored in the profile (is used from fixed profile only)
70  */
72 
73  /*
74  Description:
75  Resolves command alias
76  */
77  virtual CFxString ResolveAlias( const CFxString& strAlias ) const = 0;
78 
79  /*
80  Description:
81  Load command aliases
82  */
83  virtual void LoadAliases() = 0;
84 
85  /*
86  Description:
87  CFxPreferences class provides access to the different preferences
88  that are stored in the profile
89  */
91 
92  /*
93  Description:
94  Flushes the changes to disk.
95  */
96  virtual void Flush() = 0;
97 };
98 
105 {
106 public:
108 
109  /*
110  Description:
111  Notification sent out that the current profile will be changed. newProfile is the new profile that will be set current.
112 
113  Arguments:
114  \param newProfile Profile that will be set current
115  */
116  virtual void currentProfileWillChange( const CFxString& newProfile ) {};
117 
118  /*
119  Description:
120  Notification sent out that the current profile has changed. newProfile is now the current profile.
121 
122  Arguments:
123  \param newProfile Profile that is now current
124  */
125  virtual void currentProfileChanged( const CFxString& newProfile ) {};
126 
127  /*
128  Description:
129  Notification sent out that the current profile will be reset.
130 
131  Arguments:
132  \param currentProfile Name of the current profile
133  */
134  virtual void currentProfileWillBeReset( const CFxString& currentProfile ) {};
135 
136  /*
137  Description:
138 
139  Arguments:
140  \param
141  */
142  virtual void currentProfileReset( const CFxString& currentProfile ) {};
143 
144  /*
145  Description:
146  This method is called when the current profile is about to be saved. It is called before saving
147  the profile. Applications that use profile storage file to store the settings should override
148  this method (or profileWillBeSaved()) and store their latest settings.
149 
150  Arguments:
151  \param currentProfile Input name of the current profile that will be saved
152  */
153  virtual void currentProfileWillBeSaved( const CFxString& currentProfile, CFxSettings* pCurrentProfileSettings ) {};
154 
155  /*
156  Description:
157  */
158  virtual void currentProfileWillBeLoaded( const CFxString& currentProfile, CFxSettings* pCurrentProfileSettings ) {};
159 
160  /*
161  Description:
162  This method is called when the current profile was saved. It is called after saving the profile.
163 
164  Arguments:
165  \param currentProfile Input name of the current profile that was saved
166  */
167  virtual void currentProfileSaved( const CFxString& currentProfile ) {};
168 
169  /*
170  Description:
171  */
172  virtual void currentProfileLoaded( const CFxString& currentProfile ) {};
173 
174  /*
175  Description:
176  Notification sent out that a profile will be reset.
177 
178  Arguments:
179  \param profileName Name of the profile to be reset
180  */
181  virtual void profileWillReset( const CFxString& profileName ) {};
182 
183  /*
184  Description:
185  Notification sent out when a profile has been reset.
186 
187  Arguments:
188  \param profileName Name of the profile that was reset
189  */
190  virtual void profileReset( const CFxString& profileName ) {};
191 
192  /*
193  Description:
194  This method is called when a profile is about to be saved. It is called before saving
195  the profile. Applications that use profile storage file to store the settings should
196  override this method (or currentProfileWillBeSaved()) and store their latest settings.
197 
198  Arguments:
199  \param profileName Input name of the profile that will be saved; if the profile is
200  a fixed profile, this will contain an empty string
201  */
202  virtual void profileWillBeSaved( const CFxString& profileName, CFxSettings* pProfileSettings ) {};
203 
204  /*
205  Description:
206  */
207  virtual void profileWillBeLoaded( const CFxString& profileName, CFxSettings* pProfileSettings ) {};
208 
209  /*
210  Description:
211  This method is called when a profile was saved. It is called after saving the profile.
212 
213  Arguments:
214  \param profileName Input name of the profile that was saved; if the profile is
215  a fixed profile, this will contain an empty string
216  */
217  virtual void profileSaved( const CFxString& profileName ) {};
218 
219  /*
220  Description:
221  */
222  virtual void profileLoaded( const CFxString& profileName ) {};
223 };
224 
226 
233 {
234 public:
235  /*
236  Description:
237  The registry path for the specified profile, strProfileName, is returned via strRegProfileKey if the profile
238  is found in the registry.
239 
240  Arguments:
241  \param strRegProfileKey Output registry path
242  \param strProfileName Input profile name
243 
244  */
245  virtual void ProfileRegistryKey( CFxString& strRegProfileKey, const CFxString& strProfileName ) = 0;
246 
247  /*
248  Description:
249  This function returns the profile names list via the AcApProfileNameArray argument, nameList. When passed in,
250  this array should be empty. It is the caller’s responsibility to delete the entries of the array.
251 
252  Returns the number of profiles in the registry.
253 
254  Arguments:
255  \param nameList Passed in AcApProfileNameArray
256  */
257  virtual int ProfileListNames( CFxProfileNameArray& nameList ) = 0;
258 
259  /*
260  Description:
261  The ARGON settings in the registry for the specified profile, strProfileName, are written out to the .arg file,
262  exportFileName, in REGEDIT4 format.
263 
264  The function could return with the following return codes:
265  eProfileDoesNotExist The specified profile name is not found in the registry.
266  eNoFileName No file name specified.
267  eInvalidFileExtension The file should have an .arg extension.
268  eCantOpenFile File permission error.
269  eRegistryAccessError Could not access/update registry.
270  eOk Operation completed successfully.
271 
272  Arguments:
273  \param strProfileName Input profile name
274  \param exportFileName Output .arg file name
275  */
276  virtual int ProfileExport( const CFxString& strProfileName, const CFxString& exportFileName ) = 0;
277 
278  /*
279  Description:
280  A new profile is created with the specified name, strProfileName, and description, profileDescription. If the
281  profile already exists, it will be overwritten (if it is not the current profile). The ARGON settings from the
282  specified .arg file, importFileName, are read into the registry for the new profile. bImportPathInfo
283  determines whether the path information in the file should be read in or ignored.
284 
285  The function could return with the following return codes:
286  eInvalidProfileName Invalid characters in the Profile name.
287  eNoFileName No file name specified.
288  eInvalidFileExtension The file should have an .arg extension.
289  eProfileIsInUse Cannot import into the current profile.
290  eCantOpenFile File permission error.
291  eRegistryCreateError Could not update registry.
292  eRegistryAccessError Could not access registry.
293  eOk Operation completed successfully.
294 
295  Arguments:
296  \param strProfileName Input profile name
297  \param importFileName Input .arg file name
298  \param profileDescription Input profile description
299  \param bImportPathInfo Input Boolean indicating whether path information should be read in or ignored
300 
301  */
302  virtual int ProfileImport( const CFxString& strProfileName, const CFxString& importFileName, const CFxString& profileDescription, bool bImportPathInfo ) = 0;
303 
304  /*
305  Description:
306  Deletes the profile specified in strProfileName from the registry.
307 
308  The function could return with the following return codes:
309  eProfileDoesNotExist The specified profile name is not found in the registry.
310  eProfileIsInUse Cannot delete the current profile.
311  eRegistryAccessError Could not access/update registry.
312  eOk Operation completed successfully.
313 
314  Arguments:
315  \param strProfileName Input profile name
316  */
317  virtual int ProfileDelete( const CFxString& strProfileName ) = 0;
318 
319  /*
320  Description:
321  The settings under the profile strProfileName are deleted and the profile reverts to default settings.
322 
323  The function could return with the following return codes:
324  eProfileDoesNotExist The specified profile name is not found in the registry.
325  eRegistryAccessError Could not access/update registry.
326  eOk Operation completed successfully.
327 
328  Arguments:
329  \param strProfileName Input profile name
330  */
331  virtual int ProfileReset( const CFxString& strProfileName ) = 0;
332 
333  /*
334  Description:
335  The profile specified, strprofileName, is made the current profile for the ARGON session.
336 
337  The function could return with the following return codes:
338  eProfileDoesNotExist The specified profile name is not found in the registry.
339  eRegistryAccessError Could not access/update registry.
340  eOk Operation completed successfully.
341 
342  Arguments:
343  \param strProfileName Input profile name
344  */
345  virtual int ProfileSetCurrent( const CFxString& strProfileName ) = 0;
346 
348 
349  virtual CFxProfile* ProfileGetFixed() = 0;
350 
351  virtual CFxProfile* ProfileGet( const CFxString& strProfileName ) = 0;
352 
353  /*
354  Description:
355  A new profile is created with the new name and description. If the profile name already exists, it will be
356  overwritten (if it's not the current profile). The ARGON settings from the old profile are copied into the
357  new profile.
358 
359  The function could return with the following return codes:
360  eProfileDoesNotExist The old profile name is not found in the registry.
361  eInvalidProfileName Invalid characters in the new profile name.
362  eProfileIsInUse Cannot copy into current profile.
363  eRegistryAccessError Could not access registry.
364  eOk Operation completed successfully.
365 
366  Arguments:
367  \param newProfileName Input new profile name
368  \param oldProfileName Input profile name to be copied
369  \param newProfileDesc Input new profile description
370  */
371  virtual int ProfileCopy( const CFxString& newProfileName, const CFxString& oldProfileName, const CFxString& newProfileDesc ) = 0;
372 
373  /*
374  Description:
375  Renames an existing profile, oldProfileName, to a new name, newProfileName, with a new description, newProfileDesc.
376 
377  The function could return with the following return codes:
378  eProfileDoesNotExist The specified profile name is not found in the registry.
379  eInvalidProfileName Invalid characters in the new profile name.
380  eProfileIsInUse Cannot rename a profile to the name of the current profile.
381  eRegistryAccessError Could not access/update registry.
382  eOk Operation completed successfully.
383 
384  Arguments:
385  \param newProfileName Input new profile name
386  \param oldProfileName Input old profile name
387  \param newProfileDesc Input new profile description
388  */
389  virtual int ProfileRename( const CFxString& newProfileName, const CFxString& oldProfileName, const CFxString& newProfileDesc ) = 0;
390 
391  /*
392  Description:
393  This function force profile saving.
394 
395  The function could return with the following return codes:
396  eProfileDoesNotExist The specified profile name is not found in the registry.
397  eOk Operation completed successfully.
398  */
399  virtual int ProfileSave( const CFxString& profileName ) = 0;
400 
401  /*
402  Description:
403  This function adds a reactor to receive profile change event notifications.
404  */
405  virtual void addReactor( CFxProfileManagerReactor* ) = 0;
406 
407  /*
408  Description:
409  This function removes a reactor.
410  */
412 };
413 
414 #define currProfile() GetFxSystemServices()->GetFxProfileManager()->ProfileGetCurrent()
415 
416 class QDomNode;
417 
424 {
425 public:
426  virtual ~CFxProfileStorage() {};
427 
428  /*
429  Description:
430  Creates a node in the XML file at the specified path. If the node already exists, it gets the existing node.
431 
432  Arguments:
433  \param pszNodePath Input XML node path specifying the node to create
434  \param pNode Output reference to receive the IUnknown interface of created IXMLDOMNode interface
435  */
436  virtual int CreateNode( const CFxString& pszNodePath, QDomNode*& pNode ) = 0;
437 
438  /*
439  Description:
440  Gets the node in the XML file at the specified path.
441 
442  Arguments:
443  \param pszNodePath Input XML node path specifying the node to get;
444  for example, ToolPalette\ToolPaletteSets\ToolPaletteSet
445  \param pNode Output reference to receive the IUnknown interface of IXMLDOMNode pointer
446  for the specified node path; set to NULL if the node is not found
447  */
448  virtual int GetNode( const CFxString& pszNodePath, QDomNode*& pNode ) = 0;
449 
450  /*
451  Description:
452  Replaces the node in the XML file at the specified path with the specified node. The replaced node is released.
453 
454  Arguments:
455  \param pszNodePath Input XML node path specifying the node to replace;
456  for example, ToolPalette\ToolPaletteSets\ToolPaletteSet
457  \param pNode Input IUnknown interface of IXMLDOMNode pointer to replace the existing node
458  at the specified node path
459  */
460  virtual int ReplaceNode( const CFxString& pszNodePath, QDomNode* pNode ) = 0;
461 
462  /*
463  Description:
464  Deletes the node in the XML file at the specified path.
465 
466  Arguments:
467  \param pszNodePath Input XML node path specifying the node to delete;
468  for example, ToolPalette\ToolPaletteSets\ToolPaletteSet
469  */
470  virtual int DeleteNode( const CFxString& pszNodePath ) = 0;
471 
472  /*
473  Description:
474  Gets the physical storage file in which the profile is stored.
475 
476  Arguments:
477  \param pszFile Input pointer to character buffer to receive the profile storage file with path;
478  the buffer length should be at least MAX_PATH length
479  */
480  virtual int GetStorageFile( CFxString& fileName ) = 0;
481 
482  /*
483  Description:
484  Saves the profile storage XML file. The profile storage file is saved automatically when required.
485  For example, it will be saved when the profile is switched or renamed or when the session ends.
486  Use this function to force a save of the file immediately if necessary.
487  */
488  virtual int Save( void ) = 0;
489 };
490 
491 #include "FxPragmaPop.h"
#define DDKERNEL_API
Definition: DDKERNEL.h:32
OdArray< CFxString > CFxProfileNameArray
Definition: FxProfile.h:225
virtual CFxSystemFiles * GetSystemFiles()=0
virtual CFxPreferences * GetPreferences()=0
virtual void LoadAliases()=0
virtual CFxSettings * GetSettings()=0
virtual CFxString GetName() const =0
virtual CFxProfileStorage * GetStorage(bool bCreateIfNotExists)=0
virtual ~CFxProfile()
Definition: FxProfile.h:39
virtual CFxRecentFiles * GetRecentFiles()=0
virtual CFxString GetDescription() const =0
virtual CFxString ResolveAlias(const CFxString &strAlias) const =0
virtual void Flush()=0
virtual int ProfileImport(const CFxString &strProfileName, const CFxString &importFileName, const CFxString &profileDescription, bool bImportPathInfo)=0
virtual int ProfileCopy(const CFxString &newProfileName, const CFxString &oldProfileName, const CFxString &newProfileDesc)=0
virtual int ProfileSave(const CFxString &profileName)=0
virtual void removeReactor(CFxProfileManagerReactor *)=0
virtual int ProfileDelete(const CFxString &strProfileName)=0
virtual int ProfileRename(const CFxString &newProfileName, const CFxString &oldProfileName, const CFxString &newProfileDesc)=0
virtual int ProfileExport(const CFxString &strProfileName, const CFxString &exportFileName)=0
virtual int ProfileReset(const CFxString &strProfileName)=0
virtual CFxProfile * ProfileGet(const CFxString &strProfileName)=0
virtual int ProfileSetCurrent(const CFxString &strProfileName)=0
virtual int ProfileListNames(CFxProfileNameArray &nameList)=0
virtual void ProfileRegistryKey(CFxString &strRegProfileKey, const CFxString &strProfileName)=0
virtual void addReactor(CFxProfileManagerReactor *)=0
virtual CFxProfile * ProfileGetCurrent()=0
virtual CFxProfile * ProfileGetFixed()=0
virtual void profileReset(const CFxString &profileName)
Definition: FxProfile.h:190
virtual void currentProfileSaved(const CFxString &currentProfile)
Definition: FxProfile.h:167
virtual void profileWillReset(const CFxString &profileName)
Definition: FxProfile.h:181
virtual void profileSaved(const CFxString &profileName)
Definition: FxProfile.h:217
virtual void currentProfileWillChange(const CFxString &newProfile)
Definition: FxProfile.h:116
virtual void profileLoaded(const CFxString &profileName)
Definition: FxProfile.h:222
virtual void currentProfileWillBeLoaded(const CFxString &currentProfile, CFxSettings *pCurrentProfileSettings)
Definition: FxProfile.h:158
virtual void currentProfileReset(const CFxString &currentProfile)
Definition: FxProfile.h:142
virtual void profileWillBeSaved(const CFxString &profileName, CFxSettings *pProfileSettings)
Definition: FxProfile.h:202
virtual void currentProfileWillBeSaved(const CFxString &currentProfile, CFxSettings *pCurrentProfileSettings)
Definition: FxProfile.h:153
virtual void currentProfileLoaded(const CFxString &currentProfile)
Definition: FxProfile.h:172
virtual ~CFxProfileManagerReactor()
Definition: FxProfile.h:107
virtual void profileWillBeLoaded(const CFxString &profileName, CFxSettings *pProfileSettings)
Definition: FxProfile.h:207
virtual void currentProfileChanged(const CFxString &newProfile)
Definition: FxProfile.h:125
virtual void currentProfileWillBeReset(const CFxString &currentProfile)
Definition: FxProfile.h:134
virtual int CreateNode(const CFxString &pszNodePath, QDomNode *&pNode)=0
virtual int GetStorageFile(CFxString &fileName)=0
virtual int ReplaceNode(const CFxString &pszNodePath, QDomNode *pNode)=0
virtual int DeleteNode(const CFxString &pszNodePath)=0
virtual int GetNode(const CFxString &pszNodePath, QDomNode *&pNode)=0
virtual int Save(void)=0
virtual ~CFxProfileStorage()
Definition: FxProfile.h:426