#include "Comment.hxx"
#include "Function.hxx"
+#include "InformationManager.hxx"
+#include "events/ChangeCommentEvent.hxx"
Comment::Comment(uint64_t address, InformationManager* manager)
: address(address)
, manager(manager) {}
void Comment::setText(const std::string& text) {
+ ChangeCommentEvent event(address, location, this);
this->text = text;
+ manager->dispatch(&event);
}
uint64_t Comment::getAddress() {
return address;
}
+
+Function* Comment::getLocation() {
+ return location;
+}
void setText(const std::string& text);
uint64_t getAddress();
+ Function* getLocation();
private:
Comment(uint64_t address, InformationManager* manager);
Comment(uint64_t address, Function* location, InformationManager* manager);
#include "core/BasicBlock.hxx"
#include "core/Comment.hxx"
#include "core/events/NewFunctionEvent.hxx"
+#include "core/events/ChangeCommentEvent.hxx"
#include "gui/qt.hxx"
#include <quazip/quazip.h>
return blocks.end();
}
+/* *********************************
+ * Accessors for the Comments map
+ */
+std::pair<
+ std::multimap<uint64_t, Comment*>::const_iterator,
+ std::multimap<uint64_t, Comment*>::const_iterator>
+InformationManager::getComments(uint64_t address) {
+ return comments.equal_range(address);
+}
+
+std::multimap<uint64_t, Comment*>::const_iterator InformationManager::beginComments() {
+ return comments.begin();
+}
+std::multimap<uint64_t, Comment*>::const_iterator InformationManager::endComments() {
+ return comments.end();
+}
/* *********************************
* Accessors for the Interpreter map
}
Comment* InformationManager::newLocalComment(uint64_t address, Function* f) {
- Comment* comment = new Comment(address, this);
+ Comment* comment = new Comment(address, f, this);
comments.insert(std::make_pair(address, comment));
return comment;
}
void InformationManager::finishBasicBlock(BasicBlock*) {
}
-void InformationManager::finnishComment(Comment* c) {
+void InformationManager::finishComment(Comment* c) {
+ LOG4CXX_DEBUG(logger, "Finishing comment " << c->getAddress());
+ ChangeCommentEvent event(c->getAddress(), c->getLocation(), c);
+ dispatch(&event);
}
void InformationManager::deleteFunction(Function* f) {
std::map<uint64_t, BasicBlock*>::const_iterator beginBasicBlocks();
std::map<uint64_t, BasicBlock*>::const_iterator endBasicBlocks();
+ std::pair<
+ std::multimap<uint64_t, Comment*>::const_iterator,
+ std::multimap<uint64_t, Comment*>::const_iterator>
+ getComments(uint64_t address);
+ bool hasComments() const {return ! comments.empty();}
+ std::multimap<uint64_t,Comment*>::const_iterator beginComments();
+ std::multimap<uint64_t,Comment*>::const_iterator endComments();
+
Interpreter* getInterpreter(const std::string& name);
bool hasInterpreters() const {return interpreters.size() != 0;}
std::map<std::string, Interpreter*>::const_iterator beginInterpreters();
std::map<std::string, Interpreter*>::const_iterator endInterpreters();
-
/* Protocoll:
*
* Users may allocate new Data containers with the new*()
Comment* newLocalComment(uint64_t address, Function* f);
void finishFunction(Function* f);
void finishBasicBlock(BasicBlock* b);
- void finnishComment(Comment* c);
+ void finishComment(Comment* c);
void deleteFunction(Function* f);
void deleteBasicBlock(BasicBlock* b);
void deleteComment(Comment* c);
--- /dev/null
+#ifndef INCLUDE__ChangeCommentEvent_hxx_
+#define INCLUDE__ChangeCommentEvent_hxx_
+
+#include <string>
+
+class Comment;
+class Function;
+
+class ChangeCommentEvent {
+public:
+ ChangeCommentEvent(uint64_t address, Function* function, Comment* comment)
+ : address(address), function(function), comment(comment) {}
+ ChangeCommentEvent(uint64_t address, Comment* comment)
+ : address(address), function(NULL), comment(comment) {}
+
+ uint64_t address;
+ Function* function;
+ Comment* comment;
+};
+
+#endif /* INCLUDE__ChangeCommentEvent_hxx_ */
#include <cstdint>
#include <string>
+class Comment;
+
class Instruction {
public:
Instruction(uint64_t address, const std::string& text, const std::vector<uint8_t>& bytes, const std::string& reference)
const std::string& getText() const {return text;}
const std::vector<uint8_t>& getBytes() const {return bytes;}
const std::string& getReference() const {return reference;}
+ std::vector<Comment*>& comments() {return _comments;}
private:
uint64_t address;
std::string text;
std::vector<uint8_t> bytes;
std::string reference;
+ std::vector<Comment*> _comments;
};
#endif /* INCLUDE__Instruction_hxx_ */