22# pragma warning(disable: 4355)
33#define THREAD_SAFE_NOTIFY 1
45 class ThreadDataHolder;
74 NOTIFY_LOGONLY = 1 << 7
83 PRINT_SELECTION_END = 8,
84 PRINT_DEFAULT = PRINT_TAG | PRINT_FUNCTION,
85 PRINT_ALL = PRINT_FILE | PRINT_TAG | PRINT_LINE | PRINT_FUNCTION
92 Notify( std::ostream& out_stream = std::cerr);
182 template <
class A, A val >
188 Mode(
Notify* notify ) : m_notify( notify ), m_level( val ) {}
190 Mode(
Notify* notify, A l = val ) : m_notify( notify ), m_level( l ) {}
192 Mode(
const Mode& m ) : m_notify( m.m_notify ), m_level( m.m_level ) {}
194 Notify::NotifyLevel getLevel()
const {
197 Notify* getNotify() {
200 const Notify* getNotify()
const {
205 Notify::NotifyLevel m_level;
216 Modifier( Notify* notify ) : m_notify( notify ), m_value( A( 0 ) ) {}
217 Modifier(
const Modifier& m ) : m_notify( m.m_notify ), m_value( m.m_value ) {}
221 Modifier& setValue( A val ) {
226 Notify* getNotify() {
229 const Notify* getNotify()
const {
244 PrintSelection(
int mask );
248 PrintSelection(
const PrintSelection& p );
249 PrintSelection& operator=(
const PrintSelection& p );
256 void setMask(
int f );
259 void setMask(
int f,
bool val );
261 bool isSet(
int s )
const;
263 bool isNoneSet()
const;
266 int m_selection_mask;
272 typedef Mode<Notify::NotifyLevel, Notify::
NOTIFY_END> End;
273 typedef Mode<Notify::NotifyLevel, Notify::
NOTIFY_CLEAR> Clear;
274 typedef Mode<Notify::NotifyLevel, Notify::NOTIFY_LOGONLY> LogOnly;
275 typedef Modifier<
int> Push;
277 SINGLETON_CLASSNAME_METHOD();
280 Notify& operator<<(const T& rhs) {
281 getThreadStringStream() << rhs;
285 typedef std::basic_ostream<char, std::char_traits<char> > CoutType;
286 typedef CoutType& (*StandardEndLine)(CoutType&);
291 operator std::ostream&() {
return getThreadStringStream(); }
294 std::ostringstream& str = getThreadStringStream();
302 Notify&
operator<<( Notify::LogOnly& modifier );
304 std::ios_base::fmtflags setf(std::ios_base::fmtflags newFormatFlags);
307 Clear& clearString() ;
316 void debug(
const char* function,
int line,
const char* file,
const agx::String& msg );
317 void info(
const char* function,
int line,
const char* file,
const agx::String& msg );
318 void warning(
const char* function,
int line,
const char* file,
const agx::String& msg );
319 void error(
const char* function,
int line,
const char* file,
const agx::String& msg );
327 void pushPrintSelection(
const PrintSelection& p, NotifyLevel l );
329 void pushPrintSelection(
const PrintSelection& p );
332 PrintSelection& getPrintSelection( NotifyLevel l );
334 PrintSelection& getPrintSelection();
337 bool popPrintSelection( NotifyLevel l );
339 bool popPrintSelection();
349 void shutdown() override;
355 friend
void agx::setNumThreads(
size_t numThreads);
356 friend class ThreadDataHolder;
360 void str( const
std::
string& text );
377 std::ostringstream& getThreadStringStream();
378 const
std::ostringstream& getThreadStringStream() const;
390 std::ostringstream stream;
396 virtual ~ThreadData();
399 ThreadData* getThreadData();
400 const ThreadData* getThreadData()
const;
405 bool m_throw_on_error;
406 bool m_break_on_error;
408 static Notify* s_instance;
409 std::ostream& m_outStream;
418#define ADD_NOTIFY_FUNCTIONALITY_TO_CLASS() \
420 void debug( const agx::String& msg ) { Notify::instance()->debug(msg); };\
421 void info( const agx::String& msg ) { Notify::instance()->info(msg); };\
422 void warning( const agx::String& msg ) { Notify::instance()->warning(msg); };\
423 void error( const agx::String& msg ) { Notify::instance()->error(msg); };\
425 void debug( const char* function, int line, const char* file, const agx::String& msg ) { Notify::instance()->debug(function,line,file,msg); };\
426 void info( const char* function, int line, const char* file, const agx::String& msg ) { Notify::instance()->info(function,line,file,msg); };\
427 void warning( const char* function, int line, const char* file, const agx::String& msg ) { Notify::instance()->warning(function,line,file,msg); };\
428 void error( const char* function, int line, const char* file, const agx::String& msg ) { Notify::instance()->error(function,line,file,msg); };\
429 ::agx::Notify::Push push() { return Notify::instance()->push(); };\
430 ::agx::Notify::End end() { return Notify::instance()->end(); };\
431 agx::String setDebugStrings( ::agx::Notify::NotifyLevel l, const char* function, int line, const char* file ) { return Notify::instance()->setDebugStrings(l,function,line,file); };\
433 ::agx::Notify& getNotify() {\
434 ::agx::Notify* n = Notify::instance();\
437 const ::agx::Notify& getNotify() const {\
438 ::agx::Notify* n = Notify::instance();\
444#define NOTIFY_POS_ARGS __FUNCTION__,__LINE__,__FILE__
446#define NOTIFY_POS_ARGS "",-1,""
449#define NOTIFY() getNotify()
450#define NOTIFY_DEBUG() setDebugStrings(::agx::Notify::NOTIFY_DEBUG, NOTIFY_POS_ARGS)
451#define NOTIFY_INFO() setDebugStrings(::agx::Notify::NOTIFY_INFO, NOTIFY_POS_ARGS)
452#define NOTIFY_WARNING() setDebugStrings(::agx::Notify::NOTIFY_WARNING, NOTIFY_POS_ARGS)
453#define NOTIFY_ERROR() setDebugStrings(::agx::Notify::NOTIFY_ERROR, NOTIFY_POS_ARGS)
454#define NOTIFY_LOG() logOnly()
455#define NOTIFY_END() end()
456#define NOTIFY_CLEAR() clear()
457#define NOTIFY_STATE(X) push().setValue(X)
460#define NOTIFY_WARNING_IF_nullptr(X,Y) if ( Y == nullptr ) { X << X.NOTIFY_WARNING() << " nullptr pointer: " << #Y << std::endl << X.NOTIFY_END(); }
461#define NOTIFY_WARNING_IF_FALSE(X,Y) if ( !Y ) { X << X.NOTIFY_WARNING() << " Test false: " << #Y <<std::endl << X.NOTIFY_END(); }
462#define NOTIFY_WARNING_IF_TRUE(X,Y) if ( Y ) { X << X.NOTIFY_WARNING() << " Test true: " << #Y <<std::endl << X.NOTIFY_END(); }
464#define NOTIFY_ERROR_IF_nullptr(X,Y) if ( Y == nullptr ) { X << X.NOTIFY_STATE(::agx::Notify::PRINT_ALL) << X.NOTIFY_ERROR() << " nullptr pointer: " << #Y <<std::endl << X.NOTIFY_END(); }
465#define NOTIFY_ERROR_IF_FALSE(X,Y) if ( !Y ) { X << X.NOTIFY_STATE(::agx::Notify::PRINT_ALL) << X.NOTIFY_ERROR() << " Test false: " << #Y <<std::endl << X.NOTIFY_END(); }
466#define NOTIFY_ERROR_IF_TRUE(X,Y) if ( Y ) { X << X.NOTIFY_STATE(::agx::Notify::PRINT_ALL) << X.NOTIFY_ERROR() << " Test true: " << #Y <<std::endl << X.NOTIFY_END(); }
469#define NOTIFY_INSTANCE() ::agx::Notify::instance()
#define AGX_DECLARE_POINTER_TYPES(type)
std::ostream & operator<<(std::ostream &o, const agx::Vec6 &v)
Inheritance with partial specialization due to bug with ref_ptr containers.
Class for printing out messages to console, file, virtual method and or a callback function.
Callback class, derive from this and Register to the notify singleton to get callbacks.
virtual ~NotifyCallback()
virtual void message(const agx::String &msg, int notifyLevel)=0
Virtual method called whenever there is a message ready.
Class for handling logging of messages.
static Notify * instance()
bool getToLogOnly() const
bool setNotifyLevel(NotifyCallback *callback, NotifyLevel l)
Set the notify level for a specific callback.
void addStream(std::ostream *stream, NotifyLevel l)
Add a stream that will be printed to if the notify level less or equal to l, the memory will NOT be m...
agx::LogStream & logStream()
void setLogNotifyLevel(NotifyLevel l)
Set the notify level for the LogStream.
NotifyLevel getNotifyLevel() const
std::ostream & outStream()
void setBreakOnError(bool f)
WIN32 specific: If set to true, a breakpoint will be set in debug build.
bool getBreakOnError() const
bool removeCallback(NotifyCallback *callback)
Remove a callback from list of callbacks to report messages to.
bool setNotifyLevel(std::ostream *stream, NotifyLevel l)
Set the notify level for a specific stream.
const agx::LogStream & logStream() const
bool openLog(const agx::String &filename)
Open a log file (in the LogStream)
void setToLogOnly(bool f)
If f==true, logging will occur only to the LogStream, not to any of the associated ostreams.
NotifyLevel getOutputMode() const
void addCallback(NotifyCallback *callback, NotifyLevel l)
Add a callback class that will be printed to if the notify level less or equal to l.
void setNotifyLevel(NotifyLevel level)
Set the current notify level.
bool removeStream(std::ostream *stream)
Remove a stream from list of streams to report messages to.
void setThrowOnError(bool v)
Specify whether we should Throw an exception upon calling error?
Notify(std::ostream &out_stream=std::cerr)
Constructor.
bool getThrowOnError() const
void setOutputMode(NotifyLevel l)
Set the current output mode, do not use! (used internally)
Base class providing referencing counted objects.
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
agx::Thread is a representation of an OS specific implementation of a computational thread.
Smart pointer for handling referenced counted objects.
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
Contains function for initialization and shutdown of agxCore library when agxPhysics is not used.
AGXTERRAIN_EXPORT void clear()
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
std::recursive_mutex ReentrantMutex