45 #if defined(AJA_WINDOWS)
47 #if defined(AJA_DEBUG)
48 #define AJA_ASSERT(_expression_) \
49 if (!(_expression_)) AJADebug::AssertWithMessage(__FILE__, __LINE__, #_expression_);
50 #define AJA_PRINT(...) \
51 AJADebug::Report(0, AJA_DebugSeverity_Debug, NULL, 0, __VA_ARGS__)
53 #define AJA_ASSERT(_expression_)
54 #define AJA_PRINT(...)
57 #define AJA_REPORT(_index_, _severity_, ...) \
58 AJADebug::Report(_index_, _severity_, __FILE__, __LINE__, __VA_ARGS__);
60 #elif defined(AJA_LINUX)
62 #if defined(AJA_DEBUG)
63 #define AJA_ASSERT(_expression_) \
64 if(!(_expression_)) AJADebug::AssertWithMessage(NULL, 0, #_expression_);
65 #define AJA_PRINT(...) \
66 AJADebug::Report(0, AJA_DebugSeverity_Error, NULL, 0, __VA_ARGS__)
68 #define AJA_ASSERT(_expression_)
69 #define AJA_PRINT(...)
72 #define AJA_REPORT(_index_, _severity_, ...) \
73 AJADebug::Report(_index_, _severity_, __FILE__, __LINE__, __VA_ARGS__);
75 #elif defined(AJA_MAC)
77 #if defined(AJA_DEBUG)
78 #define AJA_ASSERT(_expression_) \
79 if (!(_expression_)) AJADebug::AssertWithMessage(__FILE__, __LINE__, #_expression_);
80 #if !defined (AJA_PRINTTYPE)
81 #define AJA_PRINTTYPE 0
82 #endif // if AJA_PRINTTYPE undefined
83 #if (AJA_PRINTTYPE==0)
84 #define AJA_PRINT(...) \
85 AJADebug::Report(0, AJA_DebugSeverity_Error, NULL, 0, __VA_ARGS__)
86 #elif (AJA_PRINTTYPE==1)
88 #define AJA_PRINT(_format_...) printf(_format_)
89 #elif (AJA_PRINTTYPE==3)
91 #define AJA_PRINT(_format_...) fprintf(stderr, _format_)
92 #elif (AJA_PRINTTYPE==4)
95 #define AJA_PRINT(_format_...) syslog(LOG_ERR, _format_)
98 #define AJA_ASSERT(_expression_)
99 #define AJA_PRINT(...)
102 #define AJA_REPORT(_index_, _severity_, ...) \
103 AJADebug::Report(_index_, _severity_, __FILE__, __LINE__, __VA_ARGS__);
107 #if defined(AJA_DEBUG)
108 #define AJA_ASSERT(_expression_) \
109 if(!(_expression_)) AJADebug::AssertWithMessage(NULL, 0, #_expression_);
110 #define AJA_PRINT(_format_,...) \
111 AJADebug::Report(0, AJA_DebugSeverity_Error, NULL, 0, _format_)
113 #define AJA_ASSERT(_expression_)
114 #define AJA_PRINT(_format_,...)
117 #define AJA_REPORT(_index_, _severity_, _format_, ...) \
118 AJADebug::Report(_index_, _severity_, NULL, 0, _format_);
126 #define AJA_sASSERT(_expr_) do { std::ostringstream __ss__; __ss__ << #_expr_; \
127 AJADebug::AssertWithMessage(__FILE__, __LINE__, __ss__.str()); \
141 #define AJA_sREPORT(_index_,_severity_,_expr_) do {std::ostringstream __ss__; __ss__ << _expr_; \
142 AJADebug::Report((_index_), (_severity_), __FILE__, __LINE__, __ss__.str()); \
154 #define AJA_sEMERGENCY(_index_,_expr_) AJA_sREPORT((_index_), AJA_DebugSeverity_Emergency, _expr_)
165 #define AJA_sALERT(_index_,_expr_) AJA_sREPORT((_index_), AJA_DebugSeverity_Alert, _expr_)
176 #define AJA_sERROR(_index_,_expr_) AJA_sREPORT((_index_), AJA_DebugSeverity_Error, _expr_)
187 #define AJA_sWARNING(_index_,_expr_) AJA_sREPORT((_index_), AJA_DebugSeverity_Warning, _expr_)
198 #define AJA_sNOTICE(_index_,_expr_) AJA_sREPORT((_index_), AJA_DebugSeverity_Notice, _expr_)
209 #define AJA_sINFO(_index_,_expr_) AJA_sREPORT((_index_), AJA_DebugSeverity_Info, _expr_)
220 #define AJA_sDEBUG(_index_,_expr_) AJA_sREPORT((_index_), AJA_DebugSeverity_Debug, _expr_)
253 static uint32_t Version (
void);
258 static uint32_t TotalBytes (
void);
272 static AJAStatus Open (
bool incrementRefCount =
false);
286 static AJAStatus Close (
bool decrementRefCount =
false);
331 static AJAStatus GetDestination (
const int32_t inGroup, uint32_t & outDestination);
337 static bool IsActive (int32_t index);
342 static bool IsOpen (
void);
347 static bool IsDebugBuild (
void);
358 static void Report (int32_t index, int32_t severity,
const char* pFileName, int32_t lineNumber, ...);
369 static void Report (int32_t index, int32_t severity,
const char* pFileName, int32_t lineNumber,
const std::string& message);
378 static void AssertWithMessage (
const char* pFileName, int32_t lineNumber,
const std::string& pExpression);
383 static uint32_t MessageRingCapacity (
void);
394 static AJAStatus GetClientReferenceCount (int32_t & outRefCount);
406 static AJAStatus SetClientReferenceCount (int32_t refCount);
417 static AJAStatus GetSequenceNumber (uint64_t & outSequenceNumber);
429 static AJAStatus GetMessageSequenceNumber (
const uint64_t sequenceNumber, uint64_t & outSequenceNumber);
441 static AJAStatus GetMessageGroup (
const uint64_t sequenceNumber, int32_t & outGroupIndex);
453 static AJAStatus GetMessageDestination (
const uint64_t sequenceNumber, uint32_t & outDestination);
465 static AJAStatus GetMessageTime (
const uint64_t sequenceNumber, uint64_t & outTime);
477 static AJAStatus GetMessageWallClockTime (
const uint64_t sequenceNumber, int64_t & outTime);
490 static AJAStatus GetMessageFileName (
const uint64_t sequenceNumber, std::string & outFileName);
502 static AJAStatus GetMessageLineNumber (
const uint64_t sequenceNumber, int32_t & outLineNumber);
514 static AJAStatus GetMessageSeverity (
const uint64_t sequenceNumber, int32_t & outSeverity);
526 static AJAStatus GetMessageText (
const uint64_t sequenceNumber, std::string & outMessage);
538 static AJAStatus GetProcessId (
const uint64_t sequenceNumber, uint64_t & outPid);
550 static AJAStatus GetThreadId (
const uint64_t sequenceNumber, uint64_t & outTid);
561 static AJAStatus GetMessagesAccepted (uint64_t & outCount);
572 static AJAStatus GetMessagesIgnored (uint64_t & outCount);
578 static const std::string & SeverityName (
const int32_t severity);
585 static const std::string & GroupName (
const int32_t group);
595 static AJAStatus SaveState (
const std::string & inFilePath);
605 static AJAStatus RestoreState (
const std::string & inFilePath);
610 static uint32_t StatsCapacity (
void);
615 static bool HasStats (
void);
623 static AJAStatus StatAllocate (
const uint32_t inKey);
631 static AJAStatus StatFree (
const uint32_t inKey);
639 static bool StatIsAllocated (
const uint32_t inKey);
647 static AJAStatus StatReset (
const uint32_t inKey);
655 static AJAStatus StatTimerStart (
const uint32_t inKey);
664 static AJAStatus StatTimerStop (
const uint32_t inKey);
673 static AJAStatus StatCounterIncrement (
const uint32_t inKey,
const uint32_t inIncrement = 1);
682 static AJAStatus StatSetValue (
const uint32_t inKey,
const uint32_t inValue);
700 static AJAStatus StatGetKeys (std::vector<uint32_t> & outKeys, uint32_t & outSeqNum);
709 static AJAStatus StatGetKeys (std::set<uint32_t> & outKeys, uint32_t & outSeqNum);
717 static AJAStatus StatGetSequenceNum (uint32_t & outSeqNum);
724 static int64_t DebugTime (
void);
727 static const char* GetSeverityString (int32_t severity);
728 static const char* GetGroupString (int32_t group);
737 static AJAStatus GetMessageFileName (uint64_t sequenceNumber,
const char** ppFileName);
740 static AJAStatus GetMessageText (uint64_t sequenceNumber,
const char** ppMessage);
747 static void * GetPrivateDataLoc (
void);
748 static size_t GetPrivateDataLen (
void);
754 #endif // AJA_DEBUG_H