IChecksum.hh 2.25 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// (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
15
16
17

#define TEST_only(CC)

18
#else
19
20

#include <Base/Test/TestResult.hh>
21
#include "Base/Utils/IOutputStream.hh"
22
23
24
25
26

#include <map>
#include <sstream>

namespace Test {
27
  
28
namespace Checksum {
29
  
30
31
32
33
34
35
36
37
/*!
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
{
public:
38
  //! Checksum name. 
39
40
  const char* name() const { return name_; }

41
42
43
  /*!
  Override compare to perform a comparison of the results stored in
  directories _dir0 and _dir1.
44
45
  Returns an estimation of the difference between the two test run and
  a description of the difference.
46
47
  */
  virtual Severity compare(
48
49
50
51
52
    IStream& _str0, //!<[in] First stream with checksum data
    IStream& _str1, //!<[in] Second stream with checksum data
    OStream& _os,   //!<[out] Description of the difference.
    const Path* _dir0 = nullptr, //!<[in] FIrst test directory
    const Path* _dir1 = nullptr  //!<[in] Second test directory
53
54
55
56
57
58
59
    ) const = 0;

protected:
  /*!
  Performs an automatic registration of the new checksum in a 
  global list, and verifies that the name is unique.
  */
60
  IChecksum(const char* _name);
61

62
  Base::IOutputStream& record(const Result& _rep_res) const;
63

64
private:
65
  const char* name_;
66
67
68
};

/*!
69
70
Definition of the checksums registry. It is a map from a string (that is the 
checksum name to an IChecksum.
71
*/
72
typedef std::map<std::string, IChecksum*> Registry; 
73
74
75
76
77
78
79
80
81
82
83
84

/*!
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