• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _TCUSEEDBUILDER_HPP
2 #define _TCUSEEDBUILDER_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Tester Core
5  * ----------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief Utility class to build seeds from different data types.
24  *
25  * Values are first XORed with type specifig mask, which makes sure that
26  * two values with different types, but same bit presentation produce
27  * different results. Then values are passed through 32 bit crc.
28  *//*--------------------------------------------------------------------*/
29 
30 #include "tcuDefs.hpp"
31 #include "tcuVector.hpp"
32 
33 #include <string>
34 #include <vector>
35 
36 namespace tcu
37 {
38 
39 class SeedBuilder
40 {
41 public:
42 				SeedBuilder	(void);
get(void) const43 	deUint32	get			(void) const { return m_hash; }
44 	void		feed		(size_t size, const void* ptr);
45 
46 private:
47 	deUint32	m_hash;
48 } DE_WARN_UNUSED_TYPE;
49 
50 SeedBuilder& operator<< (SeedBuilder& builder, bool value);
51 SeedBuilder& operator<< (SeedBuilder& builder, deInt8 value);
52 SeedBuilder& operator<< (SeedBuilder& builder, deUint8 value);
53 
54 SeedBuilder& operator<< (SeedBuilder& builder, deInt16 value);
55 SeedBuilder& operator<< (SeedBuilder& builder, deUint16 value);
56 
57 SeedBuilder& operator<< (SeedBuilder& builder, deInt32 value);
58 SeedBuilder& operator<< (SeedBuilder& builder, deUint32 value);
59 
60 SeedBuilder& operator<< (SeedBuilder& builder, deInt64 value);
61 SeedBuilder& operator<< (SeedBuilder& builder, deUint64 value);
62 
63 SeedBuilder& operator<< (SeedBuilder& builder, float value);
64 SeedBuilder& operator<< (SeedBuilder& builder, double value);
65 
66 SeedBuilder& operator<< (SeedBuilder& builder, const std::string& value);
67 
68 template<class T, int Size>
operator <<(SeedBuilder & builder,const tcu::Vector<T,Size> & value)69 SeedBuilder& operator<< (SeedBuilder& builder, const tcu::Vector<T, Size>& value)
70 {
71 	for (int i = 0; i < Size; i++)
72 		builder << value[i];
73 
74 	return builder;
75 }
76 
77 } // tcu
78 
79 #endif // _TCUSEEDBUILDER_HPP
80