CmdBase.cpp
5.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//**************************************************************************************************
// CmdBase.cpp *
// ------------- *
// Started : 2006-08-31 *
// Last Update : 2015-03-04 *
// Copyright : (C) 2006-2016 MSWaters *
//**************************************************************************************************
//**************************************************************************************************
// *
// This program is free software; you can redistribute it and/or modify it under the *
// terms of the GNU General Public License as published by the Free Software Foundation; *
// either version 3 of the License, or (at your option) any later version. *
// *
//**************************************************************************************************
#include "CmdBase.hpp"
//**************************************************************************************************
// Constructor.
CmdBase::CmdBase( void ) : wxString( wxT("") )
{
bSetDefaults( );
}
//**************************************************************************************************
// Destructor.
CmdBase::~CmdBase( )
{
}
//**************************************************************************************************
// Set the object attributes to their default values.
//
// Return Values :
// true - Success
// false - Failure
bool CmdBase::bSetDefaults( void )
{
wxString::Empty( );
m_osErrMsg = wxT("Invalid");
m_eSimEng = eSIMR_NONE;
m_eCmdType = eCMD_NONE;
return( true );
}
//**************************************************************************************************
// Check that the object attributes are valid.
//
// Return Values :
// true - Success
// false - Failure
bool CmdBase::bValidate( void )
{
m_osErrMsg.Empty( );
if( IsEmpty( ) )
SetErrMsg( wxT("The command is empty") );
if( m_eSimEng == eSIMR_NONE )
SetErrMsg( wxT("The command has no simulator engine") );
if( m_eCmdType == eCMD_NONE )
SetErrMsg( wxT("The command has no type") );
return( bIsValid( ) );
}
//**************************************************************************************************
// Set the command based on a complete command string.
//
// Argument List :
// rosCmd - A reference to a wxString object
//
// Return Values :
// true - Success
// false - Failure
bool CmdBase::bSetString( wxString & ros )
{
bSetDefaults( );
assign( ros );
bParse( );
return( true );
}
//**************************************************************************************************
// Copy the contents of another CmdBase object.
//
// Argument List :
// roCmd - A reference to a CmdBase object
//
// Return Values :
// A reference to this object
CmdBase & CmdBase::operator = ( const CmdBase & roCmd )
{
// Copy the command string
(wxString &) *this = (wxString &) roCmd;
// Once these attributes are set they won't change
if( m_eSimEng == eSIMR_NONE ) m_eSimEng = roCmd.m_eSimEng;
if( m_eCmdType == eCMD_NONE ) m_eCmdType = roCmd.m_eCmdType;
// Copy the any error message
m_osErrMsg = roCmd.m_osErrMsg;
return( *this );
}
//**************************************************************************************************
// Print the object attributes.
//
// Argument List :
// rosPrefix - A prefix to every line displayed (usually just spaces)
void CmdBase::Print( const wxString & rosPrefix )
{
std::cout << rosPrefix .mb_str( ) << "wxString : \"" << this ->mb_str( ) << "\"\n";
std::cout << rosPrefix .mb_str( ) << "m_osErrMsg : \"" << m_osErrMsg.mb_str( ) << "\"\n";
std::cout << rosPrefix .mb_str( ) << "m_eSimEng : ";
switch( m_eSimEng )
{
case eSIMR_GNUCAP : std::cout << "eSIMR_GNUCAP"; break;
case eSIMR_NGSPICE : std::cout << "eSIMR_NGSPICE"; break;
case eSIMR_NONE : std::cout << "eSIMR_NONE"; break;
default : std::cout << "Invalid"; break;
}
std::cout << '\n';
std::cout << rosPrefix .mb_str( ) << "m_eCmdType : ";
switch( m_eCmdType )
{
case eCMD_OP : std::cout << "eANA_OP"; break; // Operating point analysis
case eCMD_DC : std::cout << "eANA_DC"; break; // DC analysis
case eCMD_AC : std::cout << "eANA_AC"; break; // AC analysis
case eCMD_TR : std::cout << "eANA_TR"; break; // Transient analysis
case eCMD_FO : std::cout << "eANA_FO"; break; // Fourier analysis
case eCMD_DI : std::cout << "eANA_DI"; break; // Distortion analysis
case eCMD_NO : std::cout << "eANA_NO"; break; // Noise analysis
case eCMD_PZ : std::cout << "eANA_PZ"; break; // Pole-zero analysis
case eCMD_SE : std::cout << "eANA_SE"; break; // Sensitivity analysis
case eCMD_TF : std::cout << "eANA_TF"; break; // Transfer function analysis
case eCMD_OPT : std::cout << "eCMD_OPT"; break; // Options command
case eCMD_IC : std::cout << "eCMD_IC"; break; // Initial conditions command
case eCMD_PR : std::cout << "eCMD_PR"; break; // Print command
case eCMD_GEN : std::cout << "eCMD_GEN"; break; // Generator command
case eCMD_NONE : std::cout << "eANA_NONE"; break; // Command type not set
default : std::cout << "Invalid"; break; // Command type is invalid
}
std::cout << '\n';
}
//**************************************************************************************************