[go: up one dir, main page]

Menu

[r12]: / metadata / index.h  Maximize  Restore  History

Download this file

61 lines (46 with data), 1.2 kB

 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef __INDEX_H__
#define __INDEX_H__
#include <file.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
class CIndex
{
public:
CIndex();
~CIndex();
public:
int lookup(const string& filename, set<CFileAttr, CAttrComp>* attr = NULL);
int insert(const CFileAttr& attr);
int remove(const string& filename);
public:
int getFileList(map<string, set<CFileAttr, CAttrComp> >& list);
private:
map<string, set<CFileAttr, CAttrComp> > m_mFileList;
pthread_mutex_t m_IndexLock;
};
struct CIndexInfo
{
char m_pcName[64]; // unique file name
timeval m_TimeStamp; // time stamp
//char m_pcType[64]; // file type, data, video, audio, etc
int64_t m_llSize; // size
timeval m_LRT; // last time the file information is reported (Last Report Time)
};
class CNameIndex
{
public:
CNameIndex();
~CNameIndex();
public:
int insert(const CIndexInfo& file);
int remove(const CIndexInfo& file);
public:
int synchronize(char* buffer, int& len);
int desynchronize(const char* buffer, const int& len);
private:
map<string, CIndexInfo> m_mFileList;
};
#endif