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 UPDATE_ENGINE_PAYLOAD_GENERATOR_OPERATIONS_GENERATOR_H_
18 #define UPDATE_ENGINE_PAYLOAD_GENERATOR_OPERATIONS_GENERATOR_H_
19 
20 #include <vector>
21 
22 #include <base/macros.h>
23 
24 #include "update_engine/payload_generator/annotated_operation.h"
25 #include "update_engine/payload_generator/blob_file_writer.h"
26 #include "update_engine/payload_generator/payload_generation_config.h"
27 
28 namespace chromeos_update_engine {
29 
30 class OperationsGenerator {
31  public:
32   virtual ~OperationsGenerator() = default;
33 
34   // This method generates a list of operations to update from the partition
35   // |old_part| to |new_part| and stores the generated operations in |aops|.
36   // These operations are generated based on the given |config|.
37   // The operations should be applied in the order specified in the list, and
38   // they respect the payload version and type (delta or full) specified in
39   // |config|.
40   // The operations generated will refer to offsets in the file |blob_file|,
41   // where this function stores the output, but not necessarily in the same
42   // order as they appear in the |aops|.
43   virtual bool GenerateOperations(const PayloadGenerationConfig& config,
44                                   const PartitionConfig& old_part,
45                                   const PartitionConfig& new_part,
46                                   BlobFileWriter* blob_file,
47                                   std::vector<AnnotatedOperation>* aops) = 0;
48 
49  protected:
50   OperationsGenerator() = default;
51 
52  private:
53   DISALLOW_COPY_AND_ASSIGN(OperationsGenerator);
54 };
55 
56 }  // namespace chromeos_update_engine
57 
58 #endif  // UPDATE_ENGINE_PAYLOAD_GENERATOR_OPERATIONS_GENERATOR_H_
59