1//
2// Copyright 2001 - 2003 Google, Inc.
3//
4
5#ifndef _BASICTYPES_H_
6#define _BASICTYPES_H_
7
8#include "base/integral_types.h"
9#include "base/casts.h"
10#include "base/port.h"
11
12//
13// Google-specific types
14//
15
16// id for odp categories
17typedef uint32 CatId;
18const CatId kIllegalCatId = static_cast<CatId>(0);
19
20typedef uint32 TermId;
21const TermId kIllegalTermId = static_cast<TermId>(0);
22
23typedef uint32 HostId;
24const HostId kIllegalHostId = static_cast<HostId>(0);
25
26typedef uint32 DomainId;
27const DomainId kIllegalDomainId = static_cast<DomainId>(0);
28
29// Pagerank related types.
30// TODO(user) - we'd like to move this into google3/pagerank/
31// prtype.h, but this datatype is used all over and that would be
32// a major change.
33// To get a complete picture of all the datatypes used for PageRank
34// and the functions to convert between them, please see google3/
35// pagerank/prtype.h
36typedef uint16 DocumentPageRank; // value in [0, kNumPageRankValues)
37const int kNumPageRankValues = 1 << (sizeof(DocumentPageRank) * 8);
38const DocumentPageRank kIllegalPagerank = 0;
39
40// Used for fielded search
41typedef int32 FieldValue;
42const FieldValue kIllegalFieldValue = static_cast<FieldValue>(INT_MAX);
43
44// It is expected that we *never* have a collision of Fingerprints for
45// 2 distinct objects. No object has kIllegalFprint as its Fingerprint.
46typedef uint64 Fprint;
47const Fprint kIllegalFprint = static_cast<Fprint>(0);
48const Fprint kMaxFprint = static_cast<Fprint>(kuint64max);
49
50// 64 bit checksum (see common/checksummer.{h,cc})
51typedef uint64 Checksum64;
52
53const Checksum64 kIllegalChecksum = static_cast<Checksum64>(0);
54
55// In contrast to Fingerprints, we *do* expect Hash<i> values to collide
56// from time to time (although we obviously prefer them not to). Also
57// note that there is an illegal hash value for each size hash.
58typedef uint32 Hash32;
59typedef uint16 Hash16;
60typedef unsigned char Hash8;
61
62const Hash32 kIllegalHash32 = static_cast<Hash32>(4294967295UL); // 2^32-1
63const Hash16 kIllegalHash16 = static_cast<Hash16>(65535U); // 2^16-1
64const Hash8 kIllegalHash8 = static_cast<Hash8>(255); // 2^8-1
65
66
67// Include docid.h at end because it needs the trait stuff.
68#include "base/docid.h"
69
70
71// MetatagId refers to metatag-id that we assign to
72// each metatag <name, value> pair..
73typedef uint32 MetatagId;
74
75// Argument type used in interfaces that can optionally take ownership
76// of a passed in argument. If TAKE_OWNERSHIP is passed, the called
77// object takes ownership of the argument. Otherwise it does not.
78enum Ownership {
79 DO_NOT_TAKE_OWNERSHIP,
80 TAKE_OWNERSHIP
81};
82
83// Use these as the mlock_bytes parameter to MLock and MLockGeneral
84enum { MLOCK_ALL = -1, MLOCK_NONE = 0 };
85
86// The following enum should be used only as a constructor argument to indicate
87// that the variable has static storage class, and that the constructor should
88// do nothing to its state. It indicates to the reader that it is legal to
89// declare a static nistance of the class, provided the constructor is given
90// the base::LINKER_INITIALIZED argument. Normally, it is unsafe to declare a
91// static variable that has a constructor or a destructor because invocation
92// order is undefined. However, IF the type can be initialized by filling with
93// zeroes (which the loader does for static variables), AND the type's
94// destructor does nothing to the storage, then a constructor for static initialization
95// can be declared as
96// explicit MyClass(base::LinkerInitialized x) {}
97// and invoked as
98// static MyClass my_variable_name(base::LINKER_INITIALIZED);
99namespace base {
100enum LinkerInitialized { LINKER_INITIALIZED };
101}
102
103#endif // _BASICTYPES_H_
104