p1.size() < p2.size();
84 constvector<CConvGraph::TPath>& paths,
87 if(paths.size() == 0)
91 size_t count= 0, length;
92length = paths[0].size();
93 ITERATE(vector<CConvGraph::TPath>, iter, paths) {
94 if((*iter).size() > length)
104 ITERATE(vector<CConvGraph::TPath>, iter, paths) {
105 if((*iter).size() > length)
110 if((*iter).size() == 1) {
111rel = registered[(*iter).front()];
116complex->AddRelation(registered[*iter2]);
120relations.push_back(rel);
122composite->AddRelation(rel);
128 const string& to_type_in,
147it = vertices.
find(from_type);
148 size_tfrom_vertex = (it != vertices.
end()) ?
151it = vertices.
find(to_type);
152 size_tto_vertex = (it != vertices.
end()) ?
159vector<CConvGraph::TPath> paths;
161 if(so && (to_type ==
"Object"|| to_type ==
"SerialObject")) {
162graph.
FindPaths(from_vertex, to_vertex, paths);
163 if(paths.size() > 0 && paths[0].size() <= 2)
171 if(from_type == to_type) {
176graph.
FindPaths(from_vertex, to_vertex, paths);
178 if(paths.size() > 0) {
192 sm_Relations[idxContainer2Object]->GetRelated(scope, obj, related);
193 if(related.size() == 0)
203 if(from_type == to_type) {
208it = vertices.
find(from_type);
209from_vertex = (it != vertices.
end()) ?
212vector<CConvGraph::TPath> paths2;
213graph.
FindPaths(from_vertex, to_vertex, paths2);
214 ITERATE(vector<CConvGraph::TPath>, iter2, paths2)
218 if(pathSet.
size() == 0)
223paths.push_back(*it);
226(*it).insert((*it).begin(), idxContainer2Object);
240ostream <<
"digraph {"<< endl;
243ostream <<
" \""<< vertices[(*iter)->GetTypeName()]
244<<
"\" -> \""<< vertices[(*iter)->GetRelatedTypeName()] <<
"\";"<< endl;
249ostream <<
" \""<< (*iter)->GetTypeName()
250<<
"\" -> \""<< (*iter)->GetRelatedTypeName() <<
"\";"<< endl;
253ostream <<
"}"<< endl;
279 const string& to_type,
290 const string& to_type,
292m_FromType(from_type),
294m_TypeConverter(typeConverter) {}
298 const CObject& o = m_TypeConverter.GetObject();
299 return typeid(o).name();
311 virtual void Dump(ostream& ostream)
const 313 const CObject& o = m_TypeConverter.GetObject();
314ostream <<
typeid(o).name() << endl;
324objects::CScope& scope,
333related.push_back(
SObject(iter->GetObject()));
338 const string& to_type,
345 const string& alias)
377 const string& to_type_in)
381 return(relations.size() > 0);
394 const string& to_type_in, TObjList& objs,
402ostr << endl << endl;
406ostr <<
"Conversion: "<< from_type <<
" -- > "<< to_type_in << endl <<
"{"<< endl;
409 int count= relations.size();
411ostr <<
"*** Conversion not found ***"<< endl;
413 for(
int i= 0;
i<
count; ++
i) {
414relations[
i]->Dump(ostr);
422 if(relations.size() == 0)
426relations[0]->GetRelated(scope, obj, related,
flags);
430iter->GetComment()));
437 size_tfrom_index, to_index;
438 stringfrom_type = (*iter)->GetTypeName();
439 stringto_type = (*iter)->GetRelatedTypeName();
442 if(it == vertices.
end()) {
443from_index = vertices.
size();
444vertices[from_type] = from_index;
447from_index = it->second;
449it = vertices.
find(to_type);
450 if(it == vertices.
end()) {
451to_index = vertices.
size();
452vertices[to_type] = to_index;
455to_index = it->second;
457graph.
add_edge(from_index, to_index);
464 if((*iter)->GetName() == name) {
510pair<CConvertCache::TCache::iterator, bool>
void FindPaths(size_t startVertex, size_t endVertex, vector< TPath > &paths) const
size_t add_edge(size_t from, size_t to)
virtual const TObjList & Convert(objects::CScope &scope, const CObject &obj, const CTypeInfo *info, CObjectConverter::TFlags flags=CObjectConverter::eDefault)
CObjectConverter::TObjList TObjList
static const char * m_Name
static void RegisterTypeAlias(const string &real_name, const string &alias)
static TTypeAliases sm_TypeAliases
static void SetDefaultFlags(TFlags flags)
static const CRelation * FindRelationByName(const string &name)
static void Register(CRelation *rel)
static const string & x_NormalizeTypeName(const string &str)
static size_t x_FindRelationByName(const string &name)
static void Convert(objects::CScope &scope, const CObject &obj, const CTypeInfo *info, TObjList &objs, TFlags flags=eDefault)
Convert an object of potentially unknown type to a set of objects of known type.
static void x_BuildGraph(CConvGraph &graph, map< string, size_t > &vertices)
vector< TRelation > TRelationVector
static TFlags sm_DefaultFlags
the default conversion flags
static void DumpDotGraph(ostream &ostream, bool dumpIDs=false)
static TFlags GetDefaultFlags(void)
static bool CanConvert(objects::CScope &scope, const CObject &obj, const CTypeInfo *type_info)
Determine whether an indicated conversion can be performed.
static TRelationVector sm_Relations
static void FindRelations(objects::CScope &scope, const CObject &obj, const string &to_type_in, TRelationVector &relations)
virtual void GetRelated(objects::CScope &scope, const CObject &obj, TObjects &related, TFlags flags=eDefault, ICanceled *cancel=NULL) const
virtual string GetRelatedTypeName() const
virtual string GetDescription() const
virtual void Dump(ostream &ostream) const
virtual string GetTypeName() const
CRelationTypeConverterAdapter()
CConstRef< ITypeConverter > m_TypeConverter
virtual string GetName() const
CRelationTypeConverterAdapter(const string &from_type, const string &to_type, ITypeConverter *typeConverter)
vector< SObject > TObjects
virtual void GetRelated(objects::CScope &scope, const CObject &obj, TObjects &related, TFlags flags=eDefault, ICanceled *cancel=NULL) const =0
virtual string GetName() const =0
Base class for all serializable objects.
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Interface for testing cancellation request in a long lasting operation.
@ eDefault
combined sets of flags
vector< SObject > TObjList
virtual void Convert(objects::CScope &scope, const CObject &obj, TObjList &objs, TFlags flags=eDefault) const =0
container_type::const_iterator const_iterator
container_type::iterator iterator
const_iterator end() const
iterator_bool insert(const value_type &val)
container_type::value_type value_type
const_iterator find(const key_type &key) const
iterator_bool insert(const value_type &val)
std::ofstream out("events_result.xml")
main entry point for tests
static const char * str(char *buf, int n)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
vector< CRef< CObject > > TObjects
virtual const CTypeInfo * GetThisTypeInfo(void) const =0
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
static int CompareCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive compare of a substring with another string.
const string & GetName(void) const
Get name of this type.
#define NCBI_GUIOBJUTILS_EXPORT
constexpr auto sort(_Init &&init)
const struct ncbi::grid::netcache::search::fields::KEY key
Multi-threading â mutexes; rw-locks; semaphore.
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static void x_BuildRelations(const CObjectConverter::TRelationVector ®istered, const vector< CConvGraph::TPath > &paths, CObjectConverter::TRelationVector &relations)
DEFINE_STATIC_MUTEX(s_ObjCvtMutex)
static bool PCompare(const CConvGraph::TPath &p1, const CConvGraph::TPath &p2)
bool operator()(const SCacheKey &key1, const SCacheKey &key2) const
CConstRef< objects::CScope > m_Scope
CConstRef< CObject > m_Obj
struct SObject provides an interface for defining what is returned from object conversion.
struct SObject provides an interface for defining what is returned from object conversion.
static const char * type_name(CS_INT value)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4