xref: /glogg/src/viewinterface.h (revision b423cd88e57c52bc4c23c685b57ee676012b10f4)
1 /*
2  * Copyright (C) 2013, 2014 Nicolas Bonnefon and other contributors
3  *
4  * This file is part of glogg.
5  *
6  * glogg is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * glogg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with glogg.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef VIEWINTERFACE_H
21 #define VIEWINTERFACE_H
22 
23 #include <memory>
24 
25 class LogData;
26 class LogFilteredData;
27 class SavedSearches;
28 class QuickFindPattern;
29 
30 // ViewInterface represents a high-level view on a log file.
31 class ViewInterface {
32   public:
33     // Set the log data and filtered data to associate to this view
34     // Ownership stay with the caller but is shared
35     void setData( std::shared_ptr<LogData> log_data,
36             std::shared_ptr<LogFilteredData> filtered_data )
37     { doSetData( log_data, filtered_data ); }
38 
39     // Set the (shared) quickfind pattern object
40     void setQuickFindPattern( std::shared_ptr<QuickFindPattern> qfp )
41     { doSetQuickFindPattern( qfp ); }
42 
43     // Set the (shared) search history object
44     void setSavedSearches( std::shared_ptr<SavedSearches> saved_searches )
45     { doSetSavedSearches( saved_searches ); }
46 
47     // For save/restore of the context
48     /*
49     virtual void setViewContext( const ViewContextInterface& view_context ) = 0;
50     virtual ViewContextInterface& getViewContext( void ) = 0;
51     */
52 
53     // To allow polymorphic destruction
54     virtual ~ViewInterface() {}
55 
56   protected:
57     // Virtual functions (using NVI)
58     virtual void doSetData( std::shared_ptr<LogData> log_data,
59             std::shared_ptr<LogFilteredData> filtered_data ) = 0;
60     virtual void doSetQuickFindPattern(
61             std::shared_ptr<QuickFindPattern> qfp ) = 0;
62     virtual void doSetSavedSearches(
63             std::shared_ptr<SavedSearches> saved_searches ) = 0;
64 };
65 #endif
66