kandy

atcommand.h
1 /*
2  This file is part of Kandy.
3 
4  Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  As a special exception, permission is given to link this program
21  with any edition of TQt, and distribute the resulting executable,
22  without including the source code for TQt in the source distribution.
23 */
24 #ifndef ATCOMMAND_H
25 #define ATCOMMAND_H
26 
27 #include <tqstring.h>
28 #include <tqstringlist.h>
29 #include <tqptrlist.h>
30 
31 class ATParameter {
32  public:
33  ATParameter();
34  ATParameter(const TQString &value,const TQString &name="",
35  bool userInput=false);
36 
37  void setName(const TQString &name) { mName = name; }
38  TQString name() const { return mName; }
39  void setValue(const TQString &value) { mValue = value; }
40  TQString value() const { return mValue; }
41  void setUserInput(bool userInput) { mUserInput = userInput; }
42  bool userInput() const { return mUserInput; }
43 
44  private:
45  TQString mName;
46  TQString mValue;
47  bool mUserInput;
48 };
49 
53 // TODO: emit a signal, when the command was executed.
54 class ATCommand {
55  public:
56  ATCommand();
57  ATCommand(const TQString &cmdString);
58  ATCommand(const TQString &cmdName,const TQString &cmdString,
59  bool hexOutput=false);
60  virtual ~ATCommand();
61 
62  void setCmdName(const TQString &);
63  TQString cmdName();
64 
65  void setCmdString(const TQString &);
66  TQString cmdString();
67 
68  TQString cmd();
69 
70  TQString id();
71 
72  void setHexOutput(bool);
73  bool hexOutput();
74 
75  TQString processOutput(const TQString &);
76  TQString processOutput();
77 
78  void setResultString(const TQString &);
79  TQString resultString();
80  TQString resultField(int index);
81  TQPtrList<TQStringList> *resultFields();
82 
83  void addParameter(ATParameter *);
84  void clearParameters();
85  TQPtrList<ATParameter> parameters();
86 
87  void setParameter(int index,const TQString &value);
88  void setParameter(int index,int value);
89 
90  void setAutoDelete(bool autoDelete) { mAutoDelete = autoDelete; }
91  bool autoDelete() { return mAutoDelete; }
92 
93  private:
94  void construct();
95  void setResultFields(TQString fieldsString);
96  void extractParameters();
97 
98  TQString mCmdName;
99  TQString mCmdString;
100  TQString mId;
101  bool mHexOutput;
102 
103  TQString mResultString;
104  TQPtrList<TQStringList> mResultFieldsList;
105 
106  TQPtrList<ATParameter> mParameters;
107 
108  bool mAutoDelete;
109 };
110 
111 #endif
This class provides an abstraction of an AT command.
Definition: atcommand.h:54