c905ae2c55
Several indentation issues were solved, also some style was applied to improve code's readability. cpplint is being used to get all these warnings, however there are some warnings that were suppressed. This means that this file still has the following issues: - line length > 80 characters - C casting in C++ code - References that can be const or pointers These issues will be solved in a next iteration as are more intrusive with the code. No functionality changes were done. Story: 2006425 Task: 36322 Change-Id: I4a2d3bcf9a13e0ce2659cc9a8211fc727b34d80e Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
108 lines
2.9 KiB
C++
108 lines
2.9 KiB
C++
//
|
|
// Copyright (c) 2014 Wind River Systems, Inc.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
|
|
#ifndef FMALARMUTILS_H_
|
|
#define FMALARMUTILS_H_
|
|
|
|
#include "fmAPI.h"
|
|
#include "fmMsg.h"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
enum EFmAlarmIndexMap {
|
|
FM_ALM_IX_UUID=0,
|
|
FM_ALM_IX_ALARM_ID,
|
|
FM_ALM_IX_ALARM_STATE,
|
|
FM_ALM_IX_ENTITY_ID,
|
|
FM_ALM_IX_INSTANCE_ID,
|
|
FM_ALM_IX_TIMESTAMP,
|
|
FM_ALM_IX_SEVERITY,
|
|
FM_ALM_IX_REASON,
|
|
FM_ALM_IX_ALARM_TYPE,
|
|
FM_ALM_IX_PROBABLE_CAUSE,
|
|
FM_ALM_IX_REPAIR_ACTION,
|
|
FM_ALM_IX_SERVICE_AFFECT,
|
|
FM_ALM_IX_SUPPRESSION,
|
|
FM_ALM_IX_INHIBIT_ALARM,
|
|
FM_ALM_IX_MAX
|
|
};
|
|
|
|
enum EFmLogIndexMap {
|
|
FM_LOG_IX_UUID=0,
|
|
FM_LOG_IX_LOG_ID,
|
|
FM_LOG_IX_ENTITY_ID,
|
|
FM_LOG_IX_INSTANCE_ID,
|
|
FM_LOG_IX_TIMESTAMP,
|
|
FM_LOG_IX_SEVERITY,
|
|
FM_LOG_IX_REASON,
|
|
FM_LOG_IX_LOG_TYPE,
|
|
FM_LOG_IX_PROBABLE_CAUSE,
|
|
FM_LOG_IX_SERVICE_AFFECT,
|
|
FM_LOG_IX_MAX
|
|
};
|
|
|
|
enum EFmEventLogIndexMap {
|
|
FM_EVENT_LOG_IX_UUID=0,
|
|
FM_EVENT_LOG_IX_EVENT_ID,
|
|
FM_EVENT_LOG_IX_STATE,
|
|
FM_EVENT_LOG_IX_ENTITY_ID,
|
|
FM_EVENT_LOG_IX_INSTANCE_ID,
|
|
FM_EVENT_LOG_IX_TIMESTAMP,
|
|
FM_EVENT_LOG_IX_SEVERITY,
|
|
FM_EVENT_LOG_IX_REASON,
|
|
FM_EVENT_LOG_IX_EVENT_TYPE,
|
|
FM_EVENT_LOG_IX_PROBABLE_CAUSE,
|
|
FM_EVENT_LOG_IX_REPAIR_ACTION,
|
|
FM_EVENT_LOG_IX_SERVICE_AFFECT,
|
|
FM_EVENT_LOG_IX_SUPPRESSION,
|
|
FM_EVENT_LOG_IX_MAX
|
|
};
|
|
|
|
|
|
bool fm_alarm_set_field(EFmAlarmIndexMap field, SFmAlarmDataT *a,
|
|
std::string &val);
|
|
bool fm_alarm_get_field(EFmAlarmIndexMap field, const SFmAlarmDataT *a,
|
|
std::string &val);
|
|
bool fm_log_set_field(EFmLogIndexMap field, SFmAlarmDataT *a,
|
|
std::string &val);
|
|
bool fm_event_log_set_field(EFmEventLogIndexMap field, SFmAlarmDataT *a,
|
|
std::string &val);
|
|
void fm_formatted_str_to_vector(const std::string &s,
|
|
std::vector<std::string> &alarm);
|
|
bool fm_alarm_to_string(const SFmAlarmDataT *alarm,
|
|
std::string &str);
|
|
bool fm_alarm_from_string(const std::string &str,
|
|
SFmAlarmDataT *alarm);
|
|
|
|
/**
|
|
* This will create an alarm list from an alarm - will translate to string.
|
|
* The indexes of this API are based on EFmAlarmIndexMap
|
|
*/
|
|
void fm_alarm_to_list(const SFmAlarmDataT *a,
|
|
std::vector<std::string> &list);
|
|
bool fm_alarm_filter_to_string(const AlarmFilter *alarm,
|
|
std::string &str);
|
|
bool fm_alarm_filter_from_string(const std::string &str,
|
|
AlarmFilter *alarm);
|
|
|
|
/**
|
|
* Generate a FM UUID
|
|
*/
|
|
void fm_uuid_create(fm_uuid_t &uuid);
|
|
|
|
/**
|
|
* General utilities to conver alarm fields to and from strings
|
|
*/
|
|
EFmErrorT fm_error_from_string(const std::string &str);
|
|
std::string fm_error_from_int(EFmErrorT id);
|
|
|
|
void fm_log_request(fm_buff_t &req, bool failed=false);
|
|
void fm_log_response(fm_buff_t &req, fm_buff_t &resp, bool failed=false);
|
|
|
|
#endif /* FMALARMUTILS_H_ */
|