1 #ifndef INCLUDE__InformationManager_hxx
2 #define INCLUDE__InformationManager_hxx
4 #include <boost/signals2.hpp>
16 class RenameFunctionEvent;
18 class InformationManager {
20 ~InformationManager();
22 void reset(const std::string& filename);
23 void save(const QString& filename);
25 void signal_new_function(Function* f);
26 void signal_new_dyn_symbol(const std::string& f)
27 { new_dyn_symbol_signal(f); }
29 boost::signals2::connection
30 connect_new_function_signal(std::function<void(Function*)> f)
31 { return new_function_signal.connect(f); }
33 boost::signals2::connection
34 connect_new_dyn_symbol_signal(std::function<void(const std::string& name)> f)
35 { return new_dyn_symbol_signal.connect(f); }
37 boost::signals2::connection
38 connect_reset_signal(std::function<void ()> f)
39 { return reset_signal.connect(f); }
41 boost::signals2::connection
42 connect_rename_function_signal(std::function<void (RenameFunctionEvent*)> f)
43 { return rename_function_signal.connect(f); }
45 Disassembler* getDisassembler()
46 { return disassembler.get(); }
48 void dispatch(RenameFunctionEvent* event)
49 { rename_function_signal(event); }
51 Function* getFunction(uint64_t address);
52 BasicBlock* getBasicBlock(uint64_t address);
56 * Users may allocate new Data containers with the new*()
57 * functions. Once they have populated the information they hand
58 * over the object to the information manager using the finish*()
61 * if new*() returns NULL there already exists a function at the
62 * specified address. Users may then get the old object if they
63 * wish or (more likely) skip creating it. Uniqueness of the
64 * object is only guaranteed as compared to the finish()ed
67 * Users are responsible for destroying functions iff they do not
68 * finish them using the delete*() functions. Once the objects are
69 * finished, the information manager is responsible for cleaning
70 * up the memory. If delete*() is called on a finished object, bad
73 Function* newFunction(uint64_t address);
74 BasicBlock* newBasicBlock(uint64_t address);
75 Comment* newGlobalComment(uint64_t address);
76 Comment* newLocalComment(uint64_t address, Function* f);
77 void finishFunction(Function* f);
78 void finishBasicBlock(BasicBlock* b);
79 void finnishComment(Comment* c);
80 void deleteFunction(Function* f);
81 void deleteBasicBlock(BasicBlock* b);
82 void deleteComment(Comment* c);
84 boost::signals2::signal<void ()> reset_signal;
85 boost::signals2::signal<void (Function*)> new_function_signal;
86 boost::signals2::signal<void (const std::string& name)> new_dyn_symbol_signal;
87 boost::signals2::signal<void (RenameFunctionEvent*)> rename_function_signal;
88 std::unique_ptr<Disassembler> disassembler;
89 std::map<uint64_t, Function*> functions;
90 std::map<uint64_t, BasicBlock*> blocks;
93 #endif /* INCLUDE__InformationManager_hxx */