Using CICS resources

To use a CICS® resource, such as a file or program, you must first create an appropriate object and then call methods on the object.

Creating a resource object

When you create a resource object you create a representation of the actual CICS resource (such as a file or program). You do not create the CICS resource; the object is simply the application's view of the resource. The same is true of destroying objects.

You are recommended to use an accompanying resource identification object when creating a resource object. For example:

IccFileId  id("XYZ123");
IccFile    file(id);

This allows the C++ compiler to protect you against doing something wrong such as:

IccDataQueueId  id("WXYZ");
IccFile         file(id);       //gives error at compile time

The alternative of using the text name of the resource when creating the object is also permitted:

IccFile  file("XYZ123");

Singleton classes

Many resource classes, such as IccFile, can be used to create multiple resource objects within a single program:

IccFileId   id1("File1");
IccFileId   id2("File2");
IccFile     file1(id1);
IccFile     file2(id2);

However, some resource classes are designed to allow the programmer to create only one instance of the class; these are called singleton classes. The following Foundation Classes are singleton:

Any attempt to create more than one object of a singleton class results in an error - a C++ exception is thrown.

A class method, instance, is provided for each of these singleton classes, which returns a pointer to the requested object and creates one if it does not already exist. For example:

IccControl* pControl = IccControl::instance();

Calling methods on a resource object

Any of the public methods can be called on an object of that class. For example:

IccTempStoreId id("TEMP1234");
IccTempStore   temp(id);
temp.writeItem("Hello TEMP1234");

Method writeItem writes the contents of the string it is passed ("Hello TEMP1234") to the CICS Temporary Storage queue "TEMP1234".

[[ Contents Previous Page | Next Page Index ]]