cdgClass::cdgClass(size_t lineNumber): cdgScope("class", lineNumber) { CMN_ASSERT(this->AddField("name", "", true, "name of the generated C++ class")); CMN_ASSERT(this->AddField("attribute", "", false, "string placed between 'class' and the class name (e.g. CISST_EXPORT)")); cdgField * field; field = this->AddField("ctor-all-members", "false", false, "adds a constructor requiring an initial value for each member"); CMN_ASSERT(field); field->AddPossibleValue("true"); field->AddPossibleValue("false"); field = this->AddField("virtual-dtor", "false", false, "make the destructor virtual"); CMN_ASSERT(field); field->AddPossibleValue("true"); field->AddPossibleValue("false"); field = this->AddField("generate-human-readable", "true", false, "generate the code for std::string _type.HumanReadable(void), set this to false to provide own implementation"); CMN_ASSERT(field); field->AddPossibleValue("true"); field->AddPossibleValue("false"); CMN_ASSERT(this->AddField("namespace", "", false, "namespace for the class")); field = this->AddField("mts-proxy", "true", false, "generate the code to create a cisstMultiTask proxy, set this to false to avoid proxy generation or \"declaration-only\" to manually instantiate the proxy in a different source file (.cpp)"); CMN_ASSERT(field); field->AddPossibleValue("true"); field->AddPossibleValue("declaration-only"); field->AddPossibleValue("false"); this->AddKnownScope(*this); cdgBaseClass newBaseClass(0); this->AddSubScope(newBaseClass); cdgTypedef newTypedef(0); this->AddSubScope(newTypedef); cdgMember newMember(0); this->AddSubScope(newMember); cdgEnum newEnum(0); this->AddSubScope(newEnum); cdgInline newInline(0, cdgInline::CDG_INLINE_HEADER); this->AddSubScope(newInline); cdgInline newCode(0, cdgInline::CDG_INLINE_CODE); this->AddSubScope(newCode); }
//------------------------------------------------------------------------------------------------- Enum& EnumManager::addClass(const std::string& name, const std::string& id) { const IdIndex& ids = m_enums.get<Id>(); const NameIndex& names = m_enums.get<Name>(); // First make sure that the enum doesn't already exist if ((ids.find(id) != ids.end()) || (names.find(name) != names.end())) CAMP_ERROR(EnumAlreadyCreated(name, id)); // Create the new class boost::shared_ptr<Enum> newEnum(new Enum(name)); // Insert it into the table EnumInfo info; info.id = id; info.name = name; info.enumPtr = newEnum; m_enums.insert(info); // Notify observers notifyEnumAdded(*newEnum); return *newEnum; }