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 DocumentPageRank; // value in [0, kNumPageRankValues) 37 const int kNumPageRankValues = 1 << (sizeof(DocumentPageRank) * 8); 38 const DocumentPageRank kIllegalPagerank = 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 // MetatagId refers to metatag-id that we assign to 68 // each metatag <name, value> pair.. 69 typedef uint32 MetatagId; 70 71 // Argument type used in interfaces that can optionally take ownership 72 // of a passed in argument. If TAKE_OWNERSHIP is passed, the called 73 // object takes ownership of the argument. Otherwise it does not. 74 enum Ownership { 75 DO_NOT_TAKE_OWNERSHIP, 76 TAKE_OWNERSHIP 77 }; 78 79 // Use these as the mlock_bytes parameter to MLock and MLockGeneral 80 enum { MLOCK_ALL = -1, MLOCK_NONE = 0 }; 81 82 // The following enum should be used only as a constructor argument to indicate 83 // that the variable has static storage class, and that the constructor should 84 // do nothing to its state. It indicates to the reader that it is legal to 85 // declare a static nistance of the class, provided the constructor is given 86 // the base::LINKER_INITIALIZED argument. Normally, it is unsafe to declare a 87 // static variable that has a constructor or a destructor because invocation 88 // order is undefined. However, IF the type can be initialized by filling with 89 // zeroes (which the loader does for static variables), AND the type's 90 // destructor does nothing to the storage, then a constructor for static initialization 91 // can be declared as 92 // explicit MyClass(base::LinkerInitialized x) {} 93 // and invoked as 94 // static MyClass my_variable_name(base::LINKER_INITIALIZED); 95 namespace base { 96 enum LinkerInitialized { LINKER_INITIALIZED }; 97 } 98 99 #endif // _BASICTYPES_H_ 100