Using KosObject containers (objcontainer.h)
The API is defined in the header file sysroot-*-kos/include/kos/objcontainer.h
from the KasperskyOS SDK.
The API lets you merge KosObjects
into containers to conveniently use sets of these objects (for details about KosObjects
, see Using KosObjects (objects.h)). The containers are also KosObjects
and may be elements of other containers. The same KosObject
may be an element of multiple containers at the same time.
Information about API functions is provided in the table below.
Creating a container
To create a container, call the KosCreateObjContainer()
function. In the parent
parameter, you can specify the ID of the parent container, which is the container to which the created container will be added.
Adding an object to a container
To add an object to a container, call the KosInsertObjContainerObject()
function. An object can be another container. You must use the name
parameter to define the object name that this object will have within the container. This name is not related to the name that was defined when the object was created. The name of an object within a container must be unique so that this object can be unambiguously identified among other objects in this container. When an object is added to a container, the counter for links to this object is incremented.
Removing an object from a container
To remove an object from a container, call the KosRemoveObjContainerObjectByName()
or KosRemoveObjContainerObject()
function. When an object is removed from a container, the counter for links to this object is decremented.
Searching for an object in a container
To search for an object with the defined name in a container, call the KosGetObjContainerObjectByName()
function. Child containers will not be searched for the object. This function increments the counter for links to the found object.
Enumerating objects in a container
Enumeration may be necessary to perform specific actions with multiple objects in a container. To enumerate objects in a container, call the KosWalkObjContainerObjects()
function. Use the walk
parameter to define the callback function that is called for each object during enumeration and receives pointers to the object and data that is passed to the KosWalkObjContainerObjects()
function via the context
parameter. Objects in child containers are not enumerated.
Enumerating the names of objects in a container
To enumerate the names of objects in a container, use the KosEnumObjContainerNames()
function. The order of enumeration for object names matches the order in which these objects are added to the container. Object names in child containers are not enumerated.
Getting the number of objects in a container
To get the number of objects in a container, call the KosCountObjContainerObjects()
function. Objects in child containers are not taken into account.
Clearing a container
To remove all objects from a container, call the KosClearObjContainer()
function. This function decrements the counters for links to objects that are removed from the container.
Checking whether an object is a container
To check whether an object is a container, call the KosIsContainer()
function.
Deleting a container
To delete a container, call the KosDestroyObjContainer()
function. When a container is deleted, the counters for links to objects within this container are decremented.
Information about API functions
objcontainer.h functions
Function |
Information about the function |
---|---|
|
Purpose Creates a container. Parameters
Returned values If successful, the function returns |
|
Purpose Deletes a container. Parameters
Returned values If successful, the function returns |
|
Purpose Adds an object to a container. Parameters
Returned values If successful, the function returns |
|
Purpose Removes the object with the defined name from a container. Parameters
Returned values If successful, the function returns |
|
Purpose Removes an object from a container. Parameters
Returned values If successful, the function returns |
|
Purpose Searches a container for the object with the defined name. Parameters
Returned values If successful, the function returns Additional information If an object with the defined name is not found, the function returns the |
|
Purpose Enumerates objects in a container and calls the defined function for each object during enumeration. Parameters
Returned values If successful, the function returns Additional information The callback function defined via the If a callback function defined via the If a callback function defined via the The |
|
Purpose Enumerates the names of objects in a container. Parameters
Returned values If successful, the function returns Additional information The |
|
Purpose Gets the number of objects in a container. Parameters
Returned values Number of objects in a container. |
|
Purpose Clears a container. Parameters
Returned values If successful, the function returns |
|
Purpose Checks whether an object is a container. Parameters
Returned values If the verification is successful, the function returns |