libiec61850  1.2.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 <stdint.h>
32 #include <stdbool.h>
33 
34 
51 typedef struct sLogStorage* LogStorage;
52 
63 typedef bool (*LogEntryCallback) (void* parameter, uint64_t timestamp, uint64_t entryID, bool moreFollow);
64 
77 typedef bool (*LogEntryDataCallback) (void* parameter, const char* dataRef, uint8_t* data, int dataSize, uint8_t reasonCode, bool moreFollow);
78 
79 struct sLogStorage {
80 
81  void* instanceData;
82 
84 
85  uint64_t (*addEntry) (LogStorage self, uint64_t timestamp);
86 
87  bool (*addEntryData) (LogStorage self, uint64_t entryID, const char* dataRef, uint8_t* data, int dataSize, uint8_t reasonCode);
88 
89  bool (*getEntries) (LogStorage self, uint64_t startingTime, uint64_t endingTime,
90  LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void* parameter);
91 
92  bool (*getEntriesAfter) (LogStorage self, uint64_t startingTime, uint64_t entryID,
93  LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void* parameter);
94 
95  bool (*getOldestAndNewestEntries) (LogStorage self, uint64_t* newEntry, uint64_t* newEntryTime,
96  uint64_t* oldEntry, uint64_t* oldEntryTime);
97 
98  void (*destroy) (LogStorage self);
99 };
100 
101 
108 void
109 LogStorage_setMaxLogEntries(LogStorage self, int maxEntries);
110 
119 uint64_t
120 LogStorage_addEntry(LogStorage self, uint64_t timestamp);
121 
134 bool
135 LogStorage_addEntryData(LogStorage self, uint64_t entryID, const char* dataRef, uint8_t* data, int dataSize, uint8_t reasonCode);
136 
149 bool
150 LogStorage_getEntries(LogStorage self, uint64_t startingTime, uint64_t endingTime,
151  LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void* parameter);
152 
168 bool
169 LogStorage_getEntriesAfter(LogStorage self, uint64_t startingTime, uint64_t entryID,
170  LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void* parameter);
171 
184 bool
185 LogStorage_getOldestAndNewestEntries(LogStorage self, uint64_t* newEntry, uint64_t* newEntryTime,
186  uint64_t* oldEntry, uint64_t* oldEntryTime);
187 
193 void
194 LogStorage_destroy(LogStorage self);
195 
200 #ifdef __cplusplus
201 }
202 #endif
203 
204 #endif /* LIBIEC61850_SRC_LOGGING_LOGGING_API_H_ */
void LogStorage_setMaxLogEntries(LogStorage self, int maxEntries)
Set the maximum number of log entries for this log.
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.
void LogStorage_destroy(LogStorage self)
Destroy the LogStorage instance and free all related resources.
uint64_t LogStorage_addEntry(LogStorage self, uint64_t timestamp)
Add an entry to the log.
bool(* getEntriesAfter)(LogStorage self, uint64_t startingTime, uint64_t entryID, LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void *parameter)
Definition: logging_api.h:92
void(* destroy)(LogStorage self)
Definition: logging_api.h:98
Definition: logging_api.h:79
void * instanceData
Definition: logging_api.h:81
bool(* getOldestAndNewestEntries)(LogStorage self, uint64_t *newEntry, uint64_t *newEntryTime, uint64_t *oldEntry, uint64_t *oldEntryTime)
Definition: logging_api.h:95
int maxLogEntries
Definition: logging_api.h:83
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.
bool(* addEntryData)(LogStorage self, uint64_t entryID, const char *dataRef, uint8_t *data, int dataSize, uint8_t reasonCode)
Definition: logging_api.h:87
uint64_t(* addEntry)(LogStorage self, uint64_t timestamp)
Definition: logging_api.h:85
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.
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:63
bool(* getEntries)(LogStorage self, uint64_t startingTime, uint64_t endingTime, LogEntryCallback entryCallback, LogEntryDataCallback entryDataCallback, void *parameter)
Definition: logging_api.h:89
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:77
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.