提交 ec1c1b9f 编写于 作者: X xuyong

更新开发指导说明

Signed-off-by: Nxuyong <xuyong59@huawei.com>
上级 222bd1ad
......@@ -15,7 +15,7 @@ HiSysEvent supports listening for events across processes. You can register a li
</th>
</tr>
</thead>
<tbody><tr id="row16441155818499"><td class="cellrowborder" valign="top" width="48.120000000000005%" headers="mcps1.2.3.1.1 "><p id="p877916438211"><a name="p877916438211"></a><a name="p877916438211"></a>int HiSysEventManager::AddEventListener(std::shared_ptr&lt;HiSysEventSubscribeCallBackBase&gt; listener, std::vector&lt;struct ListenerRule&gt;&amp; rules)</p>
<tbody><tr id="row16441155818499"><td class="cellrowborder" valign="top" width="48.120000000000005%" headers="mcps1.2.3.1.1 "><p id="p877916438211"><a name="p877916438211"></a><a name="p877916438211"></a>int HiSysEventManager::AddEventListener(std::shared_ptr&lt;HiSysEventSubscribeCallBack&gt; listener, std::vector&lt;struct ListenerRule&gt;&amp; rules)</p>
</td>
<td class="cellrowborder" valign="top" width="51.88%" headers="mcps1.2.3.1.2 "><p id="p14727325133216"><a name="p14727325133216"></a><a name="p14727325133216"></a>Registers a listener for system events. You can listen for certain events by specifying rules.</p>
<p id="p167271525203213"><a name="p167271525203213"></a><a name="p167271525203213"></a>Input arguments:</p>
......@@ -24,7 +24,7 @@ HiSysEvent supports listening for events across processes. You can register a li
<a name="ul12105842111913"></a><a name="ul12105842111913"></a><ul id="ul12105842111913"><li><strong id="b117641849702"><a name="b117641849702"></a><a name="b117641849702"></a>0</strong>: Repeated registration is successful.</li><li><strong id="b2682415314"><a name="b2682415314"></a><a name="b2682415314"></a>1</strong>: Initial registration is successful.</li><li>Other values: Registration has failed.</li></ul>
</td>
</tr>
<tr id="row910319443242"><td class="cellrowborder" valign="top" width="48.120000000000005%" headers="mcps1.2.3.1.1 "><p id="p15104154411248"><a name="p15104154411248"></a><a name="p15104154411248"></a>void HiSysEventManager::RemoveListener(std::shared_ptr&lt;HiSysEventSubscribeCallBackBase&gt; listener)</p>
<tr id="row910319443242"><td class="cellrowborder" valign="top" width="48.120000000000005%" headers="mcps1.2.3.1.1 "><p id="p15104154411248"><a name="p15104154411248"></a><a name="p15104154411248"></a>void HiSysEventManager::RemoveListener(std::shared_ptr&lt;HiSysEventSubscribeCallBack&gt; listener)</p>
</td>
<td class="cellrowborder" valign="top" width="51.88%" headers="mcps1.2.3.1.2 "><p id="p1104194420248"><a name="p1104194420248"></a><a name="p1104194420248"></a>Removes the listener for system events.</p>
<p id="p7943171095411"><a name="p7943171095411"></a><a name="p7943171095411"></a>Input arguments:</p>
......@@ -72,7 +72,7 @@ HiSysEvent supports listening for events across processes. You can register a li
</th>
</tr>
</thead>
<tbody><tr id="row111823719274"><td class="cellrowborder" valign="top" width="48.25%" headers="mcps1.2.3.1.1 "><p id="p161181537112712"><a name="p161181537112712"></a><a name="p161181537112712"></a>void HiSysEventSubscribeCallBackBase::OnHandle(const std::string&amp; domain, const std::string&amp; eventName, const int eventType, const std::string&amp; eventDetail)</p>
<tbody><tr id="row111823719274"><td class="cellrowborder" valign="top" width="48.25%" headers="mcps1.2.3.1.1 "><p id="p161181537112712"><a name="p161181537112712"></a><a name="p161181537112712"></a>void HiSysEventSubscribeCallBack::OnHandle(const std::string&amp; domain, const std::string&amp; eventName, const int eventType, const std::string&amp; eventDetail)</p>
</td>
<td class="cellrowborder" valign="top" width="51.74999999999999%" headers="mcps1.2.3.1.2 "><p id="p1772213111011"><a name="p1772213111011"></a><a name="p1772213111011"></a>Callback object for system events.</p>
<p id="p182081719151016"><a name="p182081719151016"></a><a name="p182081719151016"></a>Input arguments:</p>
......@@ -97,11 +97,11 @@ In this example, you'll be instructed to register a listener for all system even
- Implement the callback API.
HiSysEventSubscribeCallBackBase::OnHandle\(const std::string& domain, const std::string& eventName, const int eventType, const std::string& eventDetail\)
HiSysEventSubscribeCallBack::OnHandle\(const std::string& domain, const std::string& eventName, const int eventType, const std::string& eventDetail\)
- Register a callback object.
HiSysEventManager::AddEventListener\(std::shared\_ptr<HiSysEventSubscribeCallBackBase\> listener, std::vector<struct ListenerRule\>& rules\)
HiSysEventManager::AddEventListener\(std::shared\_ptr<HiSysEventSubscribeCallBack\> listener, std::vector<struct ListenerRule\>& rules\)
```
......
......@@ -15,7 +15,7 @@ HiSysEvent provides an API for you to query system events. You can query concern
</th>
</tr>
</thead>
<tbody><tr id="row16441155818499"><td class="cellrowborder" valign="top" width="48.120000000000005%" headers="mcps1.2.3.1.1 "><p id="p114411558204915"><a name="p114411558204915"></a><a name="p114411558204915"></a>bool HiSysEventManager::QueryHiSysEvent(struct QueryArg&amp; queryArg, std::vector&lt;struct QueryRule&gt;&amp; queryRules, std::shared_ptr&lt;HiSysEventQueryCallBackBase&gt; queryCallBack)</p>
<tbody><tr id="row16441155818499"><td class="cellrowborder" valign="top" width="48.120000000000005%" headers="mcps1.2.3.1.1 "><p id="p114411558204915"><a name="p114411558204915"></a><a name="p114411558204915"></a>bool HiSysEventManager::QueryHiSysEvent(struct QueryArg&amp; queryArg, std::vector&lt;struct QueryRule&gt;&amp; queryRules, std::shared_ptr&lt;HiSysEventQueryCallBack&gt; queryCallBack)</p>
</td>
<td class="cellrowborder" valign="top" width="51.88%" headers="mcps1.2.3.1.2 "><p id="p14727325133216"><a name="p14727325133216"></a><a name="p14727325133216"></a>Queries system events by specifying search criteria such as the time segment, event domain, and event name.</p>
<p id="p167271525203213"><a name="p167271525203213"></a><a name="p167271525203213"></a>Input arguments:</p>
......@@ -90,7 +90,7 @@ HiSysEvent provides an API for you to query system events. You can query concern
</th>
</tr>
</thead>
<tbody><tr id="row35141554151115"><td class="cellrowborder" valign="top" width="48.03%" headers="mcps1.2.3.1.1 "><p id="p4714143785410"><a name="p4714143785410"></a><a name="p4714143785410"></a>void HiSysEventQueryCallBackBase::OnQuery(const ::std::vector&lt;std::string&gt;&amp; sysEvent, const ::std::vector&lt;int64_t&gt;&amp; seq)</p>
<tbody><tr id="row35141554151115"><td class="cellrowborder" valign="top" width="48.03%" headers="mcps1.2.3.1.1 "><p id="p4714143785410"><a name="p4714143785410"></a><a name="p4714143785410"></a>void HiSysEventQueryCallBack::OnQuery(const ::std::vector&lt;std::string&gt;&amp; sysEvent, const ::std::vector&lt;int64_t&gt;&amp; seq)</p>
</td>
<td class="cellrowborder" valign="top" width="51.970000000000006%" headers="mcps1.2.3.1.2 "><p id="p1772213111011"><a name="p1772213111011"></a><a name="p1772213111011"></a>Callback object for event query.</p>
<p id="p182081719151016"><a name="p182081719151016"></a><a name="p182081719151016"></a>Input arguments:</p>
......@@ -98,7 +98,7 @@ HiSysEvent provides an API for you to query system events. You can query concern
<p id="p18209419201010"><a name="p18209419201010"></a><a name="p18209419201010"></a>Return value: none</p>
</td>
</tr>
<tr id="row15141154161111"><td class="cellrowborder" valign="top" width="48.03%" headers="mcps1.2.3.1.1 "><p id="p561110151119"><a name="p561110151119"></a><a name="p561110151119"></a>void HiSysEventQueryCallBackBase::OnComplete(int32_t reason, int32_t total)</p>
<tr id="row15141154161111"><td class="cellrowborder" valign="top" width="48.03%" headers="mcps1.2.3.1.1 "><p id="p561110151119"><a name="p561110151119"></a><a name="p561110151119"></a>void HiSysEventQueryCallBack::OnComplete(int32_t reason, int32_t total)</p>
</td>
<td class="cellrowborder" valign="top" width="51.970000000000006%" headers="mcps1.2.3.1.2 "><p id="p126315352130"><a name="p126315352130"></a><a name="p126315352130"></a>Callback object for completion of event query.</p>
<p id="p6631235191316"><a name="p6631235191316"></a><a name="p6631235191316"></a>Input arguments:</p>
......@@ -123,13 +123,13 @@ In this example, you'll be instructed to query all system events.
- Implement the callback API.
void HiSysEventQueryCallBackBase::OnQuery\(const ::std::vector<std::string\>& sysEvent, const ::std::vector<int64\_t\>& seq\)
void HiSysEventQueryCallBack::OnQuery\(const ::std::vector<std::string\>& sysEvent, const ::std::vector<int64\_t\>& seq\)
void HiSysEventQueryCallBackBase::OnComplete\(int32\_t reason, int32\_t total\)
void HiSysEventQueryCallBack::OnComplete\(int32\_t reason, int32\_t total\)
- Invoke the query API in the corresponding service logic.
HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector<struct QueryRule\>& queryRules, std::shared\_ptr<HiSysEventQueryCallBackBase\> queryCallBack\)
HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector<struct QueryRule\>& queryRules, std::shared\_ptr<HiSysEventQueryCallBack\> queryCallBack\)
```
......
......@@ -4,7 +4,7 @@
- **[HiSysEvent Listening](subsys-dfx-hisysevent-listening.md)**
- **[HiSysEvent Query](subsys-dfx-hisysevent-query.md)**
- **[HiSysEvent Query](subsys-dfx-hisysevent-querying.md)**
- **[HiSysEvent Tool Usage](subsys-dfx-hisysevent-tool.md)**
......
......@@ -27,8 +27,8 @@ HiSysEvent提供了跨进程订阅机制,开发者可以通过注册订阅接
| 接口名称 | 描述 |
| -------- | --------- |
|int HiSysEventManager::AddEventListener(std::shared_ptr&lt;HiSysEventSubscribeCallBackBase&gt; listener, std::vector&lt;ListenerRule&gt;&amp; rules)|接口功能:注册订阅HiSysEvent系统事件侦听对象,可设置规则订阅某些事件。<br><br>输入参数:<ul><li>listener:订阅回调对象。</li><li>rules:事件订阅规则。</li></ul>返回值:<ul><li>0:订阅成功,重复订阅。</li><li>1:订阅成功,初次订阅。</li><li>其他值:订阅失败。</li></ul>|
|void HiSysEventManager::RemoveListener(std::shared_ptr&lt;HiSysEventSubscribeCallBackBase&gt; listener)|接口功能:移除订阅hisysevent系统事件侦听对象。<br><br>输入参数:<ul><li>listener:订阅回调对象。</ul>返回值:<br>&emsp;&emsp;无。|
|int HiSysEventManager::AddEventListener(std::shared_ptr&lt;HiSysEventSubscribeCallBack&gt; listener, std::vector&lt;ListenerRule&gt;&amp; rules)|接口功能:注册订阅HiSysEvent系统事件侦听对象,可设置规则订阅某些事件。<br><br>输入参数:<ul><li>listener:订阅回调对象。</li><li>rules:事件订阅规则。</li></ul>返回值:<ul><li>0:订阅成功,重复订阅。</li><li>1:订阅成功,初次订阅。</li><li>其他值:订阅失败。</li></ul>|
|void HiSysEventManager::RemoveListener(std::shared_ptr&lt;HiSysEventSubscribeCallBack&gt; listener)|接口功能:移除订阅hisysevent系统事件侦听对象。<br><br>输入参数:<ul><li>listener:订阅回调对象。</ul>返回值:<br>&emsp;&emsp;无。|
**表 2** ListenerRule订阅规则对象
......@@ -46,11 +46,11 @@ HiSysEvent提供了跨进程订阅机制,开发者可以通过注册订阅接
| PREFIX | 前缀匹配类型 |
| REGULAR | 正则匹配类型 |
**表 4** HiSysEventSubscribeCallBackBase订阅对象
**表 4** HiSysEventSubscribeCallBack订阅对象
| 接口名称 | 描述 |
| -------- | --------- |
|void HiSysEventSubscribeCallBackBase::OnHandle(const std::string&amp; domain, const std::string&amp; eventName, const int eventType, const std::string&amp; eventDetail)|接口功能:订阅事件的回调接口。<br><br>输入参数:<ul><li>domain:事件所属领域。</li><li>eventName:事件的名称。</li><li>eventType:事件类型。</li><li>eventDetail:包含事件相关信息的字符串,以json的形式体现。</li></ul>返回值:<br>&emsp;&emsp;无。|
|void HiSysEventSubscribeCallBack::OnHandle(const std::string&amp; domain, const std::string&amp; eventName, const int eventType, const std::string&amp; eventDetail)|接口功能:订阅事件的回调接口。<br><br>输入参数:<ul><li>domain:事件所属领域。</li><li>eventName:事件的名称。</li><li>eventType:事件类型。</li><li>eventDetail:包含事件相关信息的字符串,以json的形式体现。</li></ul>返回值:<br>&emsp;&emsp;无。|
### 开发实例<a name="section123181432175110"></a>
......@@ -68,9 +68,9 @@ HiSysEvent提供了跨进程订阅机制,开发者可以通过注册订阅接
#include <string>
class DemoListener : public OHOS::HiviewDFX::HiSysEventSubscribeCallBackNative {
class DemoListener : public OHOS::HiviewDFX::HiSysEventSubscribeCallBack {
public:
explicit DemoListener() : HiSysEventSubscribeCallBackNative() {}
explicit DemoListener() : HiSysEventSubscribeCallBack() {}
void OnHandle(const std::string& domain, const std::string& eventName, const int eventType,
const std::string& eventDetail);
virtual ~DemoListener() {}
......
......@@ -17,7 +17,7 @@ HiSysEvent提供了查询接口,支持开发者设置条件查询HiSysEvent事
| 接口名称 | 描述 |
| -------- | --------- |
| bool HiSysEventManager::QueryHiSysEvent(struct QueryArg&amp; queryArg, std::vector&lt;struct QueryRule&gt;&amp; queryRules, std::shared_ptr&lt;HiSysEventQueryCallBackBase&gt; queryCallBack) | 接口功能:<br>&emsp;&emsp;支持设置查询时间段,事件领域,事件名称等,查询满足条件的HiSysEvent事件。<br><br>输入参数:<ul><li>queryArg:查询参数。</li><li>queryRules:事件过滤规则。</li><li>queryCallBack:查询接口回调对象。</li></ul>返回值:<ul><li>true:查询成功。</li><li>false:查询失败。</li></ul> |
| bool HiSysEventManager::QueryHiSysEvent(struct QueryArg&amp; queryArg, std::vector&lt;struct QueryRule&gt;&amp; queryRules, std::shared_ptr&lt;HiSysEventQueryCallBack&gt; queryCallBack) | 接口功能:<br>&emsp;&emsp;支持设置查询时间段,事件领域,事件名称等,查询满足条件的HiSysEvent事件。<br><br>输入参数:<ul><li>queryArg:查询参数。</li><li>queryRules:事件过滤规则。</li><li>queryCallBack:查询接口回调对象。</li></ul>返回值:<ul><li>true:查询成功。</li><li>false:查询失败。</li></ul> |
**表 2** QueryArg查询参数对象
......@@ -36,12 +36,12 @@ HiSysEvent提供了查询接口,支持开发者设置条件查询HiSysEvent事
| domain | string类型,用来标识查询规则对象的事件所属领域,如果传入的是空字符串,则默认事件领域字段匹配成功。 |
| eventList | std::vector&lt;std::string&gt;类型,事件名称的列表,如果传入的是空字符串,则默认事件名称字段匹配成功。 |
**表 4** HiSysEventQueryCallBackBase查询回调对象
**表 4** HiSysEventQueryCallBack查询回调对象
| 接口名称 | 描述 |
| -------- | --------- |
| void HiSysEventQueryCallBackBase::OnQuery(const ::std::vector&lt;std::string&gt;&amp; sysEvent, const ::std::vector&lt;int64_t&gt;&amp; seq) | 接口功能:订阅事件查询中的回调。<br><br>输入参数:<ul><li>sysEvent:返回事件集合。</li><li>seq:事件序列集合。</li></ul>返回值:<br>&emsp;&emsp;无。 |
| void HiSysEventQueryCallBackBase::OnComplete(int32_t reason, int32_t total) | 接口功能:订阅事件查询完成的回调。<br><br>输入参数:<ul><li>reason:查询结束返回原因,目前默认是0。</li><li>total:本次查询总共返回的事件总数量。</li></ul>返回值:<br>&emsp;&emsp;无。 |
| void HiSysEventQueryCallBack::OnQuery(const ::std::vector&lt;std::string&gt;&amp; sysEvent, const ::std::vector&lt;int64_t&gt;&amp; seq) | 接口功能:订阅事件查询中的回调。<br><br>输入参数:<ul><li>sysEvent:返回事件集合。</li><li>seq:事件序列集合。</li></ul>返回值:<br>&emsp;&emsp;无。 |
| void HiSysEventQueryCallBack::OnComplete(int32_t reason, int32_t total) | 接口功能:订阅事件查询完成的回调。<br><br>输入参数:<ul><li>reason:查询结束返回原因,目前默认是0。</li><li>total:本次查询总共返回的事件总数量。</li></ul>返回值:<br>&emsp;&emsp;无。 |
### 开发实例<a name="section14286111855212"></a>
......@@ -55,13 +55,13 @@ C++接口实例。
- 实现对应的查询回调接口:
void HiSysEventQueryCallBackBase::OnQuery\(const ::std::vector<std::string\>& sysEvent, const ::std::vector<int64\_t\>& seq\)
void HiSysEventQueryCallBack::OnQuery\(const ::std::vector<std::string\>& sysEvent, const ::std::vector<int64\_t\>& seq\)
void HiSysEventQueryCallBackBase::OnComplete\(int32\_t reason, int32\_t total\)
void HiSysEventQueryCallBack::OnComplete\(int32\_t reason, int32\_t total\)
- 在相应的业务逻辑里面调用查询接口:
HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector<struct QueryRule\>& queryRules, std::shared\_ptr<HiSysEventQueryCallBackBase\> queryCallBack\)
HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector<struct QueryRule\>& queryRules, std::shared\_ptr<HiSysEventQueryCallBack\> queryCallBack\)
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册