Commit 96b0d78f authored by casualet's avatar casualet

able to show ordered onion meta

parent d17a467f
...@@ -353,12 +353,41 @@ void batchTogether(std::string client, std::string curQuery,unsigned long long _ ...@@ -353,12 +353,41 @@ void batchTogether(std::string client, std::string curQuery,unsigned long long _
} }
static void processOnionMeta(OnionMeta &om){
std::cout<<"om.getAnonOnionName(): "<<om.getAnonOnionName()<<std::endl;
}
static void processFieldMeta(const FieldMeta &field){ static void processFieldMeta(const FieldMeta &field){
std::cout<<GREEN_BEGIN<<"PRINT FieldMeta"<<COLOR_END<<std::endl; //Process general info
if(field.getHasSalt()){
std::cout<<"this field has salt"<<std::endl;
}
std::cout<<"field.getFieldName(): "<<field.getFieldName()<<std::endl;
std::cout<<"field.getSaltName(): "<<field.getSaltName()<<std::endl;
std::cout<<"field.serialize(): "<<field.serialize(field)<<std::endl;
for(std::pair<const OnionMetaKey *, OnionMeta *> &ompair:field.orderedOnionMetas()){
processOnionMeta(*ompair.second);
}
//Process Onions
if(field.hasOnion(oDET)){
field.getOnionMeta(oDET);
}
if(field.hasOnion(oOPE)){
field.getOnionMeta(oOPE);
}
if(field.hasOnion(oAGG)){
field.getOnionMeta(oAGG);
}
return;
//iterate over onions
for(const std::pair<const OnionMetaKey,std::unique_ptr<OnionMeta> > & onion: field.getChildren()){ for(const std::pair<const OnionMetaKey,std::unique_ptr<OnionMeta> > & onion: field.getChildren()){
std::cout<<onion.second->getDatabaseID()<<":"<<onion.first.getValue()<<std::endl; std::cout<<onion.second->getDatabaseID()<<":"<<onion.first.getValue()<<std::endl;
} }
std::cout<<GREEN_BEGIN<<"end FieldMeta"<<COLOR_END<<std::endl;
} }
static void processTableMeta(const TableMeta &table){ static void processTableMeta(const TableMeta &table){
......
...@@ -19,6 +19,7 @@ public: ...@@ -19,6 +19,7 @@ public:
} }
}; };
//we have onionMetaKey,UIntMetaKey and IdentityMetaKey for metadata hierachy
template <typename KeyType> template <typename KeyType>
class MetaKey : public AbstractMetaKey { class MetaKey : public AbstractMetaKey {
const KeyType key_data; const KeyType key_data;
......
...@@ -82,15 +82,18 @@ private: ...@@ -82,15 +82,18 @@ private:
class FieldMeta : public MappedDBMeta<OnionMeta, OnionMetaKey>, class FieldMeta : public MappedDBMeta<OnionMeta, OnionMetaKey>,
public UniqueCounter { public UniqueCounter {
public: public:
// New. // New a fieldmeta, Create_field and unique are used for determin the characteristics of the new
//fieldmeta, they are not part of fieldmeta.
FieldMeta(const Create_field &field, const AES_KEY * const mKey, FieldMeta(const Create_field &field, const AES_KEY * const mKey,
SECURITY_RATING sec_rating, unsigned long uniq_count, SECURITY_RATING sec_rating, unsigned long uniq_count,
bool unique); bool unique);
// Restore (WARN: Creates an incomplete type as it will not have it's // Restore (WARN: Creates an incomplete type as it will not have it's
// OnionMetas until they are added by the caller). // OnionMetas until they are added by the caller).
static std::unique_ptr<FieldMeta> static std::unique_ptr<FieldMeta>
deserialize(unsigned int id, const std::string &serial); deserialize(unsigned int id, const std::string &serial);
//从数据库中读取serial数据, 反序列化以后, 就可以使用这个构造函数构造一个新的fieldmeta
//read serialized data, deserialize it, and then construct new fieldmeta
FieldMeta(unsigned int id, const std::string &fname, bool has_salt, FieldMeta(unsigned int id, const std::string &fname, bool has_salt,
const std::string &salt_name, onionlayout onion_layout, const std::string &salt_name, onionlayout onion_layout,
SECURITY_RATING sec_rating, unsigned long uniq_count, SECURITY_RATING sec_rating, unsigned long uniq_count,
...@@ -102,19 +105,26 @@ public: ...@@ -102,19 +105,26 @@ public:
counter(counter), has_default(has_default), counter(counter), has_default(has_default),
default_value(default_value) { default_value(default_value) {
} }
~FieldMeta() {;} ~FieldMeta() {;}
std::string serialize(const DBObject &parent) const; std::string serialize(const DBObject &parent) const;
std::string stringify() const; std::string stringify() const;
std::vector<std::pair<const OnionMetaKey *, OnionMeta *>> std::vector<std::pair<const OnionMetaKey *, OnionMeta *>>
orderedOnionMetas() const; orderedOnionMetas() const;
std::string getSaltName() const; std::string getSaltName() const;
unsigned long getUniq() const {return uniq_count;} unsigned long getUniq() const {return uniq_count;}
OnionMeta *getOnionMeta(onion o) const; OnionMeta *getOnionMeta(onion o) const;
TYPENAME("fieldMeta"); TYPENAME("fieldMeta");
SECURITY_RATING getSecurityRating() const {return sec_rating;} SECURITY_RATING getSecurityRating() const {return sec_rating;}
bool hasOnion(onion o) const; bool hasOnion(onion o) const;
bool hasDefault() const {return has_default;} bool hasDefault() const {return has_default;}
std::string defaultValue() const {return default_value;} std::string defaultValue() const {return default_value;}
...@@ -134,10 +144,12 @@ private: ...@@ -134,10 +144,12 @@ private:
const std::string default_value; const std::string default_value;
SECLEVEL getOnionLevel(onion o) const; SECLEVEL getOnionLevel(onion o) const;
static onionlayout determineOnionLayout(const AES_KEY *const m_key, static onionlayout determineOnionLayout(const AES_KEY *const m_key,
const Create_field &f, const Create_field &f,
SECURITY_RATING sec_rating); SECURITY_RATING sec_rating);
static bool determineHasDefault(const Create_field &cf); static bool determineHasDefault(const Create_field &cf);
static std::string determineDefaultValue(bool has_default, static std::string determineDefaultValue(bool has_default,
const Create_field &cf); const Create_field &cf);
uint64_t &getCounter_() {return counter;} uint64_t &getCounter_() {return counter;}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment