Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

MediaPagePool Class Reference

#include <mcache.h>

Inheritance diagram for MediaPagePool:

Inheritance graph
[legend]
Collaboration diagram for MediaPagePool:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MediaPagePool ()
int num_pages () const
int num_pages () const

Protected Member Functions

virtual int command (int argc, const char *const *argv)
TclObjectlookup_obj (const char *name)
TclObjectlookup_obj (const char *name)

Protected Attributes

int layer_
int * size_
RandomVariablervReq_
int num_pages_
double start_time_
double end_time_
int duration_

Constructor & Destructor Documentation

MediaPagePool::MediaPagePool  ) 
 

Definition at line 615 of file mcache.cc.

References PagePool::duration_, layer_, and size_.

00615                              : PagePool()
00616 {
00617         size_ = NULL;
00618         duration_ = 0;
00619         layer_ = 1;
00620 }


Member Function Documentation

int MediaPagePool::command int  argc,
const char *const *  argv
[protected, virtual]
 

Reimplemented from PagePool.

Definition at line 623 of file mcache.cc.

References abort(), PagePool::command(), PagePool::duration_, PagePool::end_time_, layer_, PagePool::num_pages_, rvReq_, size_, PagePool::start_time_, and RandomVariable::value().

00624 {
00625         Tcl& tcl = Tcl::instance();
00626 
00627         if (argc == 2) {
00628                 if (strcmp(argv[1], "get-poolsize") == 0) { 
00629                         tcl.resultf("%d", num_pages_);
00630                         return TCL_OK;
00631                 } else if (strcmp(argv[1], "get-start-time") == 0) {
00632                         tcl.resultf("%.17g", start_time_);
00633                         return TCL_OK;
00634                 } else if (strcmp(argv[1], "get-duration") == 0) {
00635                         tcl.resultf("%d", duration_);
00636                         return TCL_OK;
00637                 }
00638         } else if (argc == 3) {
00639                 if (strcmp(argv[1], "gen-pageid") == 0) {
00640                         // Generating requested page id
00641                         if (rvReq_ == NULL) {
00642                                 tcl.add_errorf("no page id ranvar.");
00643                                 return TCL_ERROR;
00644                         }
00645                         int p = (int)rvReq_->value();
00646                         assert((p >= 0) && (p < num_pages_));
00647                         tcl.resultf("%d", p);
00648                         return TCL_OK;
00649                 } else if (strcmp(argv[1], "is-media-page") == 0) {
00650                         // XXX Currently all pages are media pages. Should
00651                         // be able to allow both normal pages and media pages
00652                         // in the future
00653                         tcl.result("1");
00654                         return TCL_OK;
00655                 } else if (strcmp(argv[1], "get-layer") == 0) {
00656                         // XXX Currently all pages have the same number of 
00657                         // layers. Should be able to change this in future.
00658                         tcl.resultf("%d", layer_); 
00659                         return TCL_OK;
00660                 } else if (strcmp(argv[1], "set-start-time") == 0) {
00661                         double st = strtod(argv[2], NULL);
00662                         start_time_ = st;
00663                         end_time_ = st + duration_;
00664                         return TCL_OK;
00665                 } else if (strcmp(argv[1], "set-duration") == 0) {
00666                         // XXX Need this info to set page mod time!!
00667                         duration_ = atoi(argv[2]);
00668                         end_time_ = start_time_ + duration_;
00669                         return TCL_OK;
00670                 } else if (strcmp(argv[1], "gen-init-modtime") == 0) {
00671                         // XXX We are not interested in page consistency here,
00672                         // so never change this page.
00673                         tcl.resultf("%d", -1);
00674                         return TCL_OK;
00675                 } else if (strcmp(argv[1], "gen-size") == 0) {
00676                         int pagenum = atoi(argv[2]);
00677                         if (pagenum >= num_pages_) {
00678                                 tcl.add_errorf("Invalid page id %d", pagenum);
00679                                 return TCL_ERROR;
00680                         }
00681                         tcl.resultf("%d", size_[pagenum]);
00682                         return TCL_OK;
00683                 } else if (strcmp(argv[1], "set-layer") == 0) {
00684                         layer_ = atoi(argv[2]);
00685                         return TCL_OK;
00686                 } else if (strcmp(argv[1], "set-num-pages") == 0) {
00687                         if (size_ != NULL) {
00688                                 tcl.add_errorf("can't change number of pages");
00689                                 return TCL_ERROR;
00690                         }
00691                         num_pages_ = atoi(argv[2]);
00692                         size_ = new int[num_pages_];
00693                         return TCL_OK;
00694                 } else if (strcmp(argv[1], "ranvar-req") == 0) {
00695                         rvReq_ = (RandomVariable*)TclObject::lookup(argv[2]);
00696                         return TCL_OK;
00697                 }
00698         } else if (argc == 4) {
00699                 if (strcmp(argv[1], "gen-modtime") == 0) {
00700                         // This should never be called, because we never
00701                         // deals with page modifications!!
00702                         fprintf(stderr, "%s: gen-modtime called!\n", name());
00703                         abort();
00704                 } else if (strcmp(argv[1], "set-pagesize") == 0) {
00705                         // <pagepool> set-pagesize <pagenum> <size>
00706                         int pagenum = atoi(argv[2]);
00707                         if (pagenum >= num_pages_) {
00708                                 tcl.add_errorf("Invalid page id %d", pagenum);
00709                                 return TCL_ERROR;
00710                         }
00711                         size_[pagenum] = atoi(argv[3]);
00712                         return TCL_OK;
00713                 }
00714         }
00715         return PagePool::command(argc, argv);
00716 }

Here is the call graph for this function:

TclObject* PagePool::lookup_obj const char *  name  )  [inline, protected, inherited]
 

Definition at line 242 of file pagepool.h.

00242                                                 {
00243                 TclObject* obj = Tcl::instance().lookup(name);
00244                 if (obj == NULL) 
00245                         fprintf(stderr, "Bad object name %s\n", name);
00246                 return obj;
00247         }

TclObject* PagePool::lookup_obj const char *  name  )  [inline, protected, inherited]
 

Definition at line 30 of file persconn.h.

Referenced by WebTrafPool::command(), EmpWebTrafPool::command(), EmpFtpTrafPool::command(), WebTrafPool::lookup_rv(), EmpWebTrafPool::lookup_rv(), EmpFtpTrafPool::lookup_rv(), WebTrafPool::picksink(), EmpWebTrafPool::picksink(), EmpFtpTrafPool::picksink(), WebTrafPool::picktcp(), EmpWebTrafPool::picktcp(), and EmpFtpTrafPool::picktcp().

00030                                                 {
00031                 TclObject* obj = Tcl::instance().lookup(name);
00032                 if (obj == NULL) 
00033                         fprintf(stderr, "Bad object name %s\n", name);
00034                 return obj;
00035         }

int PagePool::num_pages  )  const [inline, inherited]
 

Definition at line 233 of file pagepool.h.

References PagePool::num_pages_.

00233 { return num_pages_; }

int PagePool::num_pages  )  const [inline, inherited]
 

Definition at line 21 of file persconn.h.

References PagePool::num_pages_.

00021 { return num_pages_; }


Member Data Documentation

int PagePool::duration_ [protected, inherited]
 

Definition at line 239 of file pagepool.h.

Referenced by TracePagePool::change_time(), ProxyTracePagePool::command(), CompMathPagePool::command(), MathPagePool::command(), TracePagePool::command(), command(), ProxyTracePagePool::find_info(), and MediaPagePool().

double PagePool::end_time_ [protected, inherited]
 

Definition at line 238 of file pagepool.h.

Referenced by TracePagePool::change_time(), CompMathPagePool::command(), MathPagePool::command(), TracePagePool::command(), command(), TracePagePool::load_page(), and PagePool::PagePool().

int MediaPagePool::layer_ [protected]
 

Definition at line 232 of file mcache.h.

Referenced by command(), and MediaPagePool().

int PagePool::num_pages_ [protected, inherited]
 

Definition at line 236 of file pagepool.h.

Referenced by ClientPagePool::add_page(), EPATracePagePool::command(), ProxyTracePagePool::command(), ClientPagePool::command(), CompMathPagePool::command(), TracePagePool::command(), command(), CompMathPagePool::CompMathPagePool(), ProxyTracePagePool::find_info(), TracePagePool::get_page(), ProxyTracePagePool::init_page(), TracePagePool::load_page(), MathPagePool::MathPagePool(), PagePool::num_pages(), PagePool::PagePool(), and ClientPagePool::remove_page().

RandomVariable* MediaPagePool::rvReq_ [protected]
 

Definition at line 234 of file mcache.h.

Referenced by command().

int* MediaPagePool::size_ [protected]
 

Definition at line 233 of file mcache.h.

Referenced by command(), and MediaPagePool().

double PagePool::start_time_ [protected, inherited]
 

Definition at line 237 of file pagepool.h.

Referenced by TracePagePool::change_time(), ProxyTracePagePool::command(), CompMathPagePool::command(), MathPagePool::command(), TracePagePool::command(), command(), TracePagePool::load_page(), ProxyTracePagePool::load_req(), and PagePool::PagePool().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 12:59:58 2004 for NS2.26SourcesOriginal by doxygen 1.3.3