Version: 1.0
graph_code_generator.h
Go to the documentation of this file.
1 // Copyright (c) 2020, the GRAPHGEN contributors, as
2 // shown by the AUTHORS file. All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6 
7 #ifndef GRAPHGEN_GRAPH_CODE_GENERATOR_H_
8 #define GRAPHGEN_GRAPH_CODE_GENERATOR_H_
9 
10 #include <ostream>
11 
12 #include "conact_tree.h"
13 #include "forest.h"
14 #include "rule_set.h"
15 
17 #define BEFORE_AFTER_FUNC(func_name) std::string func_name(size_t index, \
18  const std::string& prefix, \
19  const std::vector<std::vector<size_t>>& mapping, \
20  size_t end_group_id)
21 
28 
76 size_t GenerateDragCode(std::ostream& os,
77  const BinaryDrag<conact>& bd,
78  bool with_gotos = false,
81  const std::string prefix = "",
82  size_t start_id = 0,
83  const std::vector<std::vector<size_t>> mapping = {},
84  size_t end_group_id = 0);
85 
87 bool GenerateDragCode(const BinaryDrag<conact>& bd,
88  bool with_gotos = false,
91  const std::string prefix = "",
92  size_t start_id = 0,
93  const std::vector<std::vector<size_t>> mapping = {},
94  size_t end_group_id = 0);
95 
101 size_t GenerateLineForestCode(std::ostream& os,
102  const LineForestHandler& lfh,
103  std::string prefix,
104  size_t start_id,
105  BEFORE_AFTER_FUNC(before_main) = BeforeMainShiftOne,
106  BEFORE_AFTER_FUNC(after_main) = DefaultEmptyFunc,
107  BEFORE_AFTER_FUNC(before_end) = BeforeEnd,
108  BEFORE_AFTER_FUNC(after_end) = AfterEnd);
109 
110 
111 #endif // GRAPHGEN_GRAPH_CODE_GENERATOR_H_
#define BEFORE_AFTER_FUNC(func_name)
Macro used to define the base signature of before and after functions.
std::string BeforeMainShiftOne(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id)
std::string AfterEndNoLoop(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id)
std::string AfterEnd(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id)
std::string BeforeEnd(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id)
std::string DefaultEmptyFunc(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id)
std::string BeforeMainShiftTwo(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id)
size_t GenerateLineForestCode(std::ostream &os, const LineForestHandler &lfh, std::string prefix, size_t start_id, std::string before_main(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id)=BeforeMainShiftOne, std::string after_main(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id)=DefaultEmptyFunc, std::string before_end(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id)=BeforeEnd, std::string after_end(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id)=AfterEnd)
Generate the C++ code for the given Forest.
size_t GenerateDragCode(std::ostream &os, const BinaryDrag< conact > &bd, bool with_gotos=false, std::string before(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id)=DefaultEmptyFunc, std::string after(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id)=DefaultEmptyFunc, const std::string prefix="", size_t start_id=0, const std::vector< std::vector< size_t >> mapping={}, size_t end_group_id=0)
This function generates the code for the given drag reversing the output into the specified stream.
Generates all the forests needed to handle one line of the image.
Definition: forest.h:51