xref: /glogg/src/viewinterface.h (revision a44d09bc709514bfc9e2b6b4e435e83e8a36868a)
1d96f3f21SNicolas Bonnefon /*
2b423cd88SNicolas Bonnefon  * Copyright (C) 2013, 2014 Nicolas Bonnefon and other contributors
3d96f3f21SNicolas Bonnefon  *
4d96f3f21SNicolas Bonnefon  * This file is part of glogg.
5d96f3f21SNicolas Bonnefon  *
6d96f3f21SNicolas Bonnefon  * glogg is free software: you can redistribute it and/or modify
7d96f3f21SNicolas Bonnefon  * it under the terms of the GNU General Public License as published by
8d96f3f21SNicolas Bonnefon  * the Free Software Foundation, either version 3 of the License, or
9d96f3f21SNicolas Bonnefon  * (at your option) any later version.
10d96f3f21SNicolas Bonnefon  *
11d96f3f21SNicolas Bonnefon  * glogg is distributed in the hope that it will be useful,
12d96f3f21SNicolas Bonnefon  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13d96f3f21SNicolas Bonnefon  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14d96f3f21SNicolas Bonnefon  * GNU General Public License for more details.
15d96f3f21SNicolas Bonnefon  *
16d96f3f21SNicolas Bonnefon  * You should have received a copy of the GNU General Public License
17d96f3f21SNicolas Bonnefon  * along with glogg.  If not, see <http://www.gnu.org/licenses/>.
18d96f3f21SNicolas Bonnefon  */
19d96f3f21SNicolas Bonnefon 
20d96f3f21SNicolas Bonnefon #ifndef VIEWINTERFACE_H
21d96f3f21SNicolas Bonnefon #define VIEWINTERFACE_H
22d96f3f21SNicolas Bonnefon 
23d96f3f21SNicolas Bonnefon #include <memory>
24d96f3f21SNicolas Bonnefon 
25d96f3f21SNicolas Bonnefon class LogData;
26d96f3f21SNicolas Bonnefon class LogFilteredData;
271b5e406eSNicolas Bonnefon class SavedSearches;
28b423cd88SNicolas Bonnefon class QuickFindPattern;
29d96f3f21SNicolas Bonnefon 
30*a44d09bcSNicolas Bonnefon // ViewContextInterface represents the private information
31*a44d09bcSNicolas Bonnefon // the concrete view will be able to save and restore.
32*a44d09bcSNicolas Bonnefon // It can be marshalled to persistent storage.
33*a44d09bcSNicolas Bonnefon class ViewContextInterface {
34*a44d09bcSNicolas Bonnefon   public:
~ViewContextInterface()35*a44d09bcSNicolas Bonnefon     virtual ~ViewContextInterface() {}
36*a44d09bcSNicolas Bonnefon 
37*a44d09bcSNicolas Bonnefon     virtual std::string toString() const = 0;
38*a44d09bcSNicolas Bonnefon };
39*a44d09bcSNicolas Bonnefon 
40d96f3f21SNicolas Bonnefon // ViewInterface represents a high-level view on a log file.
41*a44d09bcSNicolas Bonnefon // This a pure virtual class (interface) which is subclassed
42*a44d09bcSNicolas Bonnefon // for each type of view.
43d96f3f21SNicolas Bonnefon class ViewInterface {
44d96f3f21SNicolas Bonnefon   public:
45039481acSNicolas Bonnefon     // Set the log data and filtered data to associate to this view
46d96f3f21SNicolas Bonnefon     // Ownership stay with the caller but is shared
setData(std::shared_ptr<LogData> log_data,std::shared_ptr<LogFilteredData> filtered_data)47039481acSNicolas Bonnefon     void setData( std::shared_ptr<LogData> log_data,
48039481acSNicolas Bonnefon             std::shared_ptr<LogFilteredData> filtered_data )
49039481acSNicolas Bonnefon     { doSetData( log_data, filtered_data ); }
50d96f3f21SNicolas Bonnefon 
51b423cd88SNicolas Bonnefon     // Set the (shared) quickfind pattern object
setQuickFindPattern(std::shared_ptr<QuickFindPattern> qfp)52b423cd88SNicolas Bonnefon     void setQuickFindPattern( std::shared_ptr<QuickFindPattern> qfp )
53b423cd88SNicolas Bonnefon     { doSetQuickFindPattern( qfp ); }
54b423cd88SNicolas Bonnefon 
551b5e406eSNicolas Bonnefon     // Set the (shared) search history object
setSavedSearches(std::shared_ptr<SavedSearches> saved_searches)561b5e406eSNicolas Bonnefon     void setSavedSearches( std::shared_ptr<SavedSearches> saved_searches )
571b5e406eSNicolas Bonnefon     { doSetSavedSearches( saved_searches ); }
581b5e406eSNicolas Bonnefon 
59d96f3f21SNicolas Bonnefon     // For save/restore of the context
setViewContext(const char * view_context)60*a44d09bcSNicolas Bonnefon     void setViewContext( const char* view_context )
61*a44d09bcSNicolas Bonnefon     { doSetViewContext( view_context ); }
62*a44d09bcSNicolas Bonnefon     // (returned object ownership is transferred to the caller)
context(void)63*a44d09bcSNicolas Bonnefon     std::shared_ptr<const ViewContextInterface> context( void ) const
64*a44d09bcSNicolas Bonnefon     { return doGetViewContext(); }
65d96f3f21SNicolas Bonnefon 
66f0708ca8SNicolas Bonnefon     // To allow polymorphic destruction
~ViewInterface()67f0708ca8SNicolas Bonnefon     virtual ~ViewInterface() {}
68d96f3f21SNicolas Bonnefon 
69d96f3f21SNicolas Bonnefon   protected:
70d96f3f21SNicolas Bonnefon     // Virtual functions (using NVI)
71039481acSNicolas Bonnefon     virtual void doSetData( std::shared_ptr<LogData> log_data,
72039481acSNicolas Bonnefon             std::shared_ptr<LogFilteredData> filtered_data ) = 0;
73b423cd88SNicolas Bonnefon     virtual void doSetQuickFindPattern(
74b423cd88SNicolas Bonnefon             std::shared_ptr<QuickFindPattern> qfp ) = 0;
751b5e406eSNicolas Bonnefon     virtual void doSetSavedSearches(
761b5e406eSNicolas Bonnefon             std::shared_ptr<SavedSearches> saved_searches ) = 0;
77*a44d09bcSNicolas Bonnefon     virtual void doSetViewContext(
78*a44d09bcSNicolas Bonnefon             const char* view_context ) = 0;
79*a44d09bcSNicolas Bonnefon     virtual std::shared_ptr<const ViewContextInterface>
80*a44d09bcSNicolas Bonnefon         doGetViewContext( void ) const = 0;
81d96f3f21SNicolas Bonnefon };
82d96f3f21SNicolas Bonnefon #endif
83