RADE |
Source Code Manager |
The Custom Checker LibraryUnderstanding and changing tests on command arguments |
Use Case |
Abstract
As part of the CAA RADE V5 environment, SCM supports the CAA V5
nomenclature like the maximum number of characters in a framework name
or the structure of a CAA file tree. The default behavior of SCM
commands is to check every arguments against those CAA V5 rules. |
When SCM commands are executed, some controls are performed to check the
validity of command's arguments.
These controls are realized by some checkers, especially:
Those checkers are located outside the configuration management kernel and gathered in a shared library that we will call the default library in the rest of this paper. | |
For a given installation of the SCM product, it is possible to create a
new library which will define some checkers for verifying specific rules. We will call this library the custom library. |
|
We will see that it is also possible to call the default checkers from the custom library. |
[Top]
Each time a command is executed, the arguments to be checked are passed to the corresponding checkers if exist. Some checkers can be found either in the default library or in the custom library:
We will see afterwards that it is also possible to call the default checkers from the custom checkers. So, depending on what has been written in the body of a custom checker, it is possible
[Top]
It is possible to build a custom library without having a full CAA V5 development environment installed. Only a C++ compiler is needed. The compilation and the creation of the library are performed by a specific tool.
[Top]
The custom library must export two functions that are recognized by the SCM
kernel and that are called when loading the custom library.
Here are their definitions:
const char *ADLCMGetAPIVersion();
This function must not be modified and is used by the kernel to avoid any inconsistency between the kernel and the custom library (especially when further versions of SCM will be installed upon an existing installation)
HRESULT ADLCMInitAPI(ADLCMAPIInterface &APIInterface)
This function is always called by the kernel and it allows
- the custom library to know the default checkers (located in the default library).
Then it will be able to call them from the custom checkers- the custom library to provide its own checkers in place of the default ones
The custom library sample that is provided with SCM performs the two operations: it registers the references to the default checkers and provides its own checkers
The other functions that are defined in the custom library are those corresponding to the custom checkers. To know the list of default checkers that can be redefined, consult the ADLCMAPIInterface class definition which propose a SetXXX() method for each XXX default checker.
Actually there are five checkers that can be defined in the custom library:
HRESULT ADLCMCheckArchiRules(ADLCMCheckArchiRulesArgs)
HRESULT ADLCMCheckIfUnixPathIsShared(ADLCMCheckIfUnixPathIsSharedArgs)
HRESULT ADLCMCheckSoftObj(ADLCMCheckSoftObjArgs)
HRESULT ADLCMCheckPromotionRequest(ADLCMCheckPromotionRequestArgs)
HRESULT ADLCMCheckFlow(ADLCMCheckFlowArgs)
In further SCM versions, it will be possible that other functions can be defined in the custom library. It is the reason why the ADLCMGetAPIVersion function must be implemented by the custom library.
[Top]
The custom library is initialized using the ADLCMInitAPI function. This function receives in input an instance of the class ADLCMAPIInterface which provides some methods for managing errors and messages in a format that can be handled by the kernel.
ADLCMAPIMsgBldrCtlg * MakeMsgBldrCtlg(const char *Catalog, const char *Code)
This method is used for creating a NLS message builder from a usual CAA message catalog file. See the section "Installing the Custom Checker Library" to know where such a message file can be delivered
HRESULT SetLastError(const char *SourcePath, int SourceLine, ADLCMAPIMsgBldr *pRequestBldr, ADLCMAPIMsgBldr *pDiagnosticBldr, ADLCMAPIMsgBldr *pAdviceBldr, ADLCMAPIErrorType ErrorType = ADLCMAPIErrorTypeCritical, HRESULT hr = E_FAIL)
This method is used for raising an error and defining the associated messages (which have been defined using the method MakeMsgBldrCtlg).
The following sample shows how to return to the SCM kernel an error with a relevant message:
HRESULT hr = S_OK; ... if (! UnixSharedPathFound) { ADLCMAPIMsgBldrCtlg *pRequestBldr = GetAPIInterface().MakeMsgBldrCtlg("ADLCMD", "0525"); // "Check the Unix network path \"/p1\"" pRequestBldr->AddNewParameter(Path); ADLCMAPIMsgBldrCtlg *pDiagnosticBldr = GetAPIInterface().MakeMsgBldrCtlg("ADLCMD", "0526"); // "The Unix network path \"/p1\" is invalid." pDiagnosticBldr->AddNewParameter(Path); ADLCMAPIMsgBldrCtlg *pAdviceBldr = GetAPIInterface().MakeMsgBldrCtlg("ADLCMD", "0527"); // "Use /p1 option or choose between the following path: /p2" pAdviceBldr->AddNewParameter(LocalPathOptionName); pAdviceBldr->AddNewParameter("/u/lego/, /u/users/"); hr = GetAPIInterface().SetLastError(__FILE__, __LINE__, pRequestBldr, pDiagnosticBldr, pAdviceBldr); delete pRequestBldr; delete pDiagnosticBldr; delete pAdviceBldr; } return hr; } |
[Top]
It is interesting to call a default checker when specific tests must be performed in addition to the default ones.
Considering a default checker whose name is XXX and which can be redefined, the ADLCMAPIInterface class provides two methods either
Then if you want to call a default checker from your own function, you have just to call the appropriate DlftXXX() method and to set its arguments with the values you want. This method will return a HRESULT value that will be tested to know whether the call was successful or not.
The following example shows the default checker called from the custom checker in the case where the object to be checked is a framework:
HRESULT ADLCMCheckArchiRules( const ADLCMAPIParsedProjPath &APIParsedProjPath, int ProjElemIdx, const char *User, Boolean &UnicityWithExtension, Boolean &UnicityInFolder) { HRESULT hr = S_OK; if (APIParsedProjPath.GetProjElem(ProjElemIdx).GetProjElemType() == ADLCMAPIProjElem::ArchiFramework) // Framework -> default check hr = GetAPIInterface().DfltCheckArchiRules( APIParsedProjPath, ProjElemIdx, User, UnicityWithExtension, UnicityInFolder); else if (Type == ADLCMAPIProjElem::ArchiModule) ... |
[Top]
This checker is called for every file or directory path given as argument to a SCM command (once per argument).
HRESULT ADLCMCheckArchiRules( const ADLCMAPIParsedProjPath &APIParsedProjPath, int ProjElemIdx, const char *User, Boolean &UnicityWithExtension, Boolean &UnicityInFolder) { ... } |
For instance, when the user runs the command adl_mk_elem Fw/module.m/src/foo.cpp, the ADLCMCheckArchiRules checker is called with the following arguments:
The rules enforced by the default checker are described in a dedicated paper [1]. Please consult it for learning more about the rules.
[Top]
This checker is called to check if a given UNIX path should be considered like a network path or not; that is to say that it will be considered by SCM command as referencing the same file system from any UNIX host of the current SCM installation. See the sample's sources for a full implementation of this checker.
HRESULT ADLCMCheckIfUnixPathIsShared(const char *Path, const char *LocalPathOptionName) { ... } |
The Unix paths that are considered as shared paths must begin either by /u/users or by /u/lego [2].
[Top]
This checker is called to check customer rules when a software object (framework, module, data, directory or element) is created, modified, deleted or imported. In the adl_mk_fw, adl_mk_mod, adl_mk_data, adl_mk_dir, adl_mk_elem, adl_co, adl_mv, adl_rm, adl_unrm, adl_import commands, for each software object treated this checker is called just before the validation of the action. See the sample's sources for a full implementation of this checker.
HRESULT ADLCMCheckSoftObj( const ADLCMAPIParsedProjPath &APIParsedProjPath, const ADLCMAPIParsedProjPath *pTargetAPIParsedProjPath, const char *CommandName, const char *User, const char *CurrentWsTree, const char *CurrentWs, const char *CurrentImage) { ... } |
[Top]
This checker is called for every promotion request in adl_promote command just before the validation of the transaction. See the sample's sources for a full implementation of this checker.
HRESULT ADLCMCheckPromotionRequest( const char *SoftObjChangesFilePath, const char *User, const char *CurrentWsTree, const char *CurrentWs, const char *PromotedWsRev, const char *TargetWs, const char *CurrentImage, Boolean Simulation) { ... } |
[Top]
This checker is called for every import with the adl_force_so_chg command just before the validation of the transaction.
HRESULT ADLCMCheckFlow( const char *FlowDataFilePath, const char *CommandName, const char *User, const char *CurrentWsTree, const char *CurrentWs, int NbOriginWsRev, const char *OriginWsRev[], const char *CurrentImage, Boolean Simulation) { ... } |
[Top]
Some parameters are complex objects with some attributes. They are described in one string with fields.
The file contains software object changes grouped by software object. For each modified software object, we found the _SOFT_OBJ line and for each change type the _SO_CHG_GRP_CR, __SO_CHG and ___CREATED lines.
The flow data file contains:
[Top]
A sample of the custom library is provided in the SCM installation: considering the directory specified when downloading the CAA RADE V5 CD-ROM, you should find the sample in XXX/resources/Adele/CustRulesLib directory (XXX can be intel_a, solaris_a, aix_a, etc).
As an example, here is a view on a Windows
installation:
|
[Top]
If you want to use your own tools to generate the custom library, just copy the source files under your environment, generate the library and install it with the NLS message files (if any) by following what is explained in the installation section. Otherwise you can use the MakeInstall program located in the directory where the sample source files are stored and execute it.
The purpose of the MakeInstall program is
Before using the tool, check the following prerequisites:
Here is an example where the library is produced under the temporary directory E:\MyLib:
MakeInstall E:\MyLib ############################################## Initialization ############################################## msgcatalog\ADLCMCUSTRULES.CATNls msgcatalog\French\ADLCMCUSTRULES.CATNls 2 File(s) copied ############################################## Compilation ############################################## ADLCMCustRules.cpp ADLCMCustStringUtilities.cpp ############################################## Link-edit ############################################## Creating library e:\MyLib\ADLCMCustRules\code\bin\ADLCMCustRules.lib and object e:\MyLib\ADLCMCustRules\code\bin\ADLCMCustRules.exp ############################################## End ############################################## Directory PATH listing Volume serial number is 0012FC94 8C79:E0CF E:\MYLIB\ADLCMCUSTRULES +---code ¦ +---bin ¦ ADLCMCustRules.dll ¦ ADLCMCustRules.exp ¦ ADLCMCustRules.lib ¦ ADLCMCustRules.pdb ¦ +---resources +---msgcatalog ¦ ADLCMCUSTRULES.CATNls ¦ +---French ADLCMCUSTRULES.CATNls The directory e:\MyLib\ADLCMCustRules has been successfully created. |
[Top]
Once the custom library generated, it must become visible by SCM commands. This is done using the ADL_CUST_RULES_LIB environment variable.
There are two cases:
Where to set this variable?
The best way should be to edit the SCM initialization profile [3] and to add the setting of this variable.
[Top]
The controls performed by SCM commands on their arguments can be changed by building a custom library and referencing it from the SCM initialization profile.
[Top]
[1] | CAA V5 Rules |
[2] | Default Unix Shared Paths |
[3] | SCM Initialization Profiles |
[4] | SCM output in program mode |
[Top] |
Version: 3 [Jul 2003] | Add one argument for checkers : ADLCMCheckPromotionRequest, ADLCMCheckFlow |
Version: 2 [Jan 2003] | New checkers : ADLCMCheckSoftObj, ADLCMCheckPromotionRequest, ADLCMCheckFlow |
Version: 1 [May 2001] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.