libiec61850  1.6.0
logging_api.h
Go to the documentation of this file.
1 /*
2  * logging_api.h
3  *
4  * Copyright 2016 Michael Zillgith
5  *
6  * This file is part of libIEC61850.
7  *
8  * libIEC61850 is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * libIEC61850 is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
20  *
21  * See COPYING file for the complete license text.
22  */
23 
24 #ifndef LIBIEC61850_SRC_LOGGING_LOGGING_API_H_
25 #define LIBIEC61850_SRC_LOGGING_LOGGING_API_H_
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #include "libiec61850_common_api.h"
32 
33 
50 typedef struct sLogStorage* LogStorage;
51 
62 typedef bool (*LogEntryCallback) (void* parameter, uint64_t timestamp, uint64_t entryID, bool moreFollow);
63 
76 typedef bool (*LogEntryDataCallback) (void* parameter, const char* dataRef, uint8_t* data, int dataSize, uint8_t reasonCode, bool moreFollow);
77 
78 struct sLogStorage {
79 
80  void* instanceData;
81 
83 
84  uint64_t (*addEntry) (LogStorage self, uint64_t timestamp);
85 
86  bool (*addEntryData) (LogStorage self, uint64_t entryID, const char* dataRef, uint8_t* data, int dataSize, uint8_t reasonCode);
87 
88  bool (*getEntries) (LogStorage self, uint64_t startingTime, uint64_t endingTime,
89  LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void* parameter);
90 
91  bool (*getEntriesAfter) (LogStorage self, uint64_t startingTime, uint64_t entryID,
92  LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void* parameter);
93 
94  bool (*getOldestAndNewestEntries) (LogStorage self, uint64_t* newEntry, uint64_t* newEntryTime,
95  uint64_t* oldEntry, uint64_t* oldEntryTime);
96 
97  void (*destroy) (LogStorage self);
98 };
99 
100 
107 LIB61850_API void
108 LogStorage_setMaxLogEntries(LogStorage self, int maxEntries);
109 
117 LIB61850_API int
119 
128 LIB61850_API uint64_t
129 LogStorage_addEntry(LogStorage self, uint64_t timestamp);
130 
143 LIB61850_API bool
144 LogStorage_addEntryData(LogStorage self, uint64_t entryID, const char* dataRef, uint8_t* data, int dataSize, uint8_t reasonCode);
145 
158 LIB61850_API bool
159 LogStorage_getEntries(LogStorage self, uint64_t startingTime, uint64_t endingTime,
160  LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void* parameter);
161 
177 LIB61850_API bool
178 LogStorage_getEntriesAfter(LogStorage self, uint64_t startingTime, uint64_t entryID,
179  LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void* parameter);
180 
193 LIB61850_API bool
194 LogStorage_getOldestAndNewestEntries(LogStorage self, uint64_t* newEntry, uint64_t* newEntryTime,
195  uint64_t* oldEntry, uint64_t* oldEntryTime);
196 
202 LIB61850_API void
203 LogStorage_destroy(LogStorage self);
204 
209 #ifdef __cplusplus
210 }
211 #endif
212 
213 #endif /* LIBIEC61850_SRC_LOGGING_LOGGING_API_H_ */
LIB61850_API bool LogStorage_addEntryData(LogStorage self, uint64_t entryID, const char *dataRef, uint8_t *data, int dataSize, uint8_t reasonCode)
Add new entry data to an existing log entry.
LIB61850_API bool LogStorage_getEntriesAfter(LogStorage self, uint64_t startingTime, uint64_t entryID, LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void *parameter)
Get log entries specified by a start log entry.
LIB61850_API void LogStorage_setMaxLogEntries(LogStorage self, int maxEntries)
Set the maximum number of log entries for this log.
bool(* LogEntryCallback)(void *parameter, uint64_t timestamp, uint64_t entryID, bool moreFollow)
Will be called for each new LogEntry by the getEntries and getEntriesAfter functions.
Definition: logging_api.h:62
LIB61850_API bool LogStorage_getEntries(LogStorage self, uint64_t startingTime, uint64_t endingTime, LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void *parameter)
Get log entries specified by a time range.
LIB61850_API uint64_t LogStorage_addEntry(LogStorage self, uint64_t timestamp)
Add an entry to the log.
bool(* LogEntryDataCallback)(void *parameter, const char *dataRef, uint8_t *data, int dataSize, uint8_t reasonCode, bool moreFollow)
Will be called for each new LogEntryData by the getEntries and getEntriesAfter functions.
Definition: logging_api.h:76
LIB61850_API int LogStorage_getMaxLogEntries(LogStorage self)
Get the maximum allowed number of log entries for this log.
LIB61850_API bool LogStorage_getOldestAndNewestEntries(LogStorage self, uint64_t *newEntry, uint64_t *newEntryTime, uint64_t *oldEntry, uint64_t *oldEntryTime)
Get the entry time and entryID of the oldest and the newest log entries.
LIB61850_API void LogStorage_destroy(LogStorage self)
Destroy the LogStorage instance and free all related resources.
Definition: logging_api.h:78
bool(* addEntryData)(LogStorage self, uint64_t entryID, const char *dataRef, uint8_t *data, int dataSize, uint8_t reasonCode)
Definition: logging_api.h:86
void * instanceData
Definition: logging_api.h:80
int maxLogEntries
Definition: logging_api.h:82
bool(* getEntries)(LogStorage self, uint64_t startingTime, uint64_t endingTime, LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void *parameter)
Definition: logging_api.h:88
bool(* getOldestAndNewestEntries)(LogStorage self, uint64_t *newEntry, uint64_t *newEntryTime, uint64_t *oldEntry, uint64_t *oldEntryTime)
Definition: logging_api.h:94
void(* destroy)(LogStorage self)
Definition: logging_api.h:97
bool(* getEntriesAfter)(LogStorage self, uint64_t startingTime, uint64_t entryID, LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void *parameter)
Definition: logging_api.h:91
uint64_t(* addEntry)(LogStorage self, uint64_t timestamp)
Definition: logging_api.h:84