00001 /** @file leafnode.h */ 00002 /* 00003 * Copyright (C) 2002 Laird Breyer 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 * 00019 * Author: Laird Breyer <laird@lbreyer.com> 00020 */ 00021 00022 #ifndef _LEAF_NODE_H_ 00023 #define _LEAF_NODE_H_ 00024 #include "mempool.h" 00025 #include "simplehash.h" 00026 #include <slist> 00027 00028 /// Encapsulates a WebNode which exists on another machine. 00029 class LeafNode; // defined below 00030 /// All LeafNodes are allocated on the heap as LeafNodePtrs. 00031 typedef LeafNode* LeafNodePtr; 00032 00033 /// Allows a leaf node to be found through an url 00034 typedef SimpleHashTable<LeafNodePtr> SimpleLeafNodePtrHashTable; 00035 00036 /// A linked list of all LeafNode objects 00037 typedef slist<LeafNodePtr> LeafNodePtrList; 00038 00039 #define Mb 1048576L 00040 #define LEAFNODE_MEMPOOL_DELTA ((1 * Mb)/sizeof(LeafNode)) 00041 00042 /// Contains all the information about a web document stored somewhere else. 00043 struct LeafNodeStruct { 00044 // the ordering here is important due to alignment issues 00045 uint32 id; 00046 uint16 date; 00047 uint32 occupation_count; 00048 }; 00049 00050 /// Encapsulates a web document on another machine. 00051 /** 00052 * When several machines process (disjoint subsets of) the repository, 00053 * it is necessary to link the WebNode objects between the machines, so 00054 * as to allow a WebSampler simulation to span multiple machines. 00055 * A LeafNode is an alias for a WebNode stored on another machine, and 00056 * linked to by a WebNode on the current machine. The data stored in 00057 * a LeafNode is only sufficient to allow the corresponding WebNode to 00058 * be found. 00059 * The class inherits memory management from MemoryPooled<T>. 00060 */ 00061 class LeafNode: public MemoryPooled<LeafNodeStruct> { 00062 public: 00063 00064 LeafNode(uint32 idno); 00065 00066 uint32 ID() 00067 { return data.id; } 00068 uint16 Date() 00069 { return data.date; } 00070 00071 void SetDate(uint16 adate) 00072 { data.date = adate; } 00073 00074 void ClearOccupationCount() 00075 { 00076 data.occupation_count = 0; 00077 } 00078 uint32 OccupationCount() 00079 { return data.occupation_count; } 00080 void IncrementOccupationCount() 00081 { data.occupation_count++; } 00082 00083 }; 00084 00085 #endif