20 # pragma warning(push)
21 # pragma warning(disable: 4355) // No warnings about using this in member initializer list
32 #define THREAD_SAFE_NOTIFY 1
34 #if THREAD_SAFE_NOTIFY
44 class ThreadDataHolder;
73 NOTIFY_LOGONLY = 1 << 7
82 PRINT_SELECTION_END = 8,
83 PRINT_DEFAULT = PRINT_TAG | PRINT_FUNCTION,
84 PRINT_ALL = PRINT_FILE | PRINT_TAG | PRINT_LINE | PRINT_FUNCTION
91 Notify( std::ostream& out_stream = std::cerr);
103 NotifyLevel getNotifyLevel()
const;
106 void setNotifyLevel( NotifyLevel level );
112 void setLogNotifyLevel( NotifyLevel l );
115 bool getThrowOnError()
const;
118 void setThrowOnError(
bool v );
129 void setBreakOnError(
bool f );
132 bool getBreakOnError()
const;
151 void addStream( std::ostream* stream, NotifyLevel l );
157 bool removeStream( std::ostream* stream );
163 bool setNotifyLevel( std::ostream* stream, NotifyLevel l );
166 void setOutputMode( NotifyLevel l );
169 NotifyLevel getOutputMode()
const;
172 bool getToLogOnly()
const;
175 void setToLogOnly(
bool f );
177 std::ostream& outStream();
181 template <
class A, A val >
187 Mode(
Notify* notify ) : m_notify( notify ), m_level( val ) {}
189 Mode( Notify* notify, A l = val ) : m_notify( notify ), m_level( l ) {}
191 Mode(
const Mode& m ) : m_notify( m.m_notify ), m_level( m.m_level ) {}
196 Notify* getNotify() {
199 const Notify* getNotify()
const {
215 Modifier( Notify* notify ) : m_notify( notify ), m_value( A( 0 ) ) {}
216 Modifier(
const Modifier& m ) : m_notify( m.m_notify ), m_value( m.m_value ) {}
220 Modifier& setValue( A val ) {
225 Notify* getNotify() {
228 const Notify* getNotify()
const {
243 PrintSelection(
int mask );
247 PrintSelection(
const PrintSelection& p );
248 PrintSelection& operator=(
const PrintSelection& p );
255 void setMask(
int f );
258 void setMask(
int f,
bool val );
260 bool isSet(
int s )
const;
262 bool isNoneSet()
const;
265 int m_selection_mask;
271 typedef Mode<Notify::NotifyLevel, Notify::
NOTIFY_END> End;
272 typedef Mode<Notify::NotifyLevel, Notify::
NOTIFY_CLEAR> Clear;
273 typedef Mode<Notify::NotifyLevel, Notify::NOTIFY_LOGONLY> LogOnly;
274 typedef Modifier<
int> Push;
276 SINGLETON_CLASSNAME_METHOD();
279 Notify& operator<<(const T& rhs) {
280 getThreadStringStream() << rhs;
284 typedef std::basic_ostream<char, std::char_traits<char> > CoutType;
285 typedef CoutType& (*StandardEndLine)(CoutType&);
290 operator std::ostream&() {
return getThreadStringStream(); }
293 std::ostringstream& str = getThreadStringStream();
301 Notify&
operator<<( Notify::LogOnly& modifier );
303 std::ios_base::fmtflags setf(std::ios_base::fmtflags _Newfmtflags);
306 Clear& clearString() ;
315 void debug(
const char*
function,
int line,
const char* file,
const agx::String& msg );
316 void info(
const char*
function,
int line,
const char* file,
const agx::String& msg );
317 void warning(
const char*
function,
int line,
const char* file,
const agx::String& msg );
318 void error(
const char*
function,
int line,
const char* file,
const agx::String& msg );
326 void pushPrintSelection(
const PrintSelection& p, NotifyLevel l );
328 void pushPrintSelection(
const PrintSelection& p );
331 PrintSelection& getPrintSelection( NotifyLevel l );
333 PrintSelection& getPrintSelection();
336 bool popPrintSelection( NotifyLevel l );
338 bool popPrintSelection();
343 agx::
String buildString( );
344 agx::
String setDebugStrings( NotifyLevel l, const
char* function,
int line, const
char* file );
352 friend
void agxCore::
init();
355 friend class ThreadDataHolder;
357 std::
string str() const;
359 void str( const std::
string& text );
374 CallbackMap m_callbacks;
376 std::ostringstream& getThreadStringStream();
377 const std::ostringstream& getThreadStringStream() const;
389 std::ostringstream stream;
395 virtual ~ThreadData();
398 ThreadData* getThreadData();
399 const ThreadData* getThreadData()
const;
404 bool m_throw_on_error;
405 bool m_break_on_error;
407 static Notify* s_instance;
408 std::ostream& m_outStream;
417 #define ADD_NOTIFY_FUNCTIONALITY_TO_CLASS() \
419 void debug( const agx::String& msg ) { Notify::instance()->debug(msg); };\
420 void info( const agx::String& msg ) { Notify::instance()->info(msg); };\
421 void warning( const agx::String& msg ) { Notify::instance()->warning(msg); };\
422 void error( const agx::String& msg ) { Notify::instance()->error(msg); };\
424 void debug( const char* function, int line, const char* file, const agx::String& msg ) { Notify::instance()->debug(function,line,file,msg); };\
425 void info( const char* function, int line, const char* file, const agx::String& msg ) { Notify::instance()->info(function,line,file,msg); };\
426 void warning( const char* function, int line, const char* file, const agx::String& msg ) { Notify::instance()->warning(function,line,file,msg); };\
427 void error( const char* function, int line, const char* file, const agx::String& msg ) { Notify::instance()->error(function,line,file,msg); };\
428 ::agx::Notify::Push push() { return Notify::instance()->push(); };\
429 ::agx::Notify::End end() { return Notify::instance()->end(); };\
430 agx::String setDebugStrings( ::agx::Notify::NotifyLevel l, const char* function, int line, const char* file ) { return Notify::instance()->setDebugStrings(l,function,line,file); };\
432 ::agx::Notify& getNotify() {\
433 ::agx::Notify* n = Notify::instance();\
436 const ::agx::Notify& getNotify() const {\
437 ::agx::Notify* n = Notify::instance();\
443 #define NOTIFY_POS_ARGS __FUNCTION__,__LINE__,__FILE__
445 #define NOTIFY_POS_ARGS "",-1,""
448 #define NOTIFY() getNotify()
449 #define NOTIFY_DEBUG() setDebugStrings(::agx::Notify::NOTIFY_DEBUG, NOTIFY_POS_ARGS)
450 #define NOTIFY_INFO() setDebugStrings(::agx::Notify::NOTIFY_INFO, NOTIFY_POS_ARGS)
451 #define NOTIFY_WARNING() setDebugStrings(::agx::Notify::NOTIFY_WARNING, NOTIFY_POS_ARGS)
452 #define NOTIFY_ERROR() setDebugStrings(::agx::Notify::NOTIFY_ERROR, NOTIFY_POS_ARGS)
453 #define NOTIFY_LOG() logOnly()
454 #define NOTIFY_END() end()
455 #define NOTIFY_CLEAR() clear()
456 #define NOTIFY_STATE(X) push().setValue(X)
459 #define NOTIFY_WARNING_IF_nullptr(X,Y) if ( Y == nullptr ) { X << X.NOTIFY_WARNING() << " nullptr pointer: " << #Y << std::endl << X.NOTIFY_END(); }
460 #define NOTIFY_WARNING_IF_FALSE(X,Y) if ( !Y ) { X << X.NOTIFY_WARNING() << " Test false: " << #Y <<std::endl << X.NOTIFY_END(); }
461 #define NOTIFY_WARNING_IF_TRUE(X,Y) if ( Y ) { X << X.NOTIFY_WARNING() << " Test true: " << #Y <<std::endl << X.NOTIFY_END(); }
463 #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(); }
464 #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(); }
465 #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(); }
468 #define NOTIFY_INSTANCE() ::agx::Notify::instance()
473 # pragma warning(pop)
Class for printing out messages to console, file, virtual method and or a callback function...
AGXTERRAIN_EXPORT void clear()
void AGXPHYSICS_EXPORT init()
Initialize agx.
void AGXPHYSICS_EXPORT shutdown()
Shutdown agx.
agx::Thread is a representation of an OS specific implementation of a computational thread...
std::ostream & operator<<(std::ostream &stream, const AtomicValueT< T > &value)
AgXString< std::string > String
#define AGX_DECLARE_POINTER_TYPES(type)
Base class providing referencing counted objects.
Class for handling logging of messages.
AGXLUA_EXPORT void error(lua_State *L)
GLenum GLuint GLenum GLsizei const GLchar * message
Callback class, derive from this and Register to the notify singleton to get callbacks.
Smart pointer for handling referenced counted objects.
std::recursive_mutex ReentrantMutex
void AGXCORE_EXPORT setNumThreads(size_t numThreads)
Set the number of threads to use (including the main thread).
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Inheritance with partial specialization due to bug with ref_ptr containers.
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...