66 if(i->getName() == name)
return &(*i);
73 for(std::vector<Attribute>::const_iterator i =
itsAttr.begin();
75 if(i->getName() == name)
return &(*i);
84 throw ParseError(
"Object::makeTemplate()",
"Object \"" + name +
85 "\" cannot be used to define a macro.");
91 "\" cannot be called as a macro.");
105 attr->parseComponent(stat,
true, index);
107 attr->parseComponent(stat,
false, index);
110 "Delimiter \"=\" or \":=\" expected.");
113 attr->parse(stat,
true);
115 attr->parse(stat,
false);
121 "\" has no attribute \"" + name +
"\".");
133 if(stat.
word(name)) {
136 attr->parse(stat, eval);
140 "\" has no attribute \"" + name +
"\".");
144 attr->parse(stat,
false);
148 "\" has no attribute \"" + name +
"\".");
162 if(parent != 0 && ! parent->
getOpalName().empty()) {
168 int pos = head.length();
170 for(std::vector<Attribute>::const_iterator i =
itsAttr.begin();
172 if(*i) i->print(pos);
194 for (
unsigned int i = 0; i <
end; ++ i) {
205 size_t maxNameLength = 16;
206 size_t maxTypeLength = 16;
207 std::vector<Attribute>::const_iterator it;
209 std::string name = it->getName();
210 maxNameLength =
std::max(maxNameLength, name.length() + 1);
211 std::string type = it->getType();
212 maxTypeLength =
std::max(maxTypeLength, type.length() + 1);
216 std::string type = it->getType();
217 std::string name = it->getName();
218 std::istringstream help(it->getHelp());
219 std::vector<std::string> words;
220 std::copy(std::istream_iterator<std::string>(help),
221 std::istream_iterator<std::string>(),
222 std::back_inserter(words));
223 unsigned int columnWidth = 40;
224 if (maxNameLength + maxTypeLength < 40u) {
225 columnWidth = 80 - maxNameLength - maxTypeLength;
228 auto wordsIt = words.begin();
229 auto wordsEnd = words.end();
230 while (wordsIt != wordsEnd) {
231 *
gmsg <<
'\t' << type << std::string(maxTypeLength - type.length(),
' ');
232 *
gmsg << name << std::string(maxNameLength - name.length(),
' ');
233 unsigned int totalLength = 0;
235 totalLength += wordsIt->length();
236 *
gmsg << *wordsIt <<
" ";
238 }
while (wordsIt != wordsEnd && totalLength + wordsIt->length() < columnWidth);
239 if (wordsIt != wordsEnd) {
247 if(it->isReadOnly()) *
gmsg <<
" (read only)";
302 const Object *base =
this;
319 const Object *
object =
this;
321 while(
object != 0 &&
object != classObject) {
355 RCObject(), itsAttr(size), itsParent(0),
356 itsName(name), itsHelp(help), occurrence(0), sharedFlag(false) {
367 RCObject(), itsAttr(parent->itsAttr), itsParent(parent),
368 itsName(name), itsHelp(parent->itsHelp), occurrence(0), sharedFlag(false) {
PartBunch< T, Dim >::ConstIterator end(PartBunch< T, Dim > const &bunch)
std::ostream & operator<<(std::ostream &os, const Object &object)
Inform & endl(Inform &inf)
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.
std::string::iterator iterator
KOKKOS_INLINE_FUNCTION Vector< T, Dim > max(const Vector< T, Dim > &a, const Vector< T, Dim > &b)
A representation of an Object attribute.
static void addAttributeOwner(const std::string &owner, const OwnerType &type, const std::string &name)
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.
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.
std::set< Invalidator * > references
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.
Abstract base class for reference counted objects.
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.