1 //
2 // Copyright (C) 2015 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef ATTESTATION_SERVER_DATABASE_H_
18 #define ATTESTATION_SERVER_DATABASE_H_
19 
20 #include "attestation/common/database.pb.h"
21 
22 namespace attestation {
23 
24 // Manages a persistent database of attestation-related data.
25 class Database {
26  public:
27   virtual ~Database() = default;
28 
29   // Const access to the database protobuf.
30   virtual const AttestationDatabase& GetProtobuf() const = 0;
31 
32   // Mutable access to the database protobuf. Changes made to the protobuf will
33   // be reflected immediately by GetProtobuf() but will not be persisted to disk
34   // until SaveChanges is called successfully.
35   virtual AttestationDatabase* GetMutableProtobuf() = 0;
36 
37   // Writes the current database protobuf to disk.
38   virtual bool SaveChanges() = 0;
39 
40   // Reloads the database protobuf from disk.
41   virtual bool Reload() = 0;
42 };
43 
44 }  // namespace attestation
45 
46 #endif  // ATTESTATION_SERVER_DATABASE_H_
47