OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Show.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: Show.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: Show
10 // The class for OPAL SHOW commands.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:37 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "BasicActions/Show.h"
21 #include "AbstractObjects/Object.h"
22 #include "Attributes/Attributes.h"
23 #include <iostream>
24 
25 
26 // Class Show
27 // ------------------------------------------------------------------------
28 
30  Action(1, "SHOW",
31  "The \"SHOW\" statement displays all object names matching a "
32  " regular expression.") {
34  ("PATTERN", "Regular expression for pattern match");
35 
37 }
38 
39 
40 Show::Show(const std::string &name, Show *parent):
41  Action(name, parent)
42 {}
43 
44 
46 {}
47 
48 
49 Show *Show::clone(const std::string &name) {
50  return new Show(name, this);
51 }
52 
53 
54 void Show::execute() {
55  if(itsAttr[0]) {
56  std::string pattern = Attributes::getString(itsAttr[0]);
57  OpalData::getInstance()->printNames(std::cerr, pattern);
58  } else {
59  printHelp(std::cerr);
60  }
61 }
62 
63 
64 void Show::parse(Statement &statement) {
65  parseShortcut(statement);
66 }
virtual void parseShortcut(Statement &)
Parser for single-attribute commands.
Definition: Object.cpp:132
The base class for all OPAL actions.
Definition: Action.h:30
The SHOW command.
Definition: Show.h:28
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
static OpalData * getInstance()
Definition: OpalData.cpp:209
Show()
Exemplar constructor.
Definition: Show.cpp:29
virtual ~Show()
Definition: Show.cpp:45
virtual Show * clone(const std::string &name)
Make clone.
Definition: Show.cpp:49
Interface for statements.
Definition: Statement.h:38
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition: Object.cpp:194
virtual void printHelp(std::ostream &) const
Print help.
Definition: Object.cpp:204
void printNames(std::ostream &stream, const std::string &pattern)
Print all objects.
Definition: OpalData.cpp:635
const std::string name
virtual void execute()
Execute the command.
Definition: Show.cpp:54
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:296
virtual void parse(Statement &)
Parse command (special for one-attribute command).
Definition: Show.cpp:64
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:307