Weevil Workload Generation Library C++ API documentation (v. 1.0.1)

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

weevil.h

00001 // -*- C++ -*- 00002 // 00003 // This file is part of WEEVIL. 00004 // 00005 // Authors: See the file AUTHORS for full details. 00006 // 00007 // Copyright (C) 2002-2004 University of Colorado 00008 // 00009 // This program is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU General Public License 00011 // as published by the Free Software Foundation; either version 2 00012 // of the License, or (at your option) any later version. 00013 // 00014 // This program is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with this program; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, 00022 // USA, or send email to [email protected]. 00023 // 00024 // $Id: weevil.h,v 1.1.1.1 2004/11/02 23:36:43 ywang Exp $ 00025 // 00026 #ifndef WEEVIL_WEEVIL_H 00027 #define WEEVIL_WEEVIL_H 00028 00029 #include <iostream> 00030 #include <map> 00031 #include <set> 00032 #include <siena/ssim.h> 00033 #include <siena/tprocess.h> 00034 #include <string> 00035 00039 namespace weevil 00040 { 00044 class WeevilGen : public ssim::Sim 00045 { 00046 static std::map<std::string,ssim::ProcessId> m_id2pid; 00047 static std::map<ssim::ProcessId,std::string> m_pid2id; 00048 00049 public: 00050 // Adds process to the internal maps of processes. 00051 // 00052 static void add_process( const std::string& id, ssim::ProcessId pid ) 00053 { 00054 m_id2pid.insert( make_pair( id, pid ) ); 00055 m_pid2id.insert( make_pair( pid, id ) ); 00056 } 00057 00060 static void broadcast_event( const ssim::Event* event, ssim::Time lag = 0 ); 00061 00062 // Static method to return the ProcessId given a 00063 // particular identifier. 00064 // 00065 static ssim::ProcessId id2pid( const std::string& id ); 00066 00067 // returns the id of the process that has 00068 // number pid. 00069 // 00070 static const std::string& pid2id( ssim::ProcessId pid ); 00071 00074 static void self_signal_event( const ssim::Event* event, ssim::Time lag = 0 ); 00075 00078 static void signal_event( const std::string& id, const ssim::Event* event, ssim::Time lag = 0 ); 00079 }; 00080 00085 class WeevilActor 00086 { 00087 std::string m_id; 00088 ssim::ProcessId m_pid; 00089 00090 public: 00091 // Sets the id of the process. 00092 // 00093 void id( const std::string& id ) 00094 { m_id = id; } 00095 00096 // Returns the id of the process. 00097 // 00098 const std::string& id() const 00099 { return m_id; } 00100 00101 // Sets the processes processid. 00102 // 00103 void pid( ssim::ProcessId pid ) 00104 { m_pid = pid; } 00105 00106 // Returns the pid of the process. 00107 // 00108 ssim::ProcessId pid() const 00109 { return m_pid; } 00110 00113 void workload_output( const char* body ) const 00114 { std::cout << "event(" << ssim::Sim::clock() << "," << m_id << "," << body << ")" << std::endl; } 00115 }; 00116 00120 class WeevilProcess : public ssim::Process, public weevil::WeevilActor 00121 { 00122 public: 00123 // Constructor chains to superclass. 00124 // 00125 WeevilProcess() : Process() {} 00126 }; 00127 00131 class WeevilTProcess : public ssim::TProcess, public weevil::WeevilActor 00132 { 00133 public: 00134 // Constructor chains to superclass. 00135 // 00136 WeevilTProcess() : TProcess() {} 00137 00140 static const ssim::Event * wait_for_event(ssim::Time timeout = ssim::INIT_TIME) 00141 { 00142 return ssim::TProcess::wait_for_event(timeout); 00143 } 00144 }; 00145 00149 class KillerProcess : public ssim::Process 00150 { 00151 private: 00152 unsigned int m_delay; 00153 public: 00154 KillerProcess( unsigned int delay ) 00155 : m_delay( delay ) {} 00156 00157 void init() 00158 { 00159 ssim::Sim::set_stop_time( m_delay ); 00160 } 00161 }; 00162 }; 00163 00164 #endif

Copyright © 2002-2004 University of Colorado.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". This documentation is authored and maintained by Yanyan Wang