Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

talker.h

Go to the documentation of this file.
00001 /** @file talker.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 _TALKER_H
00023 #define _TALKER_H
00024 
00025 #include "graphbuilder.h"
00026 #include "sampler.h"
00027 #include "pvminterface.h"
00028 #include <algorithm>
00029 #include <sstream>
00030 
00031 /// An array of these is sent to synchronize simulations
00032 struct LeafCountsStruct {
00033   uint32 id;
00034   uint32 occupation_count;
00035 };
00036 
00037 /// Used for sorting
00038 /* struct less_LeafCountsStruct: public binary_function<LeafCountsStruct,LeafCountsStruct,bool> { */
00039 /*   bool operator()(LeafCountsStruct x, LeafCountsStruct y) {  */
00040 /*     return (x.id < y.id); */
00041 /*   } */
00042 /* }; */
00043 
00044 #define MAXLEAFMESSAGE_SIZE ((5 * Mb)/sizeof(LeafCountsStruct))
00045 
00046 /// Reads and executes interactive user commands.
00047 class Talker {
00048  public:
00049   Talker(const char* rippername, const char* tempdir,
00050          WebLinkGraph *ripperweb, GraphBuilder *rippergb,
00051          bool pvm_is_master, int pvm_numtasks) throw (exception);
00052   ~Talker();
00053 
00054   void Talk() throw (exception);
00055 
00056   void PropagateLeafCounts() throw (invalid_argument);
00057 
00058   void PrintStatistics(ostream& o);
00059   void PrintStatisticsGraph(ostream& o);
00060 
00061   bool BuildTags(ifstream& g);
00062   bool LoadLeaves(ifstream& g);
00063 
00064   int GetToken(char* command, ostream& out, char* message, int n, ...);
00065   char *GetTokenVar(char* command, ostream& out, char* message);
00066   bool ProcessCommand(char *command, ostream& out);
00067 
00068   void SetupFIFOs() throw (exception);
00069   void RemoveFIFOs();
00070 
00071  private:
00072 
00073   ostringstream inputfifo;
00074   ostringstream outputfifo;
00075   ostringstream nodequiv;
00076   const char *name;
00077   const char *tempdir;
00078   WebLinkGraph *web;
00079   GraphBuilder *gb;
00080 
00081   gsl_rng* r; // for random numbers
00082 
00083   PageRankSampler *prsampler;
00084   DateBiasedPageRankSampler *dbsampler;
00085   TruncatedKleinbergSampler *tksampler;
00086   WebSampler *defaultsampler;
00087 
00088   PVMInterface *pvminterface;
00089 
00090   LeafNodePtrList *leaflist;
00091 };
00092 
00093 #endif

Generated on Wed May 29 11:37:16 2002 for MarkovPR by doxygen1.2.15