3 ==================================================================================
4 Copyright (c) 2020 Nokia
5 Copyright (c) 2020 AT&T Intellectual Property.
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
11 http://www.apache.org/licenses/LICENSE-2.0
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 ==================================================================================
23 Abstract: Headers for the alarm class.
24 This class provides for an alarm API.
27 Author: E. Scott Daniels
30 #ifndef _XAPP_ALARM_HPP
31 #define _XAPP_ALARM_HPP
37 #include "msg_component.hpp"
41 // ------------------------------------------------------------------------
45 std::shared_ptr<Message> msg; // message to send
46 std::shared_ptr<char> psp; // shared pointer to the payload to give out
47 std::string endpoint; // the ip:port addr:port of the alarm collector
50 // data for the payload
51 std::string me_id; // managed element ID
52 std::string app_id; // application ID
53 int problem_id; // problem ID (specific problem)
54 std::string severity; // SEV_* constants
55 std::string action; // ACT_* constants
56 std::string info; // info string supplied by user
57 std::string add_info; // additional information supplied by user
59 int build_alarm( int action_id, xapp::Msg_component payload, int payload_len );
62 static const int SEV_CRIT = 1; // allow translation to string on send/gen
63 static const int SEV_MAJOR = 2;
64 static const int SEV_MINOR = 3;
65 static const int SEV_WARN = 4;
66 static const int SEV_CLEAR = 5;
67 static const int SEV_DEFAULT = 6;
69 static const int ACT_RAISE = 1; // action const map to alarm manager strings
70 static const int ACT_CLEAR = 2;
71 static const int ACT_CLEAR_ALL = 3;
73 Alarm( std::shared_ptr<Message> msg ); // builders
74 Alarm( std::shared_ptr<Message> msg, std::string meid );
75 Alarm( std::shared_ptr<Message> msg, int prob_id, std::string meid );
77 Alarm( const Alarm& soi ); // copy to newly created instance
78 Alarm& operator=( const Alarm& soi ); // copy operator
79 Alarm( Alarm&& soi ); // mover
80 Alarm& operator=( Alarm&& soi ); // move operator
81 ~Alarm(); // destroyer
84 std::string Get_endpoint( );
86 void Set_additional( std::string new_info );
87 void Set_appid( std::string new_id );
88 void Set_info( std::string new_info );
89 void Set_meid( std::string new_meid );
90 void Set_problem( int new_id );
91 void Set_severity( int new_sev );
92 void Set_whid( int whid );
96 bool Raise( int severity, int problem, std::string info );
97 bool Raise( int severity, int problem, std::string info, std::string addional_info );
101 bool Clear( int severity, int problem, std::string info );
102 bool Clear( int severity, int problem, std::string info, std::string addional_info );