RDK Documentation (Open Sourced RDK Components)
rtabstractservice.cpp
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2018 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 #include "rtabstractservice.h"
20 rtAbstractService::rtAbstractService(rtString serviceName)
21  : mServiceName(serviceName)
22  , mApiVersion(1), mEmit()
23 {
24  mEmit = new rtEmit();
25 }
26 rtAbstractService::~rtAbstractService()
27 {
28 }
29 void rtAbstractService::setName(rtString n)
30 {
31  mServiceName = n;
32 }
33 void rtAbstractService::setApiVersion(uint32_t v)
34 {
35  mApiVersion = v;
36 }
37 rtError rtAbstractService::notify(const rtString& eventName, rtObjectRef e)
38 {
39  mEmit.send(eventName, e);
40  return RT_OK;
41 }
42 #include <stdio.h>
43 rtError rtAbstractService::name(rtString& v) const
44 {
45  v = mServiceName;
46  return RT_OK;
47 }
48 rtError rtAbstractService::version(uint32_t& v) const
49 {
50  v = mApiVersion;
51  return RT_OK;
52 }
53 rtError rtAbstractService::quirks(rtValue& v) const
54 {
55  //rt services will override this method if they have any quirks
56  rtObjectRef e = new rtMapObject;
57  v = e;
58  return RT_OK;
59 }
60 rtError rtAbstractService::addListener(rtString eventName, const rtFunctionRef &f)
61 {
62  return mEmit->addListener(eventName, f);
63 }
64 rtError rtAbstractService::delListener(rtString eventName, const rtFunctionRef &f)
65 {
66  return mEmit->delListener(eventName, f);
67 }
68 rtDefineObject(rtAbstractService, rtObject);
69 rtDefineProperty(rtAbstractService, name);
70 rtDefineProperty(rtAbstractService, version);
71 rtDefineProperty(rtAbstractService, quirks);
72 rtDefineMethod(rtAbstractService, addListener);
73 rtDefineMethod(rtAbstractService, delListener);
rtAbstractService
Definition: rtabstractservice.h:24