// (C) Copyright 2016 by Autodesk, Inc. // // The information contained herein is confidential, proprietary // to Autodesk, Inc., and considered a trade secret as defined // in section 499C of the penal code of the State of California. // Use of this information by anyone other than authorized // employees of Autodesk, Inc. is granted only under a written // non-disclosure agreement, expressly prescribing the scope // and manner of such use. #ifndef BASE_CHECKSUMLOGVALUET_HH_INCLUDE #define BASE_CHECKSUMLOGVALUET_HH_INCLUDE #ifdef TEST_ON #include "IChecksum.hh" #include "Base/Debug/DebDefault.hh" #include namespace Test { namespace Checksum { /*! Utility class to compare double with a tolerance. Can be used to redefine the default compare class in class LogValueT. */ struct DoubleEqual { DoubleEqual(double _tol = 1e-12) : tol_(_tol) {} bool operator()(const double& _a, const double& _b) const { return std::fabs(_a - _b) <= tol_; } private: double tol_; }; /*! Class that can be used to specialize the behavior of LogValueT in such a way that it only checks the number of occurrences. */ struct Count { bool operator==(const Count&) const { return true; } friend std::istream& operator >> (std::istream& _is, Count&) { return _is; } friend std::ostream& operator << (std::ostream& _os, const Count&) { return _os; } }; /*! Generic Checksum class to compare data that can be read from a output file (default Debug::Default::LOG_FILENAME). It searches all occurrences of a string in the file and reads the next field to get the checksum value. If ValueT == Count it simply counts the number of occurrences of the search string. */ template > class LogValueT : public IChecksum { public: const char* flnm_; // File to parse const char* key_; // String to search as information key. LogValueT( unsigned _order, //!<[in] Execution order. Low order means high priority. const char* _name, //!<[in] Checksum name. const char* _key, //!<[in] String to search in the output file. const CompareT& _comp = CompareT(), //!<[in] Comparison function. const char* _flnm = Debug::Default::LOG_FILENAME //*!<[in] File to parse to get the information. ); virtual Severity report(const Path& _dir, std::stringstream& _os) const; virtual Severity compare(const Path& _dir0, const Path& _dir1, std::stringstream& _os) const; private: CompareT comp_; // Compare class. LogValueT& operator=(const LogValueT&); }; }//namespace Checksum }//namespace Test #endif//TEST_ON #endif//BASE_CHECKSUMLOGVALUET_HH_INCLUDE