57 for (std::vector<Attribute>::iterator i =
itsAttr.begin(); i !=
itsAttr.end(); ++i) {
58 if (i->getName() == name)
return &(*i);
64 for (std::vector<Attribute>::const_iterator i =
itsAttr.begin(); i !=
itsAttr.end(); ++i) {
65 if (i->getName() == name)
return &(*i);
73 "Object::makeTemplate()",
"Object \"" + name +
"\" cannot be used to define a macro.");
78 "Object::makeInstance()",
79 "Object \"" +
getOpalName() +
"\" cannot be called as a macro.");
92 attr->parseComponent(stat,
true, index);
94 attr->parseComponent(stat,
false, index);
96 throw ParseError(
"Object::parse()",
"Delimiter \"=\" or \":=\" expected.");
99 attr->parse(stat,
true);
101 attr->parse(stat,
false);
108 "Object \"" +
getOpalName() +
"\" has no attribute \"" + name +
"\".");
119 if (stat.
word(name)) {
122 attr->parse(stat, eval);
126 "Object::parseShortcut()",
127 "Object \"" +
getOpalName() +
"\" has no attribute \"" + name +
"\".");
131 attr->parse(stat,
false);
135 "Object::parseShortcut()",
136 "Object \"" +
getOpalName() +
"\" has no attribute \"" + name +
"\".");
149 if (parent != 0 && !parent->
getOpalName().empty()) {
155 int pos = head.length();
157 for (std::vector<Attribute>::const_iterator i =
itsAttr.begin(); i !=
itsAttr.end(); ++i) {
158 if (*i) i->print(pos);
172 const unsigned int end =
itsAttr.size();
174 for (
unsigned int i = 0; i < end; ++i) {
183 *
gmsg <<
"Attributes:" << endl;
185 size_t maxNameLength = 16;
186 size_t maxTypeLength = 16;
187 std::vector<Attribute>::const_iterator it;
189 std::string name = it->getName();
190 maxNameLength = std::max(maxNameLength, name.length() + 1);
191 std::string type = it->getType();
192 maxTypeLength = std::max(maxTypeLength, type.length() + 1);
196 std::string type = it->getType();
197 std::string name = it->getName();
198 std::istringstream help(it->getHelp());
199 std::vector<std::string> words;
201 std::istream_iterator<std::string>(help), std::istream_iterator<std::string>(),
202 std::back_inserter(words));
203 unsigned int columnWidth = 40;
204 if (maxNameLength + maxTypeLength < 40u) {
205 columnWidth = 80 - maxNameLength - maxTypeLength;
208 auto wordsIt = words.begin();
209 auto wordsEnd = words.end();
210 while (wordsIt != wordsEnd) {
211 *
gmsg <<
'\t' << type << std::string(maxTypeLength - type.length(),
' ');
212 *
gmsg << name << std::string(maxNameLength - name.length(),
' ');
213 unsigned int totalLength = 0;
215 totalLength += wordsIt->length();
216 *
gmsg << *wordsIt <<
" ";
218 }
while (wordsIt != wordsEnd && totalLength + wordsIt->length() < columnWidth);
219 if (wordsIt != wordsEnd) {
227 if (it->isReadOnly()) *
gmsg <<
" (read only)";
261 const Object* base =
this;
272 const Object*
object =
this;
274 while (
object != 0 &&
object != classObject) {
292 : itsAttr(size), itsParent(0), itsName(name), itsHelp(help), occurrence(0), sharedFlag(false) {
302 : itsAttr(parent->itsAttr),
305 itsHelp(parent->itsHelp),
std::ostream & operator<<(std::ostream &os, const Object &object)
static void addAttributeOwner(const std::string &owner, const OwnerType &type, const std::string &name)
A representation of an Object attribute.
Abstract base class for references which must be invalidated when an.
The base class for all OPAL objects.
void setParent(Object *)
Set parent object.
virtual void parseShortcut(Statement &, bool eval=true)
Parser for single-attribute commands.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
virtual bool canReplaceBy(Object *object)
Test if replacement is allowed.
virtual Object * makeTemplate(const std::string &, TokenStream &, Statement &)
Macro handler function.
bool isFlagged() const
True, if [b]this[/b] is flagged by setFlag(true).
bool isDirty() const
True, if the [b]modified[/b] flag is set.
Object * getParent() const
Return parent pointer.
virtual void update()
Update this object.
const Object * getBaseObject() const
Return the object's base type object.
virtual Object * makeInstance(const std::string &name, Statement &, const Parser *)
Macro handler function.
const std::string & getOpalName() const
Return object name.
virtual void print(std::ostream &) const
Print the object.
std::set< Invalidator * > references
int occurrenceCount()
Return the occurrence counter.
void copyAttributes(const Object &)
Copy attributes from another object.
void setDirty(bool)
Set/reset the [b]modified[/b] flag.
int increment()
Increment and return the occurrence counter.
virtual void setShared(bool)
Set/reset shared flag.
virtual Attribute * findAttribute(const std::string &name)
Find an attribute by name.
void registerReference(Invalidator *a)
Register a reference to this object.
virtual void execute()
Execute the command.
void clear()
Clear the occurrence counter.
void setOpalName(const std::string &name)
Set object name.
virtual void printHelp(std::ostream &) const
Print help.
std::vector< Attribute > itsAttr
The object attributes.
bool isTreeMember(const Object *subTree) const
Test for tree membership.
virtual void parse(Statement &)
Parse the object.
bool isBuiltin() const
True, if [b]this[/b] is a built-in object.
virtual bool isShared() const
Shared flag.
void setFlag(bool)
Flag/unflag this object, e. g. to control output of objects for.
bool builtin
Built-in flag.
virtual void replace(Object *oldObject, Object *newObject)
Replace references.
void unregisterReference(Invalidator *a)
Unegister a reference to this object.
Interface for abstract language parser.
Interface for statements.
void restore()
Return to marked position.
void mark()
Mark position in command.
bool word(std::string &value)
Return word value.
bool delimiter(char c)
Test for delimiter.
Abstract interface for a stream of input tokens.
std::string parseString(Statement &, const char msg[])
Parse string value.
void parseDelimiter(Statement &stat, char delim)
Test for one-character delimiter.
double parseRealConst(Statement &)
Parse real constant.