571dcbaef592b951e745cc0369755fa5fa568d8f
[ric-plt/xapp-frame.git] / pkg / xapp / types.go
1 /*
2 ==================================================================================
3   Copyright (c) 2019 AT&T Intellectual Property.
4   Copyright (c) 2019 Nokia
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17 ==================================================================================
18 */
19 package xapp
20
21 import (
22         "sync"
23         "unsafe"
24 )
25
26 // To be removed ...
27 type RMRStatistics struct{}
28
29 //
30 //
31 //
32 type RMRClient struct {
33         protPort      string
34         contextMux    sync.Mutex
35         context       unsafe.Pointer
36         ready         int
37         wg            sync.WaitGroup
38         mux           sync.Mutex
39         stat          map[string]Counter
40         consumers     []MessageConsumer
41         readyCb       ReadyCB
42         readyCbParams interface{}
43 }
44
45 //
46 //
47 //
48 type RMRMeid struct {
49         PlmnID  string
50         EnbID   string
51         RanName string
52 }
53
54 func (meid *RMRMeid) String() string {
55         str := "meid("
56         pad := ""
57         if len(meid.PlmnID) > 0 {
58                 str += pad + "PlmnID=" + meid.PlmnID
59                 pad = " "
60         }
61         if len(meid.EnbID) > 0 {
62                 str += pad + "EnbID=" + meid.EnbID
63                 pad = " "
64         }
65         if len(meid.RanName) > 0 {
66                 str += pad + "RanName=" + meid.RanName
67                 pad = " "
68         }
69         str += ")"
70         return str
71 }
72
73 //
74 //
75 //
76 type MessageConsumerFunc func(*RMRParams) error
77
78 func (fn MessageConsumerFunc) Consume(params *RMRParams) error {
79         return fn(params)
80 }
81
82 //
83 //
84 //
85 type MessageConsumer interface {
86         Consume(params *RMRParams) error
87 }