headers/bsd: Add sys/queue.h.
[haiku.git] / src / kits / debugger / files / FileManager.h
blob7c47a98a4ba7a95e9c5ea0c65a8bd6ddf818baaf
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2013, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
5 */
6 #ifndef FILE_MANAGER_H
7 #define FILE_MANAGER_H
9 #include <map>
11 #include <Locker.h>
12 #include <Message.h>
13 #include <String.h>
15 #include <util/DoublyLinkedList.h>
16 #include <util/OpenHashTable.h>
19 class LocatableEntry;
20 class LocatableFile;
21 class SourceFile;
22 class TeamFileManagerSettings;
25 class FileManager {
26 public:
27 FileManager();
28 ~FileManager();
30 status_t Init(bool targetIsLocal);
32 bool Lock() { return fLock.Lock(); }
33 void Unlock() { fLock.Unlock(); }
35 LocatableFile* GetTargetFile(const BString& directory,
36 const BString& relativePath);
37 // returns a reference
38 LocatableFile* GetTargetFile(const BString& path);
39 // returns a reference
40 void TargetEntryLocated(const BString& path,
41 const BString& locatedPath);
43 LocatableFile* GetSourceFile(const BString& directory,
44 const BString& relativePath);
45 // returns a reference
46 LocatableFile* GetSourceFile(const BString& path);
47 // returns a reference
48 status_t SourceEntryLocated(const BString& path,
49 const BString& locatedPath);
51 status_t LoadSourceFile(LocatableFile* file,
52 SourceFile*& _sourceFile);
53 // returns a reference
55 status_t LoadLocationMappings(TeamFileManagerSettings*
56 settings);
57 status_t SaveLocationMappings(TeamFileManagerSettings*
58 settings);
60 private:
61 struct EntryPath;
62 struct EntryHashDefinition;
63 class Domain;
64 struct SourceFileEntry;
65 struct SourceFileHashDefinition;
67 typedef BOpenHashTable<EntryHashDefinition> LocatableEntryTable;
68 typedef DoublyLinkedList<LocatableEntry> DeadEntryList;
69 typedef BOpenHashTable<SourceFileHashDefinition> SourceFileTable;
70 typedef std::map<BString, BString> LocatedFileMap;
72 friend struct SourceFileEntry;
73 // for gcc 2
75 private:
76 SourceFileEntry* _LookupSourceFile(const BString& path);
77 void _SourceFileUnused(SourceFileEntry* entry);
78 bool _LocateFileIfMapped(const BString& sourcePath,
79 LocatableFile* file);
81 private:
82 BLocker fLock;
83 Domain* fTargetDomain;
84 Domain* fSourceDomain;
85 SourceFileTable* fSourceFiles;
87 LocatedFileMap fSourceLocationMappings;
92 #endif // FILE_MANAGER_H