// (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_ICHECKSUM_HH_INCLUDE #define BASE_ICHECKSUM_HH_INCLUDE #ifndef TEST_ON # define TEST_only(CC) #else #include "types.hh" #include #include #include #include #include namespace Test { namespace Checksum { /*! Base class for test checksum. Whatever check we want to add in the test system, it must be an instance of a class derived from Checksum. All derived classes must be instantiated as global variable in such a way that they are always available. */ class IChecksum { protected: /*!Performs an automatic registration of the new checksum in a global list, and verifies that the name is unique. */ IChecksum(unsigned _order, const char* _name); public: /*!Checksum name. */ const char* name() const { return name_; } /*!Override compare to perform a comparison of the results stored in directories _dir0 and _dir1. Returns an estimation of the difference between the two test run. */ virtual Severity compare( const Test::Path& _dir0, //!< [in] Directory with the reference result const Test::Path& _dir1, //!< [in] Directory with the new result std::stringstream& _os //!< [out] Description of the difference. ) const = 0; /*!Override report to log any "interesting value" that the check has in directory _dir. For example a number of face defects greater that 0. Return an estimation of the severity. */ virtual Severity report( const Test::Path& _dir, //!< [in] Directory with the date to report. std::stringstream& _os //!< [out] Description of the retrieved information. ) const = 0; private: const char * name_; }; /*! Definition of the checksums registry. It is a map with a key made of an order (inverse of a priority) and a name. This allows to have a unique order for checksum execution and output. The idea is to have high priority checksums executed first. */ typedef std::tuple Key; // Order and test name. typedef std::map Registry; /*! Function to get a static map with all the registered checksums. */ const Registry& registry(); }//namespace Checksum }//namespace Test #define TEST_only(CC) CC #endif//TEST_ON #endif//BASE_ICHECKSUM_HH_INCLUDE