# SamgrLite ## **Overview** **Related Modules:** [Samgr](Samgr.md) **Description:** Represents the system ability management class. This class is used for registering and discovering services, features, and functions. **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Data Fields

Variable Name

Description

RegisterService )(Service *service)

BOOL(* 

Registers a service.

UnregisterService )(const char *name)

Service *(* 

Unregisters a service.

RegisterFeature )(const char *serviceName, Feature *feature)

BOOL(* 

Registers a feature.

UnregisterFeature )(const char *serviceName, const char *featureName)

Feature *(* 

Unregisters a feature.

RegisterDefaultFeatureApi )(const char *service, IUnknown *publicApi)

BOOL(* 

Registers the API for the default feature of a service.

UnregisterDefaultFeatureApi )(const char *service)

IUnknown *(* 

Unregisters the API from the default feature of a service.

RegisterFeatureApi )(const char *service, const char *feature, IUnknown *publicApi)

BOOL(* 

Registers the API for a feature.

UnregisterFeatureApi )(const char *service, const char *feature)

IUnknown *(* 

Unregisters the API from a feature.

GetDefaultFeatureApi )(const char *service)

IUnknown *(* 

Obtains the API specific to the default feature.

GetFeatureApi )(const char *serviceName, const char *feature)

IUnknown *(* 

Obtains the API specific to the feature.

## **Details** ## **Field Documentation** ## GetDefaultFeatureApi ``` [IUnknown](IUnknown.md)*(* SamgrLite::GetDefaultFeatureApi) (const char *service) ``` **Description:** Obtains the API specific to the default feature. You need to call this function before using the system capabilities of the service involved. **Parameters:**

Name

Description

service Indicates the name of the service to which the default feature belongs.
**Returns:** Returns the **[IUnknown](IUnknown.md) \*** object that can be called if the operation is successful; returns **NULL** if the operation fails. ## GetFeatureApi ``` [IUnknown](IUnknown.md)*(* SamgrLite::GetFeatureApi) (const char *serviceName, const char *feature) ``` **Description:** Obtains the API specific to the feature. You need to call this function before using the system capabilities of the service involved. **Parameters:**

Name

Description

service Indicates the name of the service to which the feature belongs.
feature Indicates the name of the feature whose API will be obtained.
**Returns:** Returns the **[IUnknown](IUnknown.md) \*** object that can be called if the operation is successful; returns **NULL** if the operation fails. ## RegisterDefaultFeatureApi ``` BOOL(* SamgrLite::RegisterDefaultFeatureApi) (const char *service, [IUnknown](IUnknown.md) *publicApi) ``` **Description:** Registers the API for the default feature of a service. You need to call this function after the service is registered. The pointers to the [IUnknown](IUnknown.md) and [IUnknown](IUnknown.md) members to be registered cannot be empty. **Parameters:**

Name

Description

service Indicates the name of the service whose default feature's API will be registered.
publicApi Indicates the API to be registered.
**Returns:** Returns **TRUE** if the registration is successful; returns **FALSE** if the registration fails. ## RegisterFeature ``` BOOL(* SamgrLite::RegisterFeature) (const char *serviceName, [Feature](Feature.md) *feature) ``` **Description:** Registers a feature. You need to call this function in the startup entry of each feature. [Feature](Feature.md) and [Feature](Feature.md) structure members to be registered cannot be empty. **Parameters:**

Name

Description

feature Indicates the feature to be registered.
**Returns:** Returns **TRUE** if the registration is successful; returns **FALSE** if the registration fails. ## RegisterFeatureApi ``` BOOL(* SamgrLite::RegisterFeatureApi) (const char *service, const char *feature, [IUnknown](IUnknown.md) *publicApi) ``` **Description:** Registers the API for a feature. You can call this function only if the feature has been registered. The pointers to the [IUnknown](IUnknown.md) and [IUnknown](IUnknown.md) members to be registered cannot be empty. **Parameters:**

Name

Description

service Indicates the name of the service whose API will be registered.
feature Indicates the name of the feature whose API will be registered.
publicApi Indicates the API to be registered.
**Returns:** Returns **TRUE** if the registration is successful; returns **FALSE** if the registration fails. ## RegisterService ``` BOOL(* SamgrLite::RegisterService) ([Service](Service.md) *service) ``` **Description:** Registers a service. You need to call this function in the startup entry of each service. [Service](Service.md) and [Service](Service.md) structure members to be registered cannot be empty. **Parameters:**

Name

Description

service Indicates the service to be registered.
**Returns:** Returns **TRUE** if the registration is successful; returns **FALSE** if the registration fails. ## UnregisterDefaultFeatureApi ``` [IUnknown](IUnknown.md)*(* SamgrLite::UnregisterDefaultFeatureApi) (const char *service) ``` **Description:** Unregisters the API from the default feature of a service. You need to call this function to unregister [IUnknown](IUnknown.md) if the service to which the default feature belongs is no longer required. **Parameters:**

Name

Description

service Indicates the name of the service whose default feature's API will be unregistered.
**Returns:** Returns the unregistered function object if the unregistration is successful. The memory is released by the caller. Returns **NULL** if the unregistration fails. ## UnregisterFeature ``` [Feature](Feature.md)*(* SamgrLite::UnregisterFeature) (const char *serviceName, const char *featureName) ``` **Description:** Unregisters a feature. You need to call this function when the feature is no longer required. **Parameters:**

Name

Description

serviceName Indicates the name of the service whose feature will be unregistered.
featureName Indicates the name of the feature to be unregistered.
**Attention:** Before unregistering the feature, you must unregister its functions. Otherwise, the unregistration fails. **Returns:** Returns the unregistered feature object if the unregistration is successful. The memory is released by the caller. Returns **NULL** if the unregistration fails. ## UnregisterFeatureApi ``` [IUnknown](IUnknown.md)*(* SamgrLite::UnregisterFeatureApi) (const char *service, const char *feature) ``` **Description:** Unregisters the API from a feature. You must call this function before unregistering the feature no longer required. **Parameters:**

Name

Description

service Indicates the name of the service whose API will be unregistered.
feature Indicates the name of the feature whose API will be unregistered.
**Returns:** Returns the unregistered function object if the unregistration is successful. The memory is released by the caller. Returns **NULL** if the unregistration fails. ## UnregisterService ``` [Service](Service.md)*(* SamgrLite::UnregisterService) (const char *name) ``` **Description:** Unregisters a service. You need to call this function when the service is no longer required. **Parameters:**

Name

Description

name Indicates the name of the service to be unregistered.
**Attention:** Before unregistering the service, you must unregister its features and functions. **Returns:** Returns the unregistered service object if the unregistration is successful. The memory is released by the caller. Returns **NULL** if the unregistration fails.