21 # pragma warning(push) 22 # pragma warning(disable: 4355) // No warnings about using this in member initializer list 33 #define THREAD_SAFE_NOTIFY 1 35 #if THREAD_SAFE_NOTIFY 45 class ThreadDataHolder;
56 virtual void message(
const agx::String& msg,
int notifyLevel) = 0;
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);
116 bool getThrowOnError()
const;
119 void setThrowOnError(
bool v );
130 void setBreakOnError(
bool f );
133 bool getBreakOnError()
const;
152 void addStream( std::ostream* stream,
NotifyLevel l );
158 bool removeStream( std::ostream* stream );
164 bool setNotifyLevel( std::ostream* stream,
NotifyLevel l );
173 bool getToLogOnly()
const;
176 void setToLogOnly(
bool f );
178 std::ostream& outStream();
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 ) {}
200 const Notify* getNotify()
const {
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 ) {
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;
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();
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();
339 bool popPrintSelection();
356 friend class ThreadDataHolder;
358 std::
string str() const;
360 void str( const
std::
string& text );
375 CallbackMap m_callbacks;
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() 474 # 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 Dynamics API including thread resources and must be executed before using the AGX API...
void AGXPHYSICS_EXPORT shutdown()
Shutdown of the AGX Dynamics API will be done when the number of shutdown matches the number of calls...
agx::Thread is a representation of an OS specific implementation of a computational thread...
#define AGX_DECLARE_POINTER_TYPES(type)
Base class providing referencing counted objects.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Class for handling logging of messages.
Callback class, derive from this and Register to the notify singleton to get callbacks.
Smart pointer for handling referenced counted objects.
std::ostream & operator<<(std::ostream &os, const agx::AddedMassInteraction::Matrix6x6 &m)
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...
Contains function for initialization and shutdown of agxCore library when agxPhysics is not used...