Tizen Native API  6.0
Component Based Application

Component based application API.

Required Header

#include <component_based_app.h>

Overview

The Component Based Application API provides functions for starting and exiting Tizen component based application. Tizen component based application can consist of frame_component and service_component. This API supports making multiple frame_components and service_components per an application.

Registering Callbacks for Application State Change Events

As for Tizen component based application states, it is very simple and somewhat similar to Tizen widget application states.

Callback Description
component_based_app_create_cb() The callback function is called before the main loop of the application starts. In this callback, you can initialize resources which can be shared among component instances. This function should return the handle for component class so that it will be used for making instances of component.
component_based_app_terminate_cb() This callback function is called once after the main loop of the application exits. You should release the resources of the application in this function.

Functions

int component_based_app_main (int argc, char **argv, component_based_app_lifecycle_callback_s *callback, void *user_data)
 Runs the main loop of the application until component_based_app_exit() is called.
int component_based_app_exit (void)
 Exits the main loop of the application.
component_class_h component_based_app_add_frame_component (component_class_h comp_class, const char *comp_id, frame_component_lifecycle_callback_s *callback, void *user_data)
 Adds a new frame component to comp_class.
component_class_h component_based_app_add_service_component (component_class_h comp_class, const char *comp_id, service_component_lifecycle_callback_s *callback, void *user_data)
 Adds a service component to comp_class.

Typedefs

typedef component_class_h(* component_based_app_create_cb )(void *user_data)
 Called when the application starts.
typedef void(* component_based_app_terminate_cb )(void *user_data)
 Called when the main loop of the application exits.

Typedef Documentation

typedef component_class_h(* component_based_app_create_cb)(void *user_data)

Called when the application starts.

The callback function is called before the main loop of the application starts. In this callback, you can initialize resources which can be shared among component instances. This function should return the handle for component class so that it will be used for making instances of component.

Since :
5.5
Remarks:
The returned object is managed by platform. You should not release the object.
Parameters:
[in]user_dataThe user data to be passed from the callback registration function
Returns:
The object of component class
See also:
component_based_app_main()
component_based_app_add_frame_component()
component_based_app_add_service_component()
typedef void(* component_based_app_terminate_cb)(void *user_data)

Called when the main loop of the application exits.

This callback function is called once after the main loop of the application exits. You should release the resources of the application in this function.

Since :
5.5
Parameters:
[in]user_dataThe user data to be passed from the callback registration function
See also:
component_based_app_main()

Function Documentation

component_class_h component_based_app_add_frame_component ( component_class_h  comp_class,
const char *  comp_id,
frame_component_lifecycle_callback_s callback,
void *  user_data 
)

Adds a new frame component to comp_class.

Adds a new frame component with comp_id to comp_class. If comp_class is null, the platform creates a component_class_h and adds a new frame component with comp_id and then return the component_class_h.

Since :
5.5
Remarks:
The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
The returned value is managed by the platform and will be released when the component_based_app_create_cb() function returns it.
Parameters:
[in]comp_classThe component class
[in]comp_idThe ID of the frame component
[in]callbackThe set of lifecycle callbacks of the frame component
[in]user_dataThe user data to be passed to the callback functions
Returns:
comp_class on success, otherwise NULL
Exceptions:
APP_ERROR_NONESucessful
APP_ERROR_INVALID_PARAMETERInvalid parameter
APP_ERROR_OUT_OF_MEMORYOut of memory
See also:
get_last_result()
component_class_h component_based_app_add_service_component ( component_class_h  comp_class,
const char *  comp_id,
service_component_lifecycle_callback_s callback,
void *  user_data 
)

Adds a service component to comp_class.

Adds a new service component with comp_id to comp_class. If comp_class is null, the platform creates a component_class_h and adds a new service component with comp_id and then return the component_class_h.

Since :
5.5
Remarks:
The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
The returned value is managed by the platform and will be released when the component_based_app_create_cb() function returns it.
Parameters:
[in]comp_classThe component class
[in]comp_idThe ID of the service component
[in]callbackThe set of lifecycle callbacks of the service component
[in]user_dataThe user data to be passed to the callback functions
Returns:
comp_class on success, otherwise NULL
Exceptions:
APP_ERROR_NONESucessful
APP_ERROR_INVALID_PARAMETERInvalid parameter
APP_ERROR_OUT_OF_MEMORYOut of memory
See also:
get_last_result()
int component_based_app_exit ( void  )

Exits the main loop of the application.

Since :
5.5
Returns:
0 on success, otherwise a negative error value
Return values:
APP_ERROR_NONESuccessful
int component_based_app_main ( int  argc,
char **  argv,
component_based_app_lifecycle_callback_s callback,
void *  user_data 
)

Runs the main loop of the application until component_based_app_exit() is called.

Since :
5.5
Parameters:
[in]argcThe argument count
[in]argvThe argument vector
[in]callbackThe set of callback functions to handle application events
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
APP_ERROR_NONESuccessful
APP_ERROR_INVALID_PARAMETERInvalid parameter
See also:
component_based_app_exit()