| 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 |
| 17 | typedef uint32 CatId; |
| 18 | const CatId kIllegalCatId = static_cast<CatId>(0); |
| 19 | |
| 20 | typedef uint32 TermId; |
| 21 | const TermId kIllegalTermId = static_cast<TermId>(0); |
| 22 | |
| 23 | typedef uint32 HostId; |
| 24 | const HostId kIllegalHostId = static_cast<HostId>(0); |
| 25 | |
| 26 | typedef uint32 DomainId; |
| 27 | const 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 |
| 36 | typedef uint16 ; // value in [0, kNumPageRankValues) |
| 37 | const int = 1 << (sizeof(DocumentPageRank) * 8); |
| 38 | const DocumentPageRank = 0; |
| 39 | |
| 40 | // Used for fielded search |
| 41 | typedef int32 FieldValue; |
| 42 | const 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. |
| 46 | typedef uint64 Fprint; |
| 47 | const Fprint kIllegalFprint = static_cast<Fprint>(0); |
| 48 | const Fprint kMaxFprint = static_cast<Fprint>(kuint64max); |
| 49 | |
| 50 | // 64 bit checksum (see common/checksummer.{h,cc}) |
| 51 | typedef uint64 Checksum64; |
| 52 | |
| 53 | const 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. |
| 58 | typedef uint32 Hash32; |
| 59 | typedef uint16 Hash16; |
| 60 | typedef unsigned char Hash8; |
| 61 | |
| 62 | const Hash32 kIllegalHash32 = static_cast<Hash32>(4294967295UL); // 2^32-1 |
| 63 | const Hash16 kIllegalHash16 = static_cast<Hash16>(65535U); // 2^16-1 |
| 64 | const 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.. |
| 73 | typedef 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. |
| 78 | enum Ownership { |
| 79 | DO_NOT_TAKE_OWNERSHIP, |
| 80 | TAKE_OWNERSHIP |
| 81 | }; |
| 82 | |
| 83 | // Use these as the mlock_bytes parameter to MLock and MLockGeneral |
| 84 | enum { 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); |
| 99 | namespace base { |
| 100 | enum LinkerInitialized { LINKER_INITIALIZED }; |
| 101 | } |
| 102 | |
| 103 | #endif // _BASICTYPES_H_ |
| 104 | |