NCBI C++ ToolKit
command_processor.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: command_processor.hpp 33815 2007-05-04 17:18:18Z kazimird $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors: Paul Thiessen
27 *
28 * File Description:
29 * module to process external commands (e.g. from file messenger)
30 *
31 * ===========================================================================
32 */
33 
34 #ifndef COMMAND_PROCESSOR__HPP
35 #define COMMAND_PROCESSOR__HPP
36 
37 #include <corelib/ncbistd.hpp>
38 
39 #include <string>
40 
41 #include "file_messaging.hpp"
42 
43 
44 BEGIN_SCOPE(Cn3D)
45 
46 // utility macros for setting up command processing functions
47 
48 // data in and out
49 #define DECLARE_PARAMS \
50  const std::string& command, const std::string& dataIn, \
51  ncbi::MessageResponder::ReplyStatus *status, std::string *dataOut
52 
53 #define PASS_PARAMS command, dataIn, status, dataOut
54 
55 // implementation of functions to handle commands
56 #define DECLARE_COMMAND_FUNCTION(name) \
57  void DoCommand_##name ( DECLARE_PARAMS )
58 
59 #define IMPLEMENT_COMMAND_FUNCTION(name) \
60  void CommandProcessor::DoCommand_##name ( DECLARE_PARAMS )
61 
62 #define PROCESS_IF_COMMAND_IS(name) \
63  do { \
64  if (command == #name ) { \
65  DoCommand_##name ( PASS_PARAMS ); \
66  return; \
67  } \
68  } while (0)
69 
70 #define ADD_REPLY_ERROR(msg) \
71  do { \
72  *status = MessageResponder::REPLY_ERROR; \
73  *dataOut += msg; \
74  *dataOut += '\n'; \
75  } while (0)
76 
77 
78 class StructureWindow;
79 
81 {
82 private:
84 
85 public:
88 
89  // main command interface: pass in a command, and get an immediate reply
91 
92  // command functions
93  DECLARE_COMMAND_FUNCTION(Highlight);
96 };
97 
98 END_SCOPE(Cn3D)
99 
100 #endif // COMMAND_PROCESSOR__HPP
StructureWindow * structureWindow
void ProcessCommand(const std::string &command, const std::string &dataIn, ncbi::MessageResponder::ReplyStatus *status, std::string *dataOut)
CommandProcessor(StructureWindow *sw)
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
static string LoadFile(CNcbiIstream &str)
static CStopWatch sw
#define DECLARE_PARAMS
#define DECLARE_COMMAND_FUNCTION(name)
Modified on Wed Feb 21 09:57:34 2024 by modify_doxy.py rev. 669887