#ifndef AGDDSOLIDPROPERTIESHH #define AGDDSOLIDPROPERTIESHH #include #include "agddAttribute.hh" #include "agddMaterial.hh" #include "ExpatInterface/Element.h" namespace agdd { class SolidProperties { private: bool _materialWasSet; string _materialName; Material * _materialPtr; Attribute _materialAtt; // InnerStruct * _innerStruct; // example only public: explicit SolidProperties() : _materialWasSet(false), _materialPtr(0), _materialAtt("material", Attribute::required) //,_innerStruct(0) // example only { }; public: void setMaterial(const std::string & name) { cerr << "WARNING. You are supplying me with the NAME of " << "a material (possibly beacuse the material is defined " << "elsewhere) rather than a REFERENCE to a material. " << "This means that I have no way of checking the " << "validity of this reference." << endl; assert(name!=static_cast("")); _materialAtt.setValue(name); _materialWasSet=true; _materialName=name; }; void setMaterial(Material * mat) { assert(mat); _materialPtr = mat; _materialWasSet=true; _materialName=mat->getName(); }; const string getMaterialName() { if (_materialWasSet) { return _materialName; } else { // material must have a default return _materialAtt.getDefaultValue(); }; }; void doSolidPropertiesThingsToThisElement(xml::Element * elt) { cout << "Adding solid properties ... " << endl; assert(elt); if (_materialPtr) { // we point to a true material elt->addAttribute("material", _materialPtr->getName()); } else { // We have to use an externally defined material. _materialAtt.addAttributeTo(elt); } //innerstruct things might come here later cout << "done." << endl; }; }; } #endif