/
service.go
92 lines (80 loc) · 2.43 KB
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// This file is part of the Smart Home
// Program complex distribution https://github.com/e154/smart-home
// Copyright (C) 2016-2021, Filippov Alex
//
// This library is free software: you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library. If not, see
// <https://www.gnu.org/licenses/>.
package plugins
import (
"github.com/e154/smart-home/adaptors"
"github.com/e154/smart-home/common"
"github.com/e154/smart-home/models"
"github.com/e154/smart-home/system/bus"
"github.com/e154/smart-home/system/entity_manager"
"github.com/e154/smart-home/system/gate_client"
"github.com/e154/smart-home/system/mqtt"
"github.com/e154/smart-home/system/scripts"
)
type service struct {
pluginManager common.PluginManager
bus bus.Bus
adaptors *adaptors.Adaptors
entityManager entity_manager.EntityManager
scriptService scripts.ScriptService
mqttServ mqtt.MqttServ
appConfig *models.AppConfig
gateClient *gate_client.GateClient
}
// Plugins ...
func (s service) Plugins() map[string]Plugable {
list := make(map[string]Plugable)
pluginList.Range(func(key, value interface{}) bool {
name := key.(string)
list[name] = value.(Plugable)
return true
})
return list
}
// PluginManager ...
func (s service) PluginManager() common.PluginManager {
return s.pluginManager
}
// EventBus ...
func (s service) EventBus() bus.Bus {
return s.bus
}
// EntityManager ...
func (s service) EntityManager() entity_manager.EntityManager {
return s.entityManager
}
// Adaptors ...
func (s service) Adaptors() *adaptors.Adaptors {
return s.adaptors
}
// ScriptService ...
func (s service) ScriptService() scripts.ScriptService {
return s.scriptService
}
// MqttServ ...
func (s service) MqttServ() mqtt.MqttServ {
return s.mqttServ
}
// AppConfig ...
func (s service) AppConfig() *models.AppConfig {
return s.appConfig
}
// GateClient ...
func (s service) GateClient() *gate_client.GateClient {
return s.gateClient
}