huigezrx |分类标签:CAA 2015-01-21

CAA开发的插件程序如何保存运行参数

CAA程序有时候需要保存运行参数,如数据库服务器的信息,FTP服务器的信息以及一些其它运行参数,CAA程序实现的方式有哪些呢?

满意答案

huigezrx 19级 2015-01-21 19:34:18

使用CATSettingRepository类的相关函数可以实现对应功能,该类的解释如下:

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

Each CATSettingRepository has a unique name used by the application to access it. Each attribute within one CATSettingRepository 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 CATSettingRepository instance can be saved in memory for temporary storage using a commit/rollback mechanism, and in a file for persistent storage.

主要使用到的函数有如下几个:

public long Commit( int iNoEvent=0)    

Makes a persistent copy of the CATsettingRepository in Memory.
Role: Makes a persistent copy of the CATsettingRepository in Memory The values of the attributes could be restore after that by doing a call to Rollback.

Parameters:

iNoEvent

In order to emit the commit event
Legal values: 0 to emit the event (the default) and 1 for no emission

Returns:

Legal values 1 on Success, otherwise -1. 

public static CATSettingRepository* GetRepository(const char* iRepositoryName, int iMode =0, AccessType iType=Prj,    

CATISysSettingController* iCtrl=0)    

Creates a CATSettingRepository.
Role: Creates the unique instance of the class CATSettingRepository named with the given argument. If a setting file exists, it is read.
Lifecycle rules deviation: The Applications must not call release on the returned pointer.

Parameters:

iRepositoryName

The name of the CATSettingRepository used by the applications to retrieve it.

iMode

Reserved for internal use. Must always be set to 0. Legal values: The length of the string must be less than or equal to MAXSETTINGNAME.

iType

Defines the type of the setting.

iCtrl

pointer to the controler Interfaces. 

public long ReadSetting(const char*  iSettingName, CATString*     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 WriteSetting () 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 MAXSETTINGNAME.

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  

public long WriteSetting(const char* iSettingName, CATString*     iSetting,    

int  iFlag =0)    

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 MAXSETTINGNAME.

ioSetting

pointer on a constructed CATString.

iFlag

reserved for internal use. do not use other values than the default one.

Returns:

Legal values:
1 : on Success
0 : if a class conflict on the attribute has occured.
-1: on failure  

其他回答(0)

相关知识

相关文章更多