1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
// -*- C++ -*-
//
// InterfaceBase.cc is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
//
// This is the implementation of the non-inlined, non-templated member
// functions of the InterfaceBase class.
//
#include "InterfaceBase.h"
#include "InterfacedBase.h"
#include "ThePEG/Repository/BaseRepository.h"
namespace ThePEG {
InterfaceBase::InterfaceBase(string newName,
string newDescription,
string newClassName,
const type_info & newTypeInfo, bool depSafe,
bool readonly)
: Named(newName), theDescription(newDescription),
theClassName(newClassName), theRank(-1.0), hasDefault(true),
isDependencySafe(depSafe), isReadOnly(readonly) {
BaseRepository::Register(*this, newTypeInfo);
}
string InterfaceBase::tag(int pos) const {
if ( pos == -1 ) return name();
ostringstream os;
os << name() << "[" << pos << "]";
return os.str();
}
bool InterfaceBase::notDefault(InterfacedBase & ib) const {
return exec(ib, "notdef", "") != "" ;
}
map<string,string> & InterfaceBase::objectDefaults(InterfacedBase & ib) const {
return ib.objectDefaults;
}
string InterfaceBase::fullDescription(const InterfacedBase &) const {
return type() + '\n' + name() + '\n' + description() +
( readOnly()? "\n-*-readonly-*-\n": "\n-*-mutable-*-\n" );
}
void InterfaceBase::doxygenDescription(ostream & os) const {
os << "\n<hr><b>Name: <a name=\"" << name() << "\"><code>"
<< name() << "</code></a></b><br>\n"
<< "<b>Type:</b> " << doxygenType();
if ( readOnly() ) os << " (read-only)";
os << " <br>\n"
<< "\\par Description:\n"
<< description() << "<br>\n";
}
bool InterfaceBase::NoReadOnly = false;
InterExClass::InterExClass(const InterfaceBase & i, const InterfacedBase & o) {
theMessage << "Could not access the interface \"" << i.name()
<< "\" of the object \"" << o.name() << "\" because the object "
<< "is not of the required class (" << i.className() << ").";
severity(setuperror);
}
InterExSetup::InterExSetup(const InterfaceBase & i, const InterfacedBase & o) {
theMessage << "Could not access the interface \"" << i.name()
<< "\" for the object \"" << o.name()
<< "\" since no get/set member function or variable was found.";
severity(setuperror);
}
InterExUnknown::InterExUnknown(const InterfaceBase & i,
const InterfacedBase & o) {
theMessage << "Could not perform action on the interface \""
<< i.name() << "\" for the object \"" << o.name()
<< "\" because the requested action was not recognized";
severity(setuperror);
}
InterExReadOnly::InterExReadOnly(const InterfaceBase & i,
const InterfacedBase & o) {
theMessage << "Could not perform action on the interface \""
<< i.name() << "\" for the object \"" << o.name()
<< "\" because this interface is read-only.";
severity(setuperror);
}
InterExNoNull::InterExNoNull(const InterfaceBase & i,
const InterfacedBase & o) {
theMessage << "Could not set reference \""
<< i.name() << "\" for the object \"" << o.name()
<< "\" to <Null> because null pointers are explicitly "
<< "disallowed.";
severity(setuperror);
}
RefInterfaceBase::
RefInterfaceBase(string newName, string newDescription, string newClassName,
const type_info & newTypeInfo, string newRefClassName,
const type_info & newRefTypeInfo, bool depSafe,
bool readonly, bool norebind, bool nullable, bool defnull)
: InterfaceBase(newName, newDescription, newClassName, newTypeInfo, depSafe,
readonly), theRefClassName(newRefClassName),
theRefTypeInfo(newRefTypeInfo), dontRebind(norebind),
isNullable(nullable), theDefaultIfNull(defnull) {
hasDefault = false;
}
}
|