1 #ifndef LAZYTYPES_H
2 #define LAZYTYPES_H
3 
4 #include <iostream>
5 #include <vector>
6 #include <set>
7 #include <stdint.h>
8 
9 #include "judyLArray.h"
10 #include "judySArray.h"
11 #include "judyL2Array.h"
12 #include "judyS2Array.h"
13 
14 class SDAI_Application_instance;
15 class lazyDataSectionReader;
16 class lazyFileReader;
17 
18 enum fileTypeEnum { Part21, Part28 };
19 // enum loadingEnum { immediate, lazy };
20 
21 typedef uint64_t instanceID;  ///< the number assigned to an instance in the file
22 typedef uint16_t sectionID;   ///< globally unique index of a sectionReader in a sectionReaderVec_t
23 typedef uint16_t fileID;      ///< the index of a lazyFileReader in a lazyFileReaderVec_t. Can be inferred from a sectionID
24 
25 /** store 16 bits of section id and 48 of instance offset into one 64-bit int
26  * use thus:
27  * positionAndSection ps = section;
28  * ps <<= 48;
29  * ps |= ( offset & 0xFFFFFFFFFFFF );
30  * //...
31  * offset = (ps & 0xFFFFFFFFFFFF );
32  * section = ( ps >> 48 );
33  * TODO: Also 8 bits of flags? Would allow files of 2^40 bytes, or ~1TB.
34  */
35 typedef uint64_t positionAndSection;
36 
37 typedef std::vector< instanceID > instanceRefs;
38 
39 typedef std::set< instanceID > instanceSet;
40 
41 //TODO: create a "unique instance id" from the sectionID and instanceID, and use it everywhere?
42 
43 /** This struct contains all the information necessary to locate an instance. It is primarily
44  * for instances that are present in a file but not memory. It could be useful in other
45  * situations, so the information should be kept up-to-date.
46  */
47 typedef struct {
48     long begin; ///< this is the result of tellg() before reading the instanceID; there may be whitespace or comments, but nothing else.
49     instanceID instance;
50     sectionID section;
51     /* bool modified; */ /* this will be useful when writing instances - if an instance is
52     unmodified, simply copy it from the input file to the output file */
53 } lazyInstanceLoc;
54 
55 /// used when populating the instance type map \sa lazyInstMgr::_instanceTypeMMap
56 typedef struct {
57     lazyInstanceLoc loc;
58     const char * name;
59     instanceRefs * refs;
60 } namedLazyInstance;
61 
62 // instanceRefs - map between an instanceID and instances that refer to it
63 typedef judyL2Array< instanceID, instanceID > instanceRefs_t;
64 
65 // instanceType_t - multimap from instance type to instanceID's
66 typedef judyS2Array< instanceID > instanceTypes_t;
67 
68 // instancesLoaded - fully created instances
69 typedef judyLArray< instanceID, SDAI_Application_instance * > instancesLoaded_t;
70 
71 // instanceStreamPos - map instance id to a streampos and data section
72 // there could be multiple instances with the same ID, but in different files (or different sections of the same file?)
73 typedef judyL2Array< instanceID, positionAndSection > instanceStreamPos_t;
74 
75 
76 // data sections
77 typedef std::vector< lazyDataSectionReader * > dataSectionReaderVec_t;
78 
79 // files
80 typedef std::vector< lazyFileReader * > lazyFileReaderVec_t;
81 
82 // type for performing actions on multiple instances
83 // NOTE not useful? typedef std::vector< lazyInstance > lazyInstanceVec_t;
84 
85 #endif //LAZYTYPES_H
86 
87