//------------------------------------------------------------------- // // ZMexDerivedAug.h // // // This class must derive from a ZMexAugmented or ZMexDerivedAug class // and it will have the same type of extraObj as its parent class. // // 08-02-99 jvr Created // //------------------------------------------------------------------ #ifndef ZM_EXDERIVEDAUG_H #define ZM_EXDERIVEDAUG_H #include "ErrLogEx/ZMexAugmented.h" #include "Exceptions/ZMexClassInfo.h" #include "ErrorLogger/ErrorObj.h" #include "ErrorLogger/ErrorLog.h" template class ZMexDerivedAug: public Parent { public: typedef typename Parent::T_type T_type; static ZMexClassInfo _classInfo; public: ZMexDerivedAug( T_type& extra, string ExName = _classInfo.name(), const ZMexSeverity howBad = ZMexSEVERITYenumLAST, int count =_classInfo.nextCount() ) : Parent( extra , ExName , (howBad == ZMexSEVERITYenumLAST ? _classInfo.severity() : howBad) , count ) { } //Constructor with ErrorObj parameter ZMexDerivedAug( T_type& extra, ErrorObj& errObj, const ZMexSeverity howBad = ZMexSEVERITYenumLAST, int count =_classInfo.nextCount() ) : Parent( extra , errObj , (howBad == ZMexSEVERITYenumLAST ? _classInfo.severity() : howBad) , count ) { } virtual ~ZMexDerivedAug() {} static void setName(string newName) { _classInfo.setName(newName); } static void setFacility(string newFacility) { _classInfo.setFacility(newFacility); } static void setSeverity(ZMexSeverity newSeverity) { _classInfo.setSeverity(newSeverity); } static ZMexHandler setHandler( const ZMexHandler & newHandler ) { return _classInfo.setHandler( newHandler); } static ZMexHandler getHandler() { return _classInfo.getHandler(); } static ZMexLogger setLogger( const ZMexLogger & newLogger ) { return _classInfo.setLogger( newLogger ); } static ZMexLogger getLogger() { return _classInfo.getLogger(); } static bool isTypeOf( const ZMexception & x ) { return ( (_classInfo.name() == x.name()) && (_classInfo.facility() == x.facility() ) ); } static bool isBaseOf( const ZMexception & x ) { return ( x.isDerivedFrom (_classInfo.name(),_classInfo.facility()) ); } static void logNMore( const int N ) { _classInfo.logNMore( N ); } virtual ZM_COVARIANT_TYPE(ZMexception, ZMexDerivedAug) * clone() const { return new ZMexDerivedAug( *this ); } virtual ZMexClassInfo & classInfo() const { return ZMexDerivedAug::_classInfo; } virtual ZMexAction handleMe() const { /* DEBUG cerr << #Class "::handleMe()" << endl; */ ZMexAction result = ZMexDerivedAug::classInfo().getHandler().takeCareOf( *this ); return (result == ZMexHANDLEVIAPARENT) ? Parent::handleMe() : result; } virtual ZMexLogResult logMe() const { /* DEBUG cerr << #Class "::logMe()" << endl; */ ZMexLogResult result = ZMexDerivedAug::classInfo().getLogger().emit( *this ); return (result == ZMexLOGVIAPARENT) ? Parent::logMe() : result; } virtual bool isDerivedFrom( const string aName, const string aFacility ) const { T_type tempExtra; Parent tempParent(tempExtra, "temp", ZMexNORMAL, count()-1); return aName == name() && aFacility == facility() ? true : tempParent.isDerivedFrom( aName, aFacility ); } }; //ZMexDerivedAug template ZMexClassInfo ZMexDerivedAug::_classInfo("ZMexDerivedAug", Parent::_classInfo.facility()); #endif // ZM_EXDERIVEDAUG_H