00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <drizzled/generator.h>
00024 #include <drizzled/session.h>
00025
00026 using namespace std;
00027
00028 namespace drizzled
00029 {
00030 namespace generator
00031 {
00032
00033 Schema::Schema(Session &arg) :
00034 session(arg)
00035 {
00036 plugin::StorageEngine::getIdentifiers(session, schema_names);
00037 #if defined(DEBUG)
00038 random_shuffle(schema_names.begin(), schema_names.end());
00039 #endif
00040 schema_iterator= schema_names.begin();
00041 }
00042
00043 Schema::operator const drizzled::message::schema::shared_ptr()
00044 {
00045 while (schema_iterator != schema_names.end())
00046 {
00047 identifier::Schema schema_identifier(*schema_iterator);
00048
00049 if (not plugin::Authorization::isAuthorized(*session.user(), schema_identifier, false))
00050 {
00051 schema_iterator++;
00052 continue;
00053 }
00054
00055 schema= plugin::StorageEngine::getSchemaDefinition(schema_identifier);
00056 schema_iterator++;
00057
00058 if (schema)
00059 return schema;
00060 }
00061
00062 return message::schema::shared_ptr();
00063 }
00064
00065 Schema::operator const drizzled::identifier::Schema*()
00066 {
00067 while (schema_iterator != schema_names.end())
00068 {
00069 const drizzled::identifier::Schema *_ptr= &(*schema_iterator);
00070 schema_iterator++;
00071
00072 if (not plugin::Authorization::isAuthorized(*session.user(), *_ptr, false))
00073 continue;
00074
00075 return _ptr;
00076 }
00077
00078 return NULL;
00079 }
00080
00081 }
00082 }