2 * Copyright 2010, Haiku.
3 * Distributed under the terms of the MIT License.
6 * Clemens Zeidler <haiku@clemens-zeidler.de>
8 #ifndef INDEX_SERVER_ADD_ON_H
9 #define INDEX_SERVER_ADD_ON_H
15 #include <ObjectList.h>
19 #include "Referenceable.h"
22 class analyser_settings
{
27 //! the volume is scanned form 0 to syncPosition, from
28 //! syncPosition to watchingStart the volume is not scanned
29 bigtime_t syncPosition
;
30 bigtime_t watchingStart
;
31 bigtime_t watchingPosition
;
38 /*! Thread safe class to sync settings between different FileAnalyser. For
39 example the watcher analyser and the catch up analyser. Because the lock
40 overhead use it only when necessary or use a cached analyser_settings if
42 class AnalyserSettings
: public BReferenceable
{
44 AnalyserSettings(const BString
& name
,
45 const BVolume
& volume
);
47 const BString
& Name() { return fName
; }
48 const BVolume
& Volume() { return fVolume
; }
53 analyser_settings
RawSettings();
56 void SetCatchUpEnabled(bool enabled
);
57 void SetSyncPosition(bigtime_t time
);
58 void SetWatchingStart(bigtime_t time
);
59 void SetWatchingPosition(bigtime_t time
);
61 bool CatchUpEnabled();
62 bigtime_t
SyncPosition();
63 bigtime_t
WatchingStart();
64 bigtime_t
WatchingPosition();
69 BLocker fSettingsLock
;
70 analyser_settings fAnalyserSettings
;
76 FileAnalyser(const BString
& name
,
77 const BVolume
& volume
);
78 virtual ~FileAnalyser() {}
80 void SetSettings(AnalyserSettings
* settings
);
81 AnalyserSettings
* Settings() const;
82 const analyser_settings
& CachedSettings() const;
83 void UpdateSettingsCache();
85 const BString
& Name() const { return fName
; }
86 const BVolume
& Volume() const { return fVolume
; }
88 virtual status_t
InitCheck() = 0;
90 virtual void AnalyseEntry(const entry_ref
& ref
) = 0;
91 virtual void DeleteEntry(const entry_ref
& ref
) { }
92 virtual void MoveEntry(const entry_ref
& oldRef
,
93 const entry_ref
& newRef
) { }
94 //! If the indexer send a bunch of entry this indicates that the last one
96 virtual void LastEntry() { }
100 BReference
<AnalyserSettings
> fAnalyserSettings
;
101 analyser_settings fCachedSettings
;
107 typedef BObjectList
<FileAnalyser
> FileAnalyserList
;
110 class IndexServerAddOn
{
112 IndexServerAddOn(image_id id
, const char* name
)
119 virtual ~IndexServerAddOn() {}
121 image_id
ImageId() { return fImageId
; }
122 BString
Name() { return fName
; }
124 virtual FileAnalyser
* CreateFileAnalyser(const BVolume
& volume
) = 0;
132 typedef IndexServerAddOn
* create_index_server_addon(image_id id
,