55fc449560f0d635e2abf400f9fcb2bd4ced686d
[calu.git] / 3c_disasm / CInstrFactory.hpp
1 /*
2  * Name:     CInstructionFactory
3  * Author:   Martin Perner, 0725782, 535
4  * E-Mail:   e0725782@student.tuwien.ac.at
5  * Purpose:  Factory for creating commands from shared libraries
6  * Date:     29.04.2009
7  */
8
9 #ifndef __CINSTRUCTIONFACTORY_H__
10 #define __CINSTRUCTIONFACTORY_H__
11
12 #include "Iinstr.hpp"
13
14 #include <string.h>
15
16 #include <iostream>
17 #include <sstream>
18 #include <map>
19 #include <vector>
20 #include <algorithm>
21
22 #include <dlfcn.h>
23 #include <errno.h>
24
25 #include <dirent.h>
26
27 /**
28  * Name:    CInstructionFactory
29  * Purpose: Factory for creating commands from shared libraries
30  */
31 class CInstrFactory {
32 private:
33         std::map<void*, Iinstr*> m_libStore;
34         std::vector<std::string> m_files;
35
36         Iinstr* loadFromLib(std::string lib);
37 public:
38         Iinstr* getNextInstr();
39         size_t getNumFiles();
40         size_t searchLibsInDir(std::string dir);
41         void loadLibsIntoMap(map<short, Iinstr*>& instr, string dir);
42         CInstrFactory() : m_libStore(), m_files() {};
43         ~CInstrFactory();
44 };
45
46 #endif