Cell down alarm notification [Issue-Id: ODUHIGH-430]
[o-du/l2.git] / src / o1 / Subject.cpp
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2020-2022] [HCL Technologies Ltd.]                          #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18
19 #include <iostream>
20 #include "Subject.hpp"
21 #include "GlobalDefs.hpp"
22
23 /* Constructor*/
24 Subject::Subject() {
25    mMessage=NULL;
26 }
27
28 /* Default destructor*/
29 Subject::~Subject() {
30
31 }
32
33 /**********************************************************************
34    Description : Register an Observer
35    Params[In]  : Observer
36    Return      : void
37 **********************************************************************/
38 void Subject::registerObserver(Observer *observer)
39 {
40    mObserversList.push_back(observer);
41 }
42
43 /**********************************************************************
44    Description : Unregister an Observer
45    Params[In]  : Observer
46    Return      : void
47 **********************************************************************/
48 void Subject::unregisterObserver(Observer *observer)
49 {
50    mObserversList.remove(observer);
51 }
52
53 /**********************************************************************
54    Description : Notify all observers on new message
55    Params[In]  : void
56    Return      : void
57 **********************************************************************/
58 void Subject::notifyObservers()
59 {
60    std::list<Observer *>::iterator iterator = mObserversList.begin();
61    while (iterator != mObserversList.end())
62       {
63         (*iterator)->update(mMessage);
64          iterator++;
65       }
66 }
67
68 /**********************************************************************
69    Description : Accept a message 
70    Params[In]  : Message
71    Return      : void
72 **********************************************************************/
73 void Subject::createMessage(char* message )
74 {
75    mMessage = message;
76    notifyObservers();
77 }
78
79
80 /**********************************************************************
81          End of file
82 **********************************************************************/