[Mobies-commit] [commit] r4403 - in UDM/trunk: include src/UdmGme
ksmyth at svn.isis.vanderbilt.edu
ksmyth at svn.isis.vanderbilt.edu
Mon Nov 20 11:12:31 CST 2017
Author: ksmyth
Date: Mon Nov 20 11:12:31 2017
New Revision: 4403
Log:
Fix up casts: use static_cast where appropriate
Modified:
UDM/trunk/include/ErrHand.h
UDM/trunk/include/UdmBase.h
UDM/trunk/src/UdmGme/UdmGme.cpp
Modified: UDM/trunk/include/ErrHand.h
==============================================================================
--- UDM/trunk/include/ErrHand.h Mon Nov 20 11:12:28 2017 (r4402)
+++ UDM/trunk/include/ErrHand.h Mon Nov 20 11:12:31 2017 (r4403)
@@ -151,7 +151,7 @@
const udm_exception &operator =(const udm_exception &a) throw()
{
#ifdef _MSC_VER
- *((::std::exception*)this) = a;
+ *(static_cast<::std::exception*>(this)) = a;
#endif
description = a.description; stacktrace = get_stacktrace(); _init(); return *this;
}
Modified: UDM/trunk/include/UdmBase.h
==============================================================================
--- UDM/trunk/include/UdmBase.h Mon Nov 20 11:12:28 2017 (r4402)
+++ UDM/trunk/include/UdmBase.h Mon Nov 20 11:12:31 2017 (r4403)
@@ -4217,7 +4217,10 @@
#endif
-inline UDM_DLL std::ostream & operator<< (std::ostream &o, Udm::StringAttr c) { o << (std::string)c; return o; };
+inline UDM_DLL std::ostream & operator<< (std::ostream &o, Udm::StringAttr c) {
+ o << static_cast<std::string>(c);
+ return o;
+}
//defines for using backends
#ifdef _WIN32
Modified: UDM/trunk/src/UdmGme/UdmGme.cpp
==============================================================================
--- UDM/trunk/src/UdmGme/UdmGme.cpp Mon Nov 20 11:12:28 2017 (r4402)
+++ UDM/trunk/src/UdmGme/UdmGme.cpp Mon Nov 20 11:12:31 2017 (r4403)
@@ -455,7 +455,7 @@
{
::Uml::Class acl = ass.assocClass();
string ret;
- if(acl) ret = PATHGET(acl);
+ if(acl) ret = getShortClassPath(acl);
else
{
ret = ass.name();
@@ -464,9 +464,9 @@
set< ::Uml::AssociationRole> roles = ass.roles();
set< ::Uml::AssociationRole>::iterator j = roles.begin();
ret = "noname_";
- ret += PATHGET((::Uml::Class)j->target());
+ ret += getShortClassPath(*j->target());
ret += "_to_";
- ret += PATHGET((::Uml::Class)(++j)->target());
+ ret += getShortClassPath(*(++j)->target());
}
}
return ret;
@@ -474,7 +474,7 @@
int CompareKindToClass(IMgaMetaFCOPtr kind, ::Uml::Class meta)
{
- return ((string)PATHGET(meta)).compare(kind->Name);
+ return getShortClassPath(meta).compare(static_cast<const char*>(kind->Name));
}
// convert a MGA rolename to the name generated by Uml::MakeRoleName:
@@ -1821,7 +1821,7 @@
if(kind)
{
- if (((::Uml::Class)role.target()) != kind)
+ if ((*role.target()) != kind)
{
if (!static_cast<GmeDataNetwork*>(const_cast<GmeObject*>(this)->__getdn())->priv.IsDerivedFrom(kind, role.target()))
throw udm_exception("GmeObject::CreateChild(): Role-Kindname mismatch");
@@ -2039,8 +2039,8 @@
if (role)
{
//the CompositionRole of the contained FCO
- string MetaRole((const char *)MGACOLL_ITER->MetaRole->Name);
- string roleWithNamespaces = (string)role.name();
+ string MetaRole(static_cast<const char *>(MGACOLL_ITER->MetaRole->Name));
+ string roleWithNamespaces = static_cast<std::string>(role.name());
if (roleWithNamespaces.length() != 0)
{
Uml::Namespace ns = static_cast<Uml::Class>(role.target()).parent_ns();
@@ -2189,7 +2189,7 @@
while (!found && d_i != descendants.end())
{
::Uml::Class descendant = *d_i++;
- found = (real_role->Name == SmartBSTR( ((string)PATHGET(descendant)).c_str() ));
+ found = (real_role->Name == SmartBSTR(PATHGET(descendant)));
}
//and it also may be one of inherited multiple chilroles,
@@ -2198,7 +2198,7 @@
while (!found && d_i != descendants.end())
{
::Uml::Class descendant = *d_i++;
- found = (real_role->Name == SmartBSTR( (PATHGET(descendant) + (string)ccr.name()).c_str() ));
+ found = (real_role->Name == SmartBSTR( (getShortClassPath(descendant) + (string)ccr.name()).c_str() ));
}
//if still not found, than the this is not contained via the requested role
@@ -2242,7 +2242,7 @@
//auto dbg2 = (string)((::Uml::Class)ccr.target()).name();
//auto dbg3 = PATHGET(kind);
- string target = ((::Uml::Class)ccr.target()).name();
+ string target = ccr.target()->name();
if (Uml::IsCrossNSComposition(ccr.parent()))
{
Uml::Namespace ns = static_cast<Uml::Class>(ccr.target()).parent_ns();
@@ -2260,17 +2260,17 @@
//empty or may be Uml::MakeShortRoleName, no one can tell.
//first we try without rolename appended, this happens more often
- mn = PATHGET(kind);
+ mn = getShortClassPath(kind);
mmodel->get_RoleByName(SmartBSTR(mn.c_str()), &rr);
if (rr == NULL)
{
- mn = PATHGET(kind) + (string)ccr.name();
+ mn = getShortClassPath(kind) + (string)ccr.name();
rr = mmodel->RoleByName[SmartBSTR(mn.c_str())];
}
}
else
{
- mn = PATHGET(kind) + (string)ccr.name();
+ mn = getShortClassPath(kind) + (string)ccr.name();
rr = mmodel->RoleByName[SmartBSTR(mn.c_str())];
}
}
@@ -2286,7 +2286,7 @@
string roleWithNamespaces = ccr.name();
if (roleWithNamespaces.empty())
{
- string kn = PATHGET(kind);
+ string kn = getShortClassPath(kind);
rr = mmodel->RoleByName[SmartBSTR(kn.c_str())];
}
else
@@ -2322,7 +2322,7 @@
throw udm_exception("Metamodel not found");
string mn = Uml::MakeShortRoleName(meta);
if(mn.empty()) {
- mn = PATHGET(::Uml::Class(meta.target()));
+ mn = getShortClassPath(*meta.target());
rr = mmodel->RoleByName[SmartBSTR(mn.c_str())];
} else {
IMgaMetaRolesPtr rrs;
@@ -2437,7 +2437,7 @@
for (set< ::Uml::CompositionChildRole>::const_iterator i = cr.begin(); i != cr.end(); i++)
if (pancs.find(::Uml::theOther(*i).target()) != pancs.end())
{
- if (MetaRole == (string)i->name())
+ if (MetaRole == static_cast<std::string>(i->name()))
{
ret = *i;
return;
@@ -2689,7 +2689,7 @@
vector<string> v;
v.push_back(path);
if (!(!val))
- v.push_back((string)val);
+ v.push_back(static_cast<std::string>(val));
else
v.push_back("");
@@ -3323,7 +3323,7 @@
::Uml::DiagramClasses meta_classes(*dia.dgr);
for (::Uml::DiagramClasses::iterator mci = meta_classes.begin(); mci != meta_classes.end(); mci++)
{
- string key = PATHGET(*mci);
+ string key = getShortClassPath(*mci);
pair<string const, const ::Uml::Class> mcc_item(key, *mci);
pair<map<string, const ::Uml::Class>::iterator, bool> ins_res = meta_class_cache.insert(mcc_item);
if (!ins_res.second)
@@ -3362,7 +3362,7 @@
// at either end (from which navigation is available) we expect to find a
// set or a reference with
// relation names matching the end names
- IMgaMetaFCOPtr MetaObjLookup(IMgaMetaModel *metam, SmartBSTR &name) {
+ IMgaMetaFCOPtr MetaObjLookup(IMgaMetaModel *metam, const SmartBSTR &name) {
IMgaMetaFCOPtr p;
if(metam->get_DefinedFCOByName(name, VARIANT_FALSE, &p) == S_OK)
return p;
@@ -3380,7 +3380,7 @@
return NULL;
}
- IMgaMetaFCOPtr MetaObjLookup(IMgaMetaFolder *metaf, SmartBSTR &name) {
+ IMgaMetaFCOPtr MetaObjLookup(IMgaMetaFolder *metaf, const SmartBSTR &name) {
IMgaMetaFCOPtr p;
if(metaf->get_DefinedFCOByName(name, VARIANT_FALSE, &p) == S_OK)
return p;
@@ -3404,7 +3404,7 @@
return NULL;
}
- IMgaMetaFCOPtr MetaObjLookup(METALib::IMgaMetaProject *metap, string name) {
+ IMgaMetaFCOPtr MetaObjLookup(METALib::IMgaMetaProject *metap, const string& name) {
return MetaObjLookup(metap->RootFolder, SmartBSTR(name.c_str()));
}
@@ -3455,7 +3455,7 @@
if(!aclass && (rolename == "ref" || rolename == "members"))
{
::Uml::Class otarget = orole.target();
- nn->metaobj = MetaObjLookup(metaproj, PATHGET(otarget));
+ nn->metaobj = MetaObjLookup(metaproj, getShortClassPath(otarget));
// the reference could be an abstract UML class
if (nn->metaobj == NULL && rolename == "ref")
@@ -3467,7 +3467,7 @@
set< ::Uml::Class> other_descs = Uml::DescendantClasses(otarget);
for (set< ::Uml::Class>::iterator desc_i = other_descs.begin(); desc_i != other_descs.end(); desc_i++)
{
- IMgaMetaFCOPtr p = MetaObjLookup(metaproj, PATHGET(*desc_i));
+ IMgaMetaFCOPtr p = MetaObjLookup(metaproj, getShortClassPath(*desc_i));
if (p)
{
if (p->GetObjType() != OBJTYPE_REFERENCE) continue;
@@ -3514,7 +3514,7 @@
break;
}
//check if it is a connection and the rolenames directly identify the source and the destination
- if(rolename == "dst" && (!orole.isNavigable() || (string)orole.name() == "src"))
+ if (rolename == "dst" && (!orole.isNavigable() || static_cast<std::string>(orole.name()) == "src"))
{
set< ::Uml::Class> deriveds = Uml::DescendantClasses(aclass);
nn->primary = Uml::theOther(*j);
@@ -3538,7 +3538,7 @@
int real_size = 0;
for (set< ::Uml::Class>::iterator desc_i = descs.begin();desc_i != descs.end();desc_i++)
{
- IMgaMetaFCOPtr p = MetaObjLookup(metaproj, PATHGET(*desc_i));
+ IMgaMetaFCOPtr p = MetaObjLookup(metaproj, getShortClassPath(*desc_i));
if (p) real_size++;
};
@@ -3550,7 +3550,7 @@
//copy the MgaMetaFCOPtrs to the allocated array in the nn structure
for (set< ::Uml::Class>::iterator desc_ii = descs.begin();desc_ii != descs.end();desc_ii++)
{
- IMgaMetaFCOPtr p = MetaObjLookup(metaproj, PATHGET(*desc_ii));
+ IMgaMetaFCOPtr p = MetaObjLookup(metaproj, getShortClassPath(*desc_ii));
if (p)
{
nn->metaobjs[j] = p;
@@ -3587,7 +3587,7 @@
::Uml::AssociationRole orole = Uml::theOther(*j);
if(!orole.isNavigable()) continue;
- IMgaMetaFCOPtr bt = MetaObjLookup(metaproj, PATHGET((::Uml::Class)j->target()));
+ IMgaMetaFCOPtr bt = MetaObjLookup(metaproj, getShortClassPath(*j->target()));
if(bt)
{ // not abstract, etc;
SmartBSTR herename, therename, sRefParent, dRefParent;
@@ -3639,10 +3639,10 @@
for(j = roles.begin(); j != roles.end(); j++)
{
// XXX what namespace?
- if(searchname == NAMEGET((::Uml::Class)j->target()) && Uml::theOther(*j).isNavigable())
+ if(searchname == NAMEGET(*j->target()) && Uml::theOther(*j).isNavigable())
{
nn->primary = *j;
- nn->metaobj = MetaObjLookup(metaproj, PATHGET((::Uml::Class)j->target()));
+ nn->metaobj = MetaObjLookup(metaproj, getShortClassPath(*j->target()));
expect = nn->metaobj->GetObjType();
break;
}
@@ -3664,7 +3664,7 @@
set< ::Uml::Class> descs = Uml::DescendantClasses(aclass);
if (descs.size() <= 1)
{
- nn->metaobj = MetaObjLookup(metaproj, PATHGET(aclass));
+ nn->metaobj = MetaObjLookup(metaproj, getShortClassPath(aclass));
}
else
{
@@ -3676,7 +3676,7 @@
int real_size = 0;
for (set< ::Uml::Class>::iterator desc_i = descs.begin();desc_i != descs.end();desc_i++)
{
- IMgaMetaFCOPtr p = MetaObjLookup(metaproj, PATHGET(*desc_i));
+ IMgaMetaFCOPtr p = MetaObjLookup(metaproj, getShortClassPath(*desc_i));
if (p) real_size++;
};
@@ -3688,7 +3688,7 @@
//copy the MgaMetaFCOPtrs to the allocated array in the nn structure
for (set< ::Uml::Class>::iterator desc_ii = descs.begin();desc_ii != descs.end();desc_ii++)
{
- IMgaMetaFCOPtr p = MetaObjLookup(metaproj, PATHGET(*desc_ii));
+ IMgaMetaFCOPtr p = MetaObjLookup(metaproj, getShortClassPath(*desc_ii));
if (p)
{
nn->metaobjs[j] = p;
@@ -3749,7 +3749,7 @@
break;
default:
typeerr:
- throw udm_exception(errPrefix + "Association resolves to invalid object type: " + (string)nn->metaobj->Name);
+ throw udm_exception(errPrefix + "Association resolves to invalid object type: " + static_cast<std::string>(nn->metaobj->Name));
}
}//if (nn->metaobj)
else
@@ -3765,8 +3765,9 @@
//we expect that all the metaobjects are the same and equal to the one expected, OBJTYPE_CONNECTION
nn->ot = p->ObjType;
- if(nn->ot != expect) throw udm_exception(errPrefix + "Association resolves to invalid object type: " + (string)p->Name);
-
+ if (nn->ot != expect)
+ throw udm_exception(errPrefix + "Association resolves to invalid object type: " + static_cast<std::string>(p->Name));
+
//compute which one is the primary role name
herename = GetRoleFromMeta(p, L"sName");
therename = GetRoleFromMeta(p, L"dName");
@@ -3794,7 +3795,7 @@
if(!nn->primary)
{
if (nn->metaobj)
- throw udm_exception(errPrefix + "Association resolves to invalid object type: " + (string)nn->metaobj->Name);
+ throw udm_exception(errPrefix + "Association resolves to invalid object type: " + static_cast<std::string>(nn->metaobj->Name));
else
{
string descr = "amapInitialize: Incosistency between UML rolenames and sName/dName specifications for these related connections :";
@@ -3809,7 +3810,7 @@
}
if((!nn->rp_helper) &&(!reservednamesinUML) && (therename != SmartBSTR(Uml::MakeRoleName(Uml::theOther(nn->primary)).c_str()) || (nn->primary.isNavigable() && herename != SmartBSTR(Uml::MakeRoleName(nn->primary).c_str()))) )
{
- throw udm_exception(errPrefix + "Association end names mismatch: " + (string)nn->metaobj->Name);
+ throw udm_exception(errPrefix + "Association end names mismatch: " + static_cast<std::string>(nn->metaobj->Name));
}
}
//archetype_ready:
@@ -4152,8 +4153,8 @@
set< ::Uml::Class> des = Uml::DescendantClasses(role.target());
for (set< ::Uml::Class>::iterator des_i = des.begin(); des_i != des.end(); des_i++)
{
- MetaRoleFilter.insert(PATHGET(*des_i));
- MetaRoleFilter.insert(PATHGET(*des_i) + (string)role.name());
+ MetaRoleFilter.insert(getShortClassPath(*des_i));
+ MetaRoleFilter.insert(getShortClassPath(*des_i) + static_cast<std::string>(role.name()));
}
//insert the newly created set<string> in a cache
More information about the Mobies-commit
mailing list