-// Copyright (C) 2006-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2006-2016 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
}
}
+std::string TypeCode::getPrintStr() const
+{
+ return id();
+}
+
//! Check if this TypeCode can be used in place of tc
/*!
* this TypeCode is equivalent to tc if they have the same kind
return KIND_STR_REPR[(int)kind];
}
+const TypeCode *TypeCode::subContentType(int lev) const
+{
+ if(lev<0)
+ throw YACS::Exception("subContentType: Invalid input val !");
+ if(lev==0)
+ return this;
+ const TypeCode *ret(this);
+ for(int i=0;i<lev;i++)
+ {
+ const TypeCode *cand(ret->contentType());
+ if(!cand)
+ throw YACS::Exception("subContentType : Invalid input val 2 !");
+ ret=cand;
+ }
+ return ret;
+}
+
const char * TypeCode::getKindRepr() const
{
return KIND_STR_REPR[(int)_kind];
return _shortName.c_str();
}
+std::string TypeCodeSeq::getPrintStr() const
+{
+ std::ostringstream oss; oss << "seq[" << contentType()->getPrintStr() << "]";
+ return oss.str();
+}
+
const TypeCode * TypeCodeSeq::contentType() const throw(YACS::Exception)
{
return _content;
*/
int TypeCodeStruct::isAdaptable(const TypeCode* tc) const
{
- if(_kind == tc->kind()) return isA(tc->id());
- return 0;
+ if (_kind != tc->kind()) return 0;
+ if (_repoId == tc->id()) return 1;
+ int nMember = memberCount();
+ if (nMember != ((TypeCodeStruct*)tc)->memberCount()) return 0;
+ for (int i=0 ; i<nMember ; i++)
+ {
+ const char * name = memberName(i);
+ if (strcmp(memberName(i), ((TypeCodeStruct*)tc)->memberName(i)) != 0) return 0;
+ if (!memberType(i)->isAdaptable(((TypeCodeStruct*)tc)->memberType(i))) return 0;
+ }
+ return 1;
}
//! Check if this TypeCode can be used in place of tc