summaryrefslogtreecommitdiff
path: root/Database/internals/database-internal.h
blob: 4616d8cf1725f8561774c0e08de759dc98d2444b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef __DATABASE_INTERNAL_H__
#define __DATABASE_INTERNAL_H__

#include "database-segment.h"
#include "database-types.h"

class Database;
class Cpu;

/** A database element. Basically, the database is a collection of segments, associated with information.
 * This class could have been merged with Segment's, but in an effort to split the segment, that only
 * contains the raw memory, and the various data associated with it, this glue element exists. It'll also
 * construct a linked list for the database.
 */

class DatabaseCell : public Base {
  public:
      /** The constructor of a DatabaseCell. Note that if you specify the origin parameter, 
       * it'll create a sub-segment based on the first one. Note also that this doesn't support
       * the patching system, yet. data and origin are mutually exclusive.
       */
      DatabaseCell(Database * parent, Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size = 0, const Byte * data = 0);
      ~DatabaseCell();
    Uint32 getId() { return segment->getId(); }
    void LoadMemory(Handle * src) { segment->LoadMemory(src); }
    Segment * getSegment() { return segment; }
    Cpu * getCpu() { return cpu; }
    Uint64 getCpuBase() { return segment->getCpuBase(); }
    absolute_ptr getOrigin() { return origin; }
    DatabaseCell * getNext() { return next; }

  private:
    Segment * segment;
    Cpu * cpu;
    absolute_ptr origin; // a data segment can come from within another one
    DatabaseCell * next, * prev;
    Database * parent;
};

#endif