[Mobies-commit] [commit] r3691 - in UDM/trunk: include src/UdmBase src/UdmDom
ksmyth at redhat1.isis.vanderbilt.edu
ksmyth at redhat1.isis.vanderbilt.edu
Fri Apr 29 16:06:41 CDT 2011
Author: ksmyth
Date: Fri Apr 29 16:06:41 2011
New Revision: 3691
Log:
Dont use reflection to get classpath in Dom; this method is faster
Modified:
UDM/trunk/include/UdmUtil.h
UDM/trunk/include/UmlExt.h
UDM/trunk/src/UdmBase/UmlExt.cpp
UDM/trunk/src/UdmDom/UdmDom.cpp
Modified: UDM/trunk/include/UdmUtil.h
==============================================================================
--- UDM/trunk/include/UdmUtil.h Fri Apr 29 16:02:28 2011 (r3690)
+++ UDM/trunk/include/UdmUtil.h Fri Apr 29 16:06:41 2011 (r3691)
@@ -53,6 +53,15 @@
UDM_DLL string ExtractName(const Udm::ObjectImpl *impl, const string &att_name = "name");
UDM_DLL string ExtractName(const Udm::Object &ob, const string &att_name = "name");
+ namespace {
+ std::string SimpleExtractName(const Udm::Object& o) { return UdmUtil::ExtractName(o); };
+ }
+ template <class Container>
+ std::vector<std::string> ExtractNames(const Container& c) {
+ vector<std::string> ret;
+ std::transform(c.begin(), c.end(), back_inserter(ret), std::ptr_fun(SimpleExtractName));
+ return ret;
+ }
//note: escape_char is not escaped unless it is contained in to_escape_chars
UDM_DLL string escape_chars(const string &src, const char escape_char, const string &to_escape_chars);
Modified: UDM/trunk/include/UmlExt.h
==============================================================================
--- UDM/trunk/include/UmlExt.h Fri Apr 29 16:02:28 2011 (r3690)
+++ UDM/trunk/include/UmlExt.h Fri Apr 29 16:06:41 2011 (r3691)
@@ -590,6 +590,8 @@
UDM_DLL void SetChildRole(CompositionChildRole &what, Class &what_target_class, Class &what_theo_target_class, const char *role_name, const char * orole_name);
UDM_DLL void SetParentRole(CompositionParentRole &what, Class &what_target_class, Class &what_theo_target_class, const char *role_name, const char * orole_name);
UDM_DLL void SetAssocRole(AssociationRole &what, Class &what_target_class, Class &what_theo_target_class, const char *target_name);
+
+ UDM_DLL std::string GetClassPath(Uml::Class& c, std::string separator = "::");
}
#endif//MOBIES_UMLEXT_H
Modified: UDM/trunk/src/UdmBase/UmlExt.cpp
==============================================================================
--- UDM/trunk/src/UdmBase/UmlExt.cpp Fri Apr 29 16:02:28 2011 (r3690)
+++ UDM/trunk/src/UdmBase/UmlExt.cpp Fri Apr 29 16:06:41 2011 (r3691)
@@ -1084,4 +1084,32 @@
return (ref_i != Udm::_UdmStaticData.ref_map.end());
}
+
+ UDM_DLL std::string GetClassPath(Uml::Class& c, std::string separator) {
+ std::vector<std::string> names;
+ {
+ Udm::Object o = c;
+ while (o != Udm::null) {
+ if (o.type() == Uml::Namespace::meta) {
+ names.push_back(o.__impl()->getStringAttr(Uml::Namespace::meta_name));
+ //} else if (o.type() == Uml::Diagram::meta) {
+ // names.push_back(o.__impl()->getStringAttr(Uml::Namespace::meta_name));
+ } else if (o.type() == Uml::Class::meta) {
+ names.push_back(o.__impl()->getStringAttr(Uml::Class::meta_name));
+ }
+ o = o.GetParent();
+ }
+ }
+ std::string ret = "";
+ std::vector<std::string>::reverse_iterator nameIt = names.rbegin();
+ std::vector<std::string>::reverse_iterator end = names.rend();
+ if (nameIt < end) {
+ ret += *nameIt;
+ nameIt++;
+ }
+ while (nameIt < end) {
+ ret += separator + *nameIt++;
+ }
+ return ret;
+ }
}
Modified: UDM/trunk/src/UdmDom/UdmDom.cpp
==============================================================================
--- UDM/trunk/src/UdmDom/UdmDom.cpp Fri Apr 29 16:02:28 2011 (r3690)
+++ UDM/trunk/src/UdmDom/UdmDom.cpp Fri Apr 29 16:06:41 2011 (r3691)
@@ -1621,7 +1621,7 @@
if(!aa.dom_element->isSameNode(currentparent))
{
- string my_type_name = m_type.getPath2("::", false);
+ string my_type_name = Uml::GetClassPath(m_type);
bool inserted = false;
DOMElement *insert_point = NULL;
@@ -1640,7 +1640,7 @@
break;
}
- string curr_child_name = findClass(*e).getPath2("::", false);
+ string curr_child_name = Uml::GetClassPath(findClass(*e));
if (my_type_name.compare(curr_child_name) < 0)
{
@@ -2199,7 +2199,7 @@
::Uml::CompositionChildRole role = childrole;
if(!role) {
::Uml::Composition comp = Uml::matchChildToParent(meta, m_type);
- if(!comp) throw udm_exception("Role must be specified for " + casestr);
+ if(!comp) throw udm_exception("Role must be specified for " + casestr); // OR this cannot contain an object of type meta
role = comp.childRole();
}
if(!Uml::IsDerivedFrom(m_type, Uml::theOther(role).target())) {
More information about the Mobies-commit
mailing list