Statistics
| Branch: | Revision:

root / src / cmdenv / cmdenv.h @ 2f5cc443

History | View | Annotate | Download (2.81 KB)

1
//==========================================================================
2
//  CMDENV.H - part of
3
//                     OMNeT++/OMNEST
4
//            Discrete System Simulation in C++
5
//
6
//  Author: Andras Varga
7
//
8
//==========================================================================
9

    
10
/*--------------------------------------------------------------*
11
  Copyright (C) 1992-2008 Andras Varga
12
  Copyright (C) 2006-2008 OpenSim Ltd.
13

14
  This file is distributed WITHOUT ANY WARRANTY. See the file
15
  `license' for details on this and other legal matters.
16
*--------------------------------------------------------------*/
17

    
18
#ifndef __CMDENV_H
19
#define __CMDENV_H
20

    
21
#include "csimulation.h"
22
#include "envirbase.h"
23

    
24
NAMESPACE_BEGIN
25

    
26
class Speedometer;
27

    
28
/**
29
 * Command line user interface.
30
 */
31
class CMDENV_API Cmdenv : public EnvirBase
32
{
33
   protected:
34
     // new simulation options:
35
     opp_string opt_configname;
36
     opp_string opt_runstoexec;
37
     size_t opt_extrastack;
38
     opp_string opt_outputfile;
39

    
40
     bool opt_expressmode;
41
     bool opt_interactive;
42
     bool opt_autoflush; // all modes
43
     bool opt_modulemsgs;  // if normal mode
44
     bool opt_eventbanners; // if normal mode
45
     bool opt_eventbanner_details; // if normal mode
46
     bool opt_messagetrace; // if normal mode
47
     long opt_status_frequency_ms; // if express mode
48
     bool opt_perfdisplay; // if express mode
49

    
50
     // set to true on SIGINT/SIGTERM signals
51
     static bool sigint_received;
52

    
53
     // stream to write output to
54
     FILE *fout;
55

    
56
   protected:
57
     virtual void sputn(const char *s, int n);
58
     virtual void putsmsg(const char *s);
59
     virtual bool askyesno(const char *question);
60
     virtual void printEventBanner(cSimpleModule *mod);
61
     virtual void doStatusUpdate(Speedometer& speedometer);
62

    
63
   public:
64
     Cmdenv();
65
     virtual ~Cmdenv();
66

    
67
     // redefined virtual funcs:
68
     virtual void componentInitBegin(cComponent *component, int stage);
69
     virtual void moduleCreated(cModule *newmodule);
70
     virtual void messageSent_OBSOLETE(cMessage *msg, cGate *directToGate);
71
     virtual void simulationEvent(cMessage *msg);
72
     virtual void simulationEventEnd(double complexity);
73
     virtual bool isGUI() const {return false;}
74
     virtual cEnvir& flush();
75
     virtual std::string gets(const char *prompt, const char *defaultReply);
76
     virtual bool idle();
77
     virtual unsigned getExtraStackForEnvir() const;
78

    
79
   protected:
80
     virtual void run();
81
     virtual void printUISpecificHelp();
82

    
83
     virtual void readOptions();
84
     virtual void readPerRunOptions();
85
     virtual void askParameter(cPar *par, bool unassigned);
86

    
87
     // new functions:
88
     void help();
89
     void simulate();
90
     const char *progressPercentage();
91

    
92
     void installSignalHandler();
93
     void deinstallSignalHandler();
94
     static void signalHandler(int signum);
95
};
96

    
97
NAMESPACE_END
98

    
99

    
100
#endif
101