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 = -1; // problem ID (specific problem)
54 std::string severity = ""; // set_sev() xlates from SEV_* consts to collector's string values
55 std::string info = ""; // info string supplied by user
56 std::string add_info = ""; // additional information supplied by user
58 int build_alarm( int action_id, xapp::Msg_component payload, int payload_len );
61 static const int SEV_CRIT = 1; // allow translation to string on send/gen
62 static const int SEV_MAJOR = 2;
63 static const int SEV_MINOR = 3;
64 static const int SEV_WARN = 4;
65 static const int SEV_CLEAR = 5;
66 static const int SEV_DEFAULT = 6;
68 static const int ACT_RAISE = 1; // action const map to alarm manager strings
69 static const int ACT_CLEAR = 2;
70 static const int ACT_CLEAR_ALL = 3;
72 explicit Alarm( std::shared_ptr<Message> msg ); // builders
73 Alarm( std::shared_ptr<Message> msg, const std::string& meid );
74 Alarm( std::shared_ptr<Message> msg, int prob_id, const std::string& meid );
76 Alarm( const Alarm& soi ); // copy to newly created instance
77 Alarm& operator=( const Alarm& soi ); // copy operator
78 Alarm( Alarm&& soi ); // mover
79 Alarm& operator=( Alarm&& soi ) noexcept; // move operator
80 ~Alarm(); // destroyer
83 std::string Get_endpoint( ) const;
85 void Set_additional( const std::string& new_info );
86 void Set_appid( const std::string& new_id );
87 void Set_info( const std::string& new_info );
88 void Set_meid( const std::string& new_meid );
89 void Set_problem( int new_id );
90 void Set_severity( int new_sev );
91 void Set_whid( int whid );
95 bool Raise( int severity, int problem, const std::string& info );
96 bool Raise( int severity, int problem, const std::string& info, const std::string& additional_info );
100 bool Clear( int severity, int problem, const std::string& info );
101 bool Clear( int severity, int problem, const std::string& info, const std::string& additional_info );