|
1 | 1 | --- |
2 | 2 | applyTo: "apis/**/I*.h" |
3 | 3 | --- |
4 | | - |
5 | | -# Interface Header Specification Instructions(apis/**/I*.h) |
6 | | -This document details the guidelines for defining interface headers for RDK Entertainment Services APIs, to ensure consistency and compliance with Thunder Plugins Interface standards. These guidelines have to be taken into account for each review. All interface headers MUST adhere to below Thunder Plugins Interface Guidelines. |
7 | 4 |
|
8 | | - |
9 | | -## Notification Interfaces |
| 5 | +## JSON RPC Tagging |
10 | 6 | ### Requirement: |
11 | | - - Notification interfaces MUST provide default (empty) implementations for notification methods; |
12 | | - - Do NOT use pure virtual methods. |
13 | | - - A single method can be defined in more than one line for code readability. |
14 | | - ### Example: |
15 | | - /* @event */ |
16 | | - struct EXTERNAL INotification : virtual public Core::IUnknown { |
17 | | - // ... |
18 | | - virtual void OnFontColorChanged(const string& color) {}; // Default implementation |
19 | | - // ... |
20 | | - }; |
21 | | - ### Incorrect Example: |
22 | | - /* @event */ |
23 | | - struct EXTERNAL INotification : virtual public Core::IUnknown { |
24 | | - // ... |
25 | | - virtual void OnFontColorChanged(const string& color) = 0; // Pure virtual method |
26 | | - // ... |
27 | | - }; |
28 | | - |
29 | | -## Method Return Type |
30 | | - ### Requirement: |
31 | | - - All methods MUST return Core::hresult. |
32 | | - - Notification Methods need not return Core::hresult. |
33 | | - ### Example: |
34 | | - virtual Core::hresult BindDriver(const string& deviceName) const = 0; |
35 | | - |
36 | | -## API & Event Naming for Interface and JSON RPC |
37 | | - ### PascalCase in Interface Header and COMRPC: |
38 | | - - Method & Event names SHOULD be in Pascal Case. |
39 | | - |
40 | | - ### Example |
41 | | - virtual Core::hresult **BindDriver**(const string& deviceName) const = 0; |
42 | | - |
43 | | - virtual void **OnDevicePluggedIn**(const USBDevice& device) {} |
44 | | - |
45 | | - ### camelCase for JSON RPC (using @text annotation): |
46 | | - - API & Event names SHOULD be defined in camel case for json-rpc definition via Thunder Framework tags. |
47 | | - ### Example |
48 | | - **// @text bindDriver** |
49 | | - virtual Core::hresult BindDriver(const string& deviceName) const = 0; |
50 | | - **// @text onDevicePluggedIn** |
51 | | - virtual void OnDevicePluggedIn(const USBDevice& device) {}; |
| 7 | + If an interface implements JSON-RPC and includes the @json tag, then: |
| 8 | + |
| 9 | + The interface must specify it's version (e.g., @json 1.0.0). |
52 | 10 |
|
53 | | -## Enum Naming |
54 | | - ### Requirement: |
55 | | - - Enum names SHOULD be ALL_UPPER_SNAKE_CASE. |
56 | | - - Enum names SHOULD NOT contain any special characters other than underscore. |
57 | | - |
58 | | - ### Example: |
59 | | - enum USBStorageMountFlags : uint8_t { |
60 | | - READ_ONLY = 1, // READ ONLY |
61 | | - READ_WRITE = 2 // READ WRITE |
62 | | - }; |
63 | | - #### Exception: |
64 | | - Standardized names (e.g., kHz) MAY be exempt. |
| 11 | + The interface must also include the @text:keep tag. |
65 | 12 |
|
66 | | -## Getter/Setter Naming |
67 | | - ### Requirement: |
68 | | - - API getters SHALL always start with get and Setters SHALL always start with set. |
69 | | - - All the getter and setter method names should be in PascalCase. |
70 | | - - All the getter and setter method names should be in camelCase when defining via @text annotations/tags. |
71 | 13 | ### Example: |
72 | | - // @text getDefaultInterface |
73 | | - virtual Core::hresult GetDefaultInterface(/* ... */) const = 0; |
74 | | - // @text setDefaultInterface |
75 | | - virtual Core::hresult SetDefaultInterface(/* ... */) = 0; |
76 | | - |
77 | | -## Event Naming Convention |
78 | | - ### Format: |
79 | | - - Event names SHOULD follow on[Object][Action]. |
80 | | - - Event names not starting with on and not following this naming convention order should be flagged as errors during code review. |
81 | | - - Object: Noun giving context. |
82 | | - - Action: Verb (present/past tense for timing). |
83 | | - ### Interface Header Example (PascalCase): |
84 | | - struct EXTERNAL INotification : virtual public Core::IUnknown { |
85 | | - // ... |
86 | | - virtual void **OnAppResumed**() {} |
87 | | - // ... |
88 | | - } |
89 | | - struct EXTERNAL INotification : virtual public Core::IUnknown { |
90 | | - // ... |
91 | | - virtual void **OnAppResuming**() {} |
92 | | - //... |
93 | | - } |
94 | | - |
95 | | - ### JSON RPC Example (camelCase via annotation): |
96 | | - struct EXTERNAL INotification : virtual public Core::IUnknown { |
97 | | - // ... |
98 | | - // @text **onAppResumed** |
99 | | - virtual void OnAppResumed() {}; |
100 | | - // ... |
101 | | - } |
102 | | - |
103 | | - struct EXTERNAL INotification : virtual public Core::IUnknown { |
104 | | - // ... |
105 | | - // @text **onAppResuming** |
106 | | - virtual void OnAppResuming() {}; |
107 | | - // ... |
108 | | - } |
109 | | - |
| 14 | + /* @json 1.0.0 @text:keep */ |
| 15 | + struct EXTERNAL ITextTrack : virtual public Core::IUnknown { |
| 16 | + // ... |
| 17 | + }; |
| 18 | + |
110 | 19 | ## Acronym Capitalization |
111 | 20 | ### Requirement: |
112 | 21 | - Acronyms SHOULD be fully capitalized. |
113 | 22 |
|
114 | 23 | ### Example: |
115 | 24 | virtual Core::hresult SetHDMIEnabled(bool enabled) = 0; |
116 | 25 | // NOT: SetHdmiEnabled |
| 26 | + |
| 27 | + |
| 28 | +## Documentation Tags Guidelines |
| 29 | + To ensure consistency and clarity in interface documentation, each method, event, and struct member must be annotated using the following tags. If any methods/events/struct members have not been annotated with the tags below, then they should be flagged as an error during PR review. |
| 30 | + |
| 31 | + ### Required Tags: |
| 32 | + |
| 33 | + - @brief — A concise description of the purpose or behavior. |
| 34 | + - @param — Description of each parameter, including its name and purpose. |
| 35 | + - @retval <ErrorCode>: <Description> — Used to describe each return code associated with a function or property. These descriptions will be included in the generated markdown documentation. |
| 36 | + - @details (optional) — Additional information or extended explanation. |
| 37 | + |
| 38 | + ### Method Example: |
| 39 | + // @text onApplicationStateChanged |
| 40 | + // @brief Triggered when the cast service receives an application state change notification from a client |
| 41 | + // @param applicationName: Registered application name |
| 42 | + // @param state: Application state |
| 43 | + // @param applicationId: Application instance ID |
| 44 | + // @param error: Error string, if any |
| 45 | + // @retval ErrorCode::NONE: Indicates successful state change |
| 46 | + // @retval ErrorCode::FORBIDDEN: Operation is not permitted |
| 47 | + // @retval ErrorCode::UNAVAILABLE: Requested resource is not available |
| 48 | + // @retval ErrorCode::INVALID: Provided state is not recognized |
| 49 | + // @retval ErrorCode::INTERNAL: Internal server error occurred |
| 50 | + virtual Core::hresult ApplicationStateChanged( |
| 51 | + const string& applicationName /* @text applicationName */, |
| 52 | + const State& state /* @text state */, |
| 53 | + const string& applicationId /* @text applicationId */, |
| 54 | + const ErrorCode& error /* @text error */ |
| 55 | + ) = 0; |
| 56 | + |
| 57 | + ### Event Example: |
| 58 | + struct EXTERNAL INotification : virtual public Core::IUnknown { |
| 59 | + // @text onApplicationLaunchRequest |
| 60 | + // @brief Triggered when the cast service receives a launch request from a client with launch params |
| 61 | + // @param applicationName: Registered application name |
| 62 | + // @param strPayLoad: Payload string to be passed to the application |
| 63 | + // @param strQuery: Query string to be appended in launch request |
| 64 | + // @param strAddDataUrl: Additional data URL to be passed to the application |
| 65 | + virtual void OnApplicationLaunchRequestWithLaunchParam( |
| 66 | + const string& appName /* @text applicationName */, |
| 67 | + const string& strPayLoad /* @text strPayLoad */, |
| 68 | + const string& strQuery /* @text strQuery */, |
| 69 | + const string& strAddDataUrl /* @text strAddDataUrl */ |
| 70 | + ) {} |
| 71 | + }; |
| 72 | + |
| 73 | + ### Struct Member Example: |
| 74 | + struct EXTERNAL ApplicationInfo { |
| 75 | + string appName /* @text names */ |
| 76 | + /* @brief Group of acceptable names for a related application. Application name in request URI must have exact match to one of the names. Otherwise, matching prefix is needed. If the application name in request URI does not match any names or prefixes, then the request shall fail */; |
| 77 | + |
| 78 | + string prefixes /* @text prefixes */ |
| 79 | + /* @brief If the application name in request URI does not match the list of names, it must contain one of the prefixes. If the application name in request URI does not match any names or prefixes, then the request shall fail */; |
| 80 | + |
| 81 | + string cors /* @text cors */ |
| 82 | + /* @brief A set of origins allowed for the application. This must not be empty */; |
| 83 | + |
| 84 | + string query /* @text query */ |
| 85 | + /* @brief Query string that needs to be appended in launch request */; |
| 86 | + |
| 87 | + string payload /* @text payload */ |
| 88 | + /* @brief Optional payload string that needs to be appended in launch request */; |
| 89 | + |
| 90 | + int allowStop /* @text allowStop */ |
| 91 | + /* @brief Indicates whether the application (matching name list or prefix list) is allowed to stop (no PID presence) after launch */; |
| 92 | + }; |
0 commit comments