E-MailRelay

gfilterfactory.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2021 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file gfilterfactory.h
19///
20
21#ifndef G_SMTP_FILTER_FACTORY_H
22#define G_SMTP_FILTER_FACTORY_H
23
24#include "gdef.h"
25#include "gfilter.h"
26#include "gfilestore.h"
27#include "gfactoryparser.h"
28#include "gexceptionsink.h"
29#include <string>
30#include <utility>
31
32 namespace GSmtp
33{
34 class FilterFactory ;
35 class FilterFactoryFileStore ;
36}
37
38//| \class GSmtp::FilterFactory
39/// A factory interface for GSmtp::Filter message processors.
40///
41 class GSmtp::FilterFactory
42{
43 public:
44 virtual std::unique_ptr<Filter> newFilter( GNet::ExceptionSink ,
45 bool server_side , const std::string & identifier , unsigned int timeout ) = 0 ;
46 ///< Returns a Filter on the heap. The identifier
47 ///< is normally prefixed with a processor type, or it
48 ///< is the file system path of an exectuable.
49
50 virtual ~FilterFactory() = default ;
51 ///< Destructor.
52
53 static std::string check( const std::string & identifier ) ;
54 ///< Checks an identifier. Returns an empty string if okay,
55 ///< or a diagnostic reason string.
56} ;
57
58//| \class GSmtp::FilterFactoryFileStore
59/// A filter factory that holds a GSmtp::FileStore reference so that
60/// it can instantiate filters that operate on message files.
61///
62 class GSmtp::FilterFactoryFileStore : public FilterFactory
63{
64 public:
65 explicit FilterFactoryFileStore( FileStore & ) ;
66 ///< Constructor. The FileStore reference is retained and passed
67 ///< to new filter objects so that they can derive the paths of
68 ///< the content and envelope files that they process.
69
70 std::unique_ptr<Filter> newFilter( GNet::ExceptionSink ,
71 bool server_side , const std::string & identifier , unsigned int timeout ) override ;
72
73 private:
74 FileStore & m_file_store ;
75} ;
76
77 inline
78std::string GSmtp::FilterFactory::check( const std::string & identifier )
79{
80 return FactoryParser::check( identifier , true ) ;
81}
82
83#endif
GNet::ExceptionSink
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
Definition: gexceptionsink.h:100
GSmtp::FactoryParser::check
static std::string check(const std::string &identifier, bool allow_spam)
Parses and checks an identifier.
Definition: gfactoryparser.cpp:63
GSmtp::FileStore
A concrete implementation of the MessageStore interface dealing in paired flat files.
Definition: gfilestore.h:58
GSmtp::FilterFactoryFileStore
A filter factory that holds a GSmtp::FileStore reference so that it can instantiate filters that oper...
Definition: gfilterfactory.h:63
GSmtp::FilterFactoryFileStore::FilterFactoryFileStore
FilterFactoryFileStore(FileStore &)
Constructor.
Definition: gfilterfactory.cpp:31
GSmtp::FilterFactoryFileStore::newFilter
std::unique_ptr< Filter > newFilter(GNet::ExceptionSink, bool server_side, const std::string &identifier, unsigned int timeout) override
Returns a Filter on the heap.
Definition: gfilterfactory.cpp:36
GSmtp::FilterFactory
A factory interface for GSmtp::Filter message processors.
Definition: gfilterfactory.h:42
GSmtp::FilterFactory::check
static std::string check(const std::string &identifier)
Checks an identifier.
Definition: gfilterfactory.h:78
GSmtp::FilterFactory::newFilter
virtual std::unique_ptr< Filter > newFilter(GNet::ExceptionSink, bool server_side, const std::string &identifier, unsigned int timeout)=0
Returns a Filter on the heap.
GSmtp::FilterFactory::~FilterFactory
virtual ~FilterFactory()=default
Destructor.
gexceptionsink.h
gfactoryparser.h
gfilestore.h
gfilter.h
GSmtp
SMTP and message-store classes.
Definition: gadminserver.h:39