forked from steemit/steem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.cpp
46 lines (33 loc) · 968 Bytes
/
schema.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <graphene/schema/schema.hpp>
#include <set>
namespace graphene { namespace schema {
namespace detail {
int64_t _next_schema_id()
{
static int64_t _next_id = 1;
return _next_id++;
}
}
void add_dependent_schemas( std::vector< std::shared_ptr< abstract_schema > >& schema_list )
{
std::vector< std::shared_ptr< abstract_schema > > to_process;
std::vector< std::shared_ptr< abstract_schema > > result;
std::set< int64_t > has_types;
for( std::shared_ptr< abstract_schema > s : schema_list )
to_process.push_back( s );
size_t i = 0;
while( i < to_process.size() )
{
std::shared_ptr< abstract_schema > s = to_process[i++];
std::string s_name;
s->get_name( s_name );
int64_t id = s->get_id();
if( has_types.find( id ) != has_types.end() )
continue;
has_types.insert( id );
result.push_back( s );
s->get_deps( to_process );
}
schema_list.swap(result);
}
} }