ChecksumLogValueT.cc 2.01 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
// (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.

#ifdef TEST_ON

#include "ChecksumLogValueT.hh"
14
#include "ReadValuesT.hh"
15
#include "StreamContainerT.hh"
16
17
18
#include "TestStream.hh"

#include "Base/Debug/DebOut.hh"
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

#include <boost/filesystem.hpp>

#include <vector>

namespace Test {
namespace Checksum {

// class ChecksumLog implementation
  
namespace { // ChecksumLog locals

template <typename ValueT>
std::ostream& operator<<(std::ostream& _out_str, const std::vector<ValueT>& _vals)
{
  return write_container(_out_str, _vals);
}

37
}//namespace
38
39
40
41

// Class LogValueT

template <typename ValueT, class CompareT> 
42
43
LogValueT<ValueT, CompareT>::LogValueT(const char* _name, const CompareT& _comp)
  : IChecksum(_name), comp_(_comp)
44
45
46
{}

template <typename ValueT, class CompareT>
47
Severity LogValueT<ValueT, CompareT>::compare(const Path& _dir0, 
48
  const Path& _dir1, OStream& _os) const
49
{
50
51
  auto list0 = read_values<ValueT>("", "", _dir0);
  auto list1 = read_values<ValueT>("", "", _dir1);
52
53
54
55
56
57
58
  if (list0.size() != list1.size())
  {
    _os << '#' << list0.size() << " #" << list1.size();
    return 1;
  }
  for (auto i = list0.size(); i-- > 0; )
  {
59
    if (comp_.same(list0[i], list1[i]))
60
61
62
63
64
65
66
67
68
69
70
71
    {
      list0.erase(list0.begin() + i);
      list1.erase(list1.begin() + i);
    }
  }
  if (list0.empty() && list1.empty())
    return 0;
  _os << list0 << " " << list1;
  return 0.5;
}

template <typename ValueT, class CompareT>
72
void LogValueT<ValueT, CompareT>::record(const Result& _rep_res, const ValueT& _val)
73
{
74
  stream_out() << _rep_res << "  " << name() << ": " << _val << std::endl;
75
76
77
}

}//namespace Checksum
78
}//namespace Test
79
80

#endif//TEST_ON