System CATSysPreferenceRepository

Usage: you must use this class as is. You should never derive it.


public class CATSysPreferenceRepository

Class for managing the user's preferences.

Role: CATSysPreferenceRepositories manage aggregates of attributes that are used to store and retrieve values and parameters set by the user. They are stored between working sessions in one preference file.

Each CATSysPreferenceRepository has a unique name used by the application to access it. Each attribute within one CATSysPreferenceRepository is identified by its name and type.

Setting attributes can store the values of simple types such as integers or floats. In addition, a marshallable object should be saved as a setting attribute with less or no impact on the application.

A CATSysPreferenceRepository instance can be saved in memory for temporary storage using a commit/rollback mechanism, and in a file for persistent storage.


Method Index


o Commit()
Makes a persistent copy of the CATSysPreferenceRepository in Memory.
o DelPreference(char*)
Removes a given preference.
o GetPreferenceRepository(char*)
Creates a CATSysPreferenceRepository.
o IsPresent(char*,char*)
Indicates the existence of a given attribute.
o NextAttribute(char*,char*,CATLONG32*,short)
Browses the CATSysPreferenceRepository.
o ReadPreference(char*,CATString*)
Retrieves the value of a setting attribute.
o ReadPreference(char*,int*,CATLONG32)
Retrieves the value of a setting attribute which is an array of ints.
o ReadPreference(char*,char*,CATLONG32)
Retrieves the value of a setting attribute which is an array of char.
o ReadPreference(char*,float*,CATLONG32)
Retrieves the value of a setting attribute which is an array of floats.
o ReadPreference(char*,short*,CATLONG32)
Retrieves the value of a setting attribute which is an array of shorts.
o ReadPreference(char*,double*,CATLONG32)
Retrieves the value of a setting attribute which is an array of doubles.
o ReadPreference(char*,CATBaseUnknown*)
Retrieves the value of a setting attribute.
o ReadPreference(char*,CATUnicodeString*)
Retrieves the value of a setting attribute.
o ReadPreference(char*,CATString**,CATLONG32)
Retrieves the value of a setting attribute which is an array of CATString.
o ReadPreference(char*,unsigned int*,CATLONG32)
Retrieves the value of a setting attribute which is an array of unsigned ints.
o ReadPreference(char*,CATBaseUnknown**,CATLONG32)
Retrieves the value of a setting attribute which is an array of CATBaseUnknown.
o ReadPreference(char*,CATUnicodeString**,CATLONG32)
Retrieves the value of a setting attribute which is an array of CATUnicodeString.
o Rollback()
Restores a previous persistent copy of the CATSysPreferenceRepository in Memory.
o SaveRepository(char*)
Makes a persistent copy of the CATsettingRepository on file.
o WritePreference(char*,CATString*)
Sets the value of a setting attribute.
o WritePreference(char*,int*,CATLONG32)
Sets the value of a setting attribute which is an array of ints.
o WritePreference(char*,char*,CATLONG32)
Sets the value of a setting attribute which is an array of chars.
o WritePreference(char*,float*,CATLONG32)
Sets the value of a setting attribute which is an array of floats.
o WritePreference(char*,short*,CATLONG32)
Sets the value of a setting attribute which is an array of shorts.
o WritePreference(char*,double*,CATLONG32)
Sets the value of a setting attribute which is an array of doubles.
o WritePreference(char*,CATBaseUnknown*)
Sets the value of a setting attribute.
o WritePreference(char*,CATUnicodeString*)
Sets the value of a setting attribute.
o WritePreference(char*,CATString**,CATLONG32)
Sets the value of a setting attribute which is an array of CATString.
o WritePreference(char*,unsigned int*,CATLONG32)
Sets the value of a setting attribute which is an array of unsigned ints.
o WritePreference(char*,CATBaseUnknown**,CATLONG32)
Sets the value of a setting attribute which is an array of CATBaseUnknown.
o WritePreference(char*,CATUnicodeString**,CATLONG32)
Sets the value of a setting attribute which is an array of CATUnicodeString.

Methods


o Commit
public Commit()
Makes a persistent copy of the CATSysPreferenceRepository in Memory.
Role: Makes a persistent copy of the CATSysPreferenceRepository in Memory The values of the attributes could be restore after that by doing a call to .
Returns:
Legal values S_OK on Success, otherwise -1.
o DelPreference
public DelPreference( const iAttributeName)
Removes a given preference.
Role: Removes in the CATSysPreferenceRepository the attribute named iAttributeName.
Parameters:
iAttributeName
The name of the attribute to be removed. Legal values: The length of the string must be less than or equal to
.
Returns:
Legal values 0 on Success, otherwise negative.
o GetPreferenceRepository
public static GetPreferenceRepository( const iPrefName)
Creates a CATSysPreferenceRepository.
Role: Creates the unique instance of the class CATSysPreferenceRepository named with the given argument. If a setting file exists, it is read.
Parameters:
iPrefName
The name of the CATSysPreferenceRepository used by the applications to retrieve it.
o IsPresent
public IsPresent( const iAttributeName,
const iAttributeClass)
Indicates the existence of a given attribute.
Role: Searches within the CATSysPreferenceRepository for an attribute named iAttributeName and of type iAttributeClass.
Parameters:
iAttributeName
The name of the attribute to be set. Legal values: The length of the string must be less than or equal to
.
iAttributeClass
The type of the requested attribute, that could be "int", "float",...
Returns:
the number of elements constituting the attribute, otherwise negative.
o NextAttribute
public NextAttribute( oAttributeName,
oAttributeClass,
oAttributeSize,
iReset= 0)
Browses the CATSysPreferenceRepository.
Role: Returns the Name, the type and the number of constituting elements of an attribute. The strings are copied but their allocation must be done by the caller.
Parameters:
oAttributeName
a pointer to an allocated buffer where the attribute's name will be copied
oAttributeClass
a pointer to an allocated buffer where the attribute's type will be copied
oAttributeSize
a pointer to a integer to put the number of constituting elements
iReset
iReset = 1 forces to begin with the first Attribute,reseting the state reached with the last call to this method, otherwise 0
Returns:
Legal values 0 until reaching the last Attribute and returning -1 when the last attribute is reached
o ReadPreference
public ReadPreference( const iSettingName,
ioSetting)
Retrieves the value of a setting attribute.
Role: Retrieves using its name, the value of an attribute constituted by one CATString. A pointer on a intialized and constructed object of type CATString must be given as argument, because this object is used to set the default value of the attribute, if it does not yet exist. In this last case the method calls WritePreference () to initialize the settings attribute.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
A pointer on a construted CATString. If the attribute has not been yet created, then ioSetting is used as default values, otherwise ioSetting is overwritten by the retrieved value.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure
o ReadPreference
public ReadPreference( const iSettingName,
ioSetting,
iLength=1)
Retrieves the value of a setting attribute which is an array of ints.
Role: Retrieves using its name, the values of each element of the array constituting an attribute. The array is defined as an array of initialized ints because it is used to set the default value of the attribute, if it does not yet exist. In this last case the method calls WritePreference () to initialize the setting attribute.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of initialized ints. If the attribute has not been yet created, then the elements of ioSetting are used as default values, otherwise the elements of ioSetting are overwritten by the retrieved values.
iLength
The number of elements to read.
Returns:
Legal values:
>0: on Success returns the number of elements really read
0 : if a class conflict on the attribute has occured.
-1: on failure
o ReadPreference
public ReadPreference( const iSettingName,
ioSetting,
iLength=1)
Retrieves the value of a setting attribute which is an array of char.
Role: Retrieves using its name, the values of each element of the array constituting an attribute. The array is defined as an array of initialized char because it is used to set the default value of the attribute, if it does not yet exist. In this last case the method calls WritePreference () to initialize the setting attribute.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of initialized char. If the attribute has not been yet created, then the elements of ioSetting are used as default values, otherwise the elements of ioSetting are overwritten by the retrieved values.
iLength
The number of elements to read.
Returns:
Legal values:
>0: on Success returns the number of elements really read
0 : if a class conflict on the attribute has occured.
-1: on failure
o ReadPreference
public ReadPreference( const iSettingName,
ioSetting,
iLength=1)
Retrieves the value of a setting attribute which is an array of floats.
Role: Retrieves using its name, the values of each element of the array constituting an attribute. The array is defined as an array of initialized floats because it is used to set the default value of the attribute, if it does not yet exist. In this last case the method calls WritePreference () to initialize the setting attribute.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of initialized floats. If the attribute has not been yet created, then the elements of ioSetting are used as default values, otherwise the elements of ioSetting are overwritten by the retrieved values.
iLength
The number of elements to read.
Returns:
Legal values:
>0: on Success returns the number of elements really read
0 : if a class conflict on the attribute has occured.
-1: on failure
o ReadPreference
public ReadPreference( const iSettingName,
ioSetting,
iLength=1)
Retrieves the value of a setting attribute which is an array of shorts.
Role: Retrieves using its name, the values of each element of the array constituting an attribute. The array is defined as an array of initialized shorts because it is used to set the default value of the attribute, if it does not yet exist. In this last case the method calls WritePreference () to initialize the setting attribute.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of initialized shorts. If the attribute has not been yet created, then the elements of ioSetting are used as default values, otherwise the elements of ioSetting are overwritten by the retrieved values.
iLength
The number of elements to read.
Returns:
Legal values:
>0: on Success returns the number of elements really read
0 : if a class conflict on the attribute has occured.
-1: on failure
o ReadPreference
public ReadPreference( const iSettingName,
ioSetting,
iLength=1)
Retrieves the value of a setting attribute which is an array of doubles.
Role: Retrieves using its name, the values of each element of the array constituting an attribute. The array is defined as an array of initialized doubles because it is used to set the default value of the attribute, if it does not yet exist. In this last case the method calls WritePreference () to initialize the setting attribute.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of initialized doubles. If the attribute has not been yet created, then the elements of ioSetting are used as default values, otherwise the elements of ioSetting are overwritten by the retrieved values.
iLength
The number of elements to read.
Returns:
Legal values:
>0: on Success returns the number of elements really read
0 : if a class conflict on the attribute has occured.
-1: on failure
o ReadPreference
public ReadPreference( const iSettingName,
ioSetting)
Retrieves the value of a setting attribute.
Role: Retrieves using its name, the value of an attribute constituted by one CATBaseUnknown. A pointer on a intialized and constructed object of type CATBaseUnknown must be given as argument, because this object is used to set the default value of the attribute, if it does not yet exist. In this last case the method calls WritePreference () to initialize the setting attribute.
Parameters:
iSettingName
The name of the attribute to be retrieved or created.
Legal values: The length of the string must be less than or equal to
.
ioSetting
A pointer on an initialized CATBaseUnknow. If the attribute has not been yet created, then ioSetting is used as default, otherwise ioSetting is overwritten by the retrieved value.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure
o ReadPreference
public ReadPreference( const iSettingName,
ioSetting)
Retrieves the value of a setting attribute.
Role: Retrieves using its name, the value of an attribute constituted by one CATUnicodeString. A pointer on a intialized and constructed object of type CATUnicodeString must be given as argument, because this object is used to set the default value of the attribute, if it does not yet exist. In this last case the method calls WritePreference () to initialize the setting attribute.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
A pointer on a construted CATString. If the attribute has not been yet created, then ioSetting is used as default value, otherwise ioSetting is overwritten by the retrieved value.
Returns:
Legal values:
1 : on Succes
0 : if a class conflict on the attribute has occured.
-1: on failure
o ReadPreference
public ReadPreference( const iSettingName,
ioSetting,
iSize)
Retrieves the value of a setting attribute which is an array of CATString.
Role: Retrieves using its name, the values of each element of the array constituting an attribute. The array is defined as an array of pointers on constructed CATString, because it is used to set the default value of the attribute, if it does not yet exist. In this last case the method calls WritePreference () to initialize the setting attribute.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of pointeur on constructed CATString. If the attribute has not been yet created, then the elements of ioSetting are used as default values, otherwise the elements of ioSetting are overwritten by the retrieved values.
iSize
The number of elements to read
Returns:
Legal values:
>0: on Success returns the number of elements really read
0 : if a class conflict on the attribute has occured.
-1: on failure
o ReadPreference
public ReadPreference( const iSettingName,
ioSetting,
iLength=1)
Retrieves the value of a setting attribute which is an array of unsigned ints.
Role: Retrieves using its name, the values of each element of the array constituting an attribute. The array is defined as an array of initialized unsigned ints because it is used to set the default value of the attribute, if it does not yet exist. In this last case the method calls WritePreference () to initialize the setting attribute.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of initialized unsigned ints. If the attribute has not been yet created, then the elements of ioSetting are used as default values, otherwise the elements of ioSetting are overwritten by the retrieved values.
iLength
The number of elements to read.
Returns:
Legal values:
>0: on Success returns the number of elements really read
0 : if a class conflict on the attribute has occured.
-1: on failure
o ReadPreference
public ReadPreference( const iSettingName,
ioSetting,
iSize)
Retrieves the value of a setting attribute which is an array of CATBaseUnknown.
Role: Retrieves using its name, the values of each element of the array constituting an attribute. The array is defined as an array of pointers on constructed CATBaseUnknown, because it is used to set the default value of the attribute, if it does not yet exist. In this last case the method calls WritePreference () to initialize the setting attribute.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of pointers on initialized CATBaseUnknow. If the attribute has not been yet created, then the elements of ioSetting are used as default values, otherwise the elements of ioSetting are overwritten by the retrieved values.
iSize
The number of elements to read.
Returns:
Legal values:
>0: on Success returns the number of elements really read
0 : if a class conflict on the attribute has occured.
-1: on failure
o ReadPreference
public ReadPreference( const iSettingName,
ioSetting,
iSize)
Retrieves the value of a setting attribute which is an array of CATUnicodeString.
Role: Retrieves using its name, the values of each element of the array constituting an attribute. The array is defined as an array of pointers on constructed CATUnicodeString, because it is used to set the default value of the attribute, if it does not yet exist. In this last case the method calls WritePreference () to initialize the setting attribute.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of pointeur on constructed CATUnicodeString. If the attribute has not been yet created, then the elements of ioSetting are used as default values, otherwise the elements of ioSetting are overwritten by the retrieved values.
iSize
The number of elements to read.
Returns:
Legal values:
>0: on Success returns the number of elements really read
0 : if a class conflict on the attribute has occured.
-1: on failure
o Rollback
public Rollback()
Restores a previous persistent copy of the CATSysPreferenceRepository in Memory.
Role: Restores the persistent memory copy of the CATSysPreferenceRepository, done by the lastest call to . All modifications that have occured on any attributes of the CATSysPreferenceRepository, since the lastest call to Commit, are discarded.
Returns:
Legal values S_OK on Success, otherwise negative.
o SaveRepository
public SaveRepository( const iReseved=NULL)
Makes a persistent copy of the CATsettingRepository on file.
Role: Makes first a persistent copy of the CATsettingRepository in Memory by calling , then writes on file the persistent representation
Parameters:
iReserved
reserved for internal use. Not to be used.
Returns:
Legal values 0 on Success, otherwise negative.
o WritePreference
public WritePreference( const iSettingName,
iSetting)
Sets the value of a setting attribute.
Role: Sets the value of an attribute of type CATString
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
pointer on a constructed CATString.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure
o WritePreference
public WritePreference( const iSettingName,
iSetting,
iLength=1)
Sets the value of a setting attribute which is an array of ints.
Role: Sets the values of each element of the array constituting the attribute. The array is defined as an array of initialized ints.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of initialized ints.
iLength
The size of the array.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure
o WritePreference
public WritePreference( const iSettingName,
iSetting,
iLength=1)
Sets the value of a setting attribute which is an array of chars.
Role: Sets the values of each element of the array constituting the attribute. The array is defined as an array of initialized char.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of initialized chars.
iLength
The size of the array.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure
o WritePreference
public WritePreference( const iSettingName,
iSetting,
iLength=1)
Sets the value of a setting attribute which is an array of floats.
Role: Sets the values of each element of the array constituting the attribute. The array is defined as an array of initialized floats.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of initialized floats.
iLength
The size of the array.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure
o WritePreference
public WritePreference( const iSettingName,
iSetting,
iLength=1)
Sets the value of a setting attribute which is an array of shorts.
Role: Sets the values of each element of the array constituting the attribute. The array is defined as an array of initialized shorts.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of initialized shorts.
iLength
The size of the array.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure
o WritePreference
public WritePreference( const iSettingName,
iSetting,
iLength=1)
Sets the value of a setting attribute which is an array of doubles.
Role: Sets the values of each element of the array constituting the attribute. The array is defined as an array of initialized doubles.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of initialized doubles.
iLength
The size of the array.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure
o WritePreference
public WritePreference( const iSettingName,
iSetting)
Sets the value of a setting attribute.
Role: Sets the value of an attribute of type CATBaseUnknown
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
An initialized CATBaseUnknow.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure
o WritePreference
public WritePreference( const iSettingName,
iSetting)
Sets the value of a setting attribute.
Role: Sets the value of an attribute of type CATUnicodeString
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
pointer on a constructed CATUnicodeString.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure
o WritePreference
public WritePreference( const iSettingName,
iSetting,
iSize)
Sets the value of a setting attribute which is an array of CATString.
Role: Sets the values of each element of the array constituting the attribute. The array is defined as an array of pointers on constructed CATString.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of pointeur on initialized CATString.
iSize
The size of the array.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure
o WritePreference
public WritePreference( const iSettingName,
iSetting,
iLength=1)
Sets the value of a setting attribute which is an array of unsigned ints.
Role: Sets the values of each element of the array constituting the attribute. The array is defined as an array of initialized unsigned ints.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of initialized unsigned ints.
iLength
The size of the array.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure
o WritePreference
public WritePreference( const iSettingName,
iSetting,
iSize)
Sets the value of a setting attribute which is an array of CATBaseUnknown.
Role: Sets the values of each element of the array constituting the attribute. The array is defined as an array of pointers on constructed CATBaseUnknown.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of pointeur on initialized CATBaseUnknow.
iSize
The size of the array.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure
o WritePreference
public WritePreference( const iSettingName,
iSetting,
iSize)
Sets the value of a setting attribute which is an array of CATUnicodeString.
Role: Sets the values of each element of the array constituting the attribute. The array is defined as an array of pointers on constructed CATUnicodeString.
Parameters:
iSettingName
The name of the attribute to be set.
Legal values: The length of the string must be less than or equal to
.
ioSetting
an array of pointeur on initialized CATUnicodeString.
iSize
The size of the array.
Returns:
Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure

This object is included in the file: CATSysPreferenceRepository.h
If needed, your Imakefile.mk should include the module: JS0GROUP

Copyright © 1999-2015, Dassault Systèmes. All rights reserved.