schema.h 1.64 KB
Newer Older
Giorgio Azzinnaro's avatar
Giorgio Azzinnaro committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * ProfaneDB - A Protocol Buffers database.
 * Copyright (C) 2017  "Giorgio Azzinnaro" <giorgio.azzinnaro@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

20 21
#ifndef PROFANEDB_BOOT_SCHEMA_H
#define PROFANEDB_BOOT_SCHEMA_H
Giorgio Azzinnaro's avatar
Giorgio Azzinnaro committed
22 23 24 25

#include <profanedb/protobuf/storage.pb.h>

namespace profanedb {
26
namespace boot {
Giorgio Azzinnaro's avatar
Giorgio Azzinnaro committed
27

28 29 30 31 32 33
// A Schema defines a Key for each message,
// a Key is a unique identifier for that given message.
// This data might be retrieved directly from the message,
// or the Schema might need to parse some definition to know what to do
template <typename Message>
class Schema {
Giorgio Azzinnaro's avatar
Giorgio Azzinnaro committed
34
public:
35 36 37 38
    virtual ~Schema() = 0;
    
    // Check whether a Message has a key, therefore can be stored
    virtual bool IsKeyable(const Message & message) const = 0;
Giorgio Azzinnaro's avatar
Giorgio Azzinnaro committed
39
    
40
    // Extract a Key from a Message
Giorgio Azzinnaro's avatar
Giorgio Azzinnaro committed
41
    virtual profanedb::protobuf::Key GetKey(const Message & message) const = 0;
Giorgio Azzinnaro's avatar
Giorgio Azzinnaro committed
42
    
43 44
    // Retrieve nested messages from a message
    virtual std::vector<const Message *> GetNestedMessages(const Message & message) const = 0;
Giorgio Azzinnaro's avatar
Giorgio Azzinnaro committed
45 46 47 48
};
}
}

49
#endif // PROFANEDB_BOOT_SCHEMA_H