| 1 | #include "LogServiceStatus.h" |
|---|
| 2 | |
|---|
| 3 | // Default log size |
|---|
| 4 | #define MAX_SIZE_DEFAULT 10000 |
|---|
| 5 | // Maximum allowed log size |
|---|
| 6 | #define MAX_MAX_SIZE 50000 |
|---|
| 7 | |
|---|
| 8 | class CircularLogRecordSequence |
|---|
| 9 | { |
|---|
| 10 | |
|---|
| 11 | private: |
|---|
| 12 | LogService::LogRecordSequence *seq; |
|---|
| 13 | unsigned long long maxLen; |
|---|
| 14 | unsigned long long currentLen; |
|---|
| 15 | unsigned long long wrIndex; |
|---|
| 16 | |
|---|
| 17 | bool logFull; |
|---|
| 18 | |
|---|
| 19 | public: |
|---|
| 20 | struct InvalidIndex { |
|---|
| 21 | unsigned long long i; |
|---|
| 22 | InvalidIndex(int ii) {i = ii;} |
|---|
| 23 | }; |
|---|
| 24 | struct InternalFailure {}; |
|---|
| 25 | |
|---|
| 26 | unsigned long long currentId; |
|---|
| 27 | |
|---|
| 28 | CircularLogRecordSequence(); |
|---|
| 29 | CircularLogRecordSequence(unsigned long long len); |
|---|
| 30 | ~CircularLogRecordSequence(); |
|---|
| 31 | |
|---|
| 32 | void writeLogRecord(const LogService::LogRecord &record); |
|---|
| 33 | |
|---|
| 34 | LogService::LogRecord readLogRecord(unsigned long long index) |
|---|
| 35 | throw (InvalidIndex); |
|---|
| 36 | |
|---|
| 37 | LogService::LogRecordSequence* readLogRecords(unsigned long long index, |
|---|
| 38 | CORBA::ULong &howMany, LogService::RecordId &id) |
|---|
| 39 | throw (InternalFailure); |
|---|
| 40 | |
|---|
| 41 | unsigned long long findIndexFromTime(const LogService::LogTime &fromTime); |
|---|
| 42 | unsigned long long findIndexById(unsigned long long id); |
|---|
| 43 | |
|---|
| 44 | unsigned long long getMaxLen(); |
|---|
| 45 | void setMaxLen(unsigned long long len); |
|---|
| 46 | |
|---|
| 47 | unsigned long long getCurrentLen(); |
|---|
| 48 | |
|---|
| 49 | bool isFull(); |
|---|
| 50 | void clearLog(); |
|---|
| 51 | }; |
|---|
| 52 | |
|---|
| 53 | class LogStatus_impl : public virtual POA_LogService::LogStatus |
|---|
| 54 | { |
|---|
| 55 | |
|---|
| 56 | private: |
|---|
| 57 | |
|---|
| 58 | protected: |
|---|
| 59 | omni_mutex* test_mutex; |
|---|
| 60 | |
|---|
| 61 | CircularLogRecordSequence* circLogSeq; |
|---|
| 62 | |
|---|
| 63 | LogService::OperationalState operationalState; |
|---|
| 64 | LogService::AdministrativeState administrativeState; |
|---|
| 65 | LogService::LogFullAction logFullAction; |
|---|
| 66 | LogService::AvailabilityStatus availabilityStatus; |
|---|
| 67 | |
|---|
| 68 | public: |
|---|
| 69 | LogStatus_impl(); |
|---|
| 70 | LogStatus_impl(unsigned long long max_length); |
|---|
| 71 | ~LogStatus_impl(); |
|---|
| 72 | |
|---|
| 73 | unsigned long long getMaxSize(); |
|---|
| 74 | unsigned long long getCurrentSize(); |
|---|
| 75 | unsigned long long getNumRecords(); |
|---|
| 76 | LogService::LogFullAction getLogFullAction(); |
|---|
| 77 | LogService::AdministrativeState getAdministrativeState(); |
|---|
| 78 | LogService::AvailabilityStatus getAvailabilityStatus(); |
|---|
| 79 | LogService::OperationalState getOperationalState(); |
|---|
| 80 | |
|---|
| 81 | }; |
|---|
| 82 | |
|---|
| 83 | |
|---|