Content-Based Networking Simulation Library Documentation (v. 1.2.1)

WorkloadGenerator.h

00001 // -*- C++ -*-
00002 //
00003 //  This file is part of CBNSIM, the Content-Based Networking
00004 //  Simulation Library.
00005 //
00006 //  Authors: See the file AUTHORS for full details.
00007 //
00008 //  Copyright (C) 2002-2004 University of Colorado
00009 //
00010 //  This program is free software; you can redistribute it and/or
00011 //  modify it under the terms of the GNU General Public License
00012 //  as published by the Free Software Foundation; either version 2
00013 //  of the License, or (at your option) any later version.
00014 //
00015 //  This program is distributed in the hope that it will be useful,
00016 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //  GNU General Public License for more details.
00019 //
00020 //  You should have received a copy of the GNU General Public License
00021 //  along with this program; if not, write to the Free Software
00022 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
00023 //  USA, or send email to serl@cs.colorado.edu.
00024 //
00025 // $Id: WorkloadGenerator.h,v 1.2 2004/01/08 16:02:17 rutherfo Exp $
00026 //
00027 #ifndef CBNSIM_WORKLOADGENERATOR_H
00028 #define CBNSIM_WORKLOADGENERATOR_H
00029 
00030 #include <iostream>
00031 #include <vector>
00032 
00033 #include "cbnsim/WorkloadNodeProcessFactory.h"
00034 
00035 namespace cbnsim
00036 {
00041   class WorkloadGenerator
00042     {
00043     public:
00047       WorkloadGenerator( std::ostream& out = std::cout );
00048 
00052       virtual ~WorkloadGenerator();
00053 
00059       void add( WorkloadNodeProcessFactory* wnpf );
00060 
00065       void attr_max( int attr_max )
00066       { m_attr_max = attr_max; }
00067 
00070       int attr_max() const
00071       { return m_attr_max; } 
00072 
00077       void attr_min( int attr_min )
00078       { m_attr_min = attr_min; }
00079 
00082       int attr_min() const
00083       { return m_attr_min; } 
00084 
00089       void constr_max( int constr_max )
00090       { m_constr_max = constr_max; }
00091 
00094       int constr_max() const
00095       { return m_constr_max; } 
00096 
00101       void constr_min( int constr_min )
00102       { m_constr_min = constr_min; }
00103 
00106       int constr_min() const
00107       { return m_constr_min; } 
00108 
00113       void dist_dir( const std::string& dist_dir )
00114       { m_dist_dir = dist_dir; }
00115 
00118       const std::string& dist_dir() const
00119       { return m_dist_dir; } 
00120 
00125       void filt_max( int filt_max )
00126       { m_filt_max = filt_max; }
00127 
00130       int filt_max() const
00131       { return m_filt_max; } 
00132 
00137       void filt_min( int filt_min )
00138       { m_filt_min = filt_min; }
00139 
00142       int filt_min() const
00143       { return m_filt_min; } 
00144 
00147       int main( const std::string& prog, const std::vector<std::string>& args )
00148         throw ( std::exception );
00149 
00154       void p_cmd( const std::string& p_cmd )
00155       { m_p_cmd = p_cmd; }
00156 
00159       const std::string& p_cmd() const
00160       { return m_p_cmd; } 
00161 
00166       void reuse_types( bool reuse_types )
00167       { m_reuse_types = reuse_types; }
00168 
00171       bool reuse_types() const
00172       { return m_reuse_types; } 
00173 
00178       void s_cmd( const std::string& s_cmd )
00179       { m_s_cmd = s_cmd; }
00180 
00183       const std::string& s_cmd() const
00184       { return m_s_cmd; } 
00185 
00190       void seed( long seed )
00191       { m_seed = seed; }
00192 
00195       long seed() const
00196       { return m_seed; }
00197 
00202       void sim_length_min( int sim_length_min )
00203       { m_sim_length_min = sim_length_min; }
00204 
00207       int sim_length_min() const
00208       { return m_sim_length_min; } 
00209 
00214       void topo_file( const std::string& topo_file )
00215       { m_topo_file = topo_file; }
00216 
00219       const std::string& topo_file() const
00220       { return m_topo_file; }
00221 
00225       void ttu_sec( double ttu_sec )
00226       { m_ttu_sec = ttu_sec; }
00227 
00230       double ttu_sec() const
00231       { return m_ttu_sec; } 
00232 
00235       void wtu_sec( double wtu_sec )
00236       { m_wtu_sec = wtu_sec; }
00237 
00240       double wtu_sec() const
00241       { return m_wtu_sec; } 
00242 
00243     private:
00244       std::ostream & output_attr( std::ostream& out, 
00245                                           const std::string& x, 
00246                                      const std::string& o, 
00247                                      const std::string& v)
00248         {
00249           return out << x << ' ' << o << ' ' << '"' << v << '"';
00250         }
00251 
00252       template<class T>
00253         std::ostream & output_attr(std::ostream & out, 
00254                                            const std::string & x, 
00255                                            const std::string & o, 
00256                                            T v )
00257         {
00258           return out << x << ' ' << o << ' ' << v;
00259         }
00260       
00261       void parse_args( const std::vector<std::string>& args ) throw ( argument_exception );
00262 
00263       void print_usage( const char* error = NULL );
00264 
00265       unsigned int                              m_attr_max;
00266       unsigned int                              m_attr_min;
00267       unsigned int                              m_constr_max;
00268       unsigned int                              m_constr_min;
00269       std::string                               m_dist_dir;
00270       unsigned int                              m_filt_max;
00271       unsigned int                              m_filt_min;
00272       std::vector<WorkloadNodeProcessFactory*>  m_npfs;
00273       std::ostream&                             m_out;
00274       std::string                               m_p_cmd;
00275       bool                                      m_reuse_types;
00276       std::string                               m_s_cmd;
00277       long                                      m_seed;
00278       unsigned int                              m_sim_length_min;
00279       std::string                               m_topo_file;
00280       double                                    m_ttu_sec;
00281       double                                    m_wtu_sec;
00282     };
00283 };
00284 #endif