Update git submodules
[LibreOffice.git] / sd / source / ui / slidesorter / inc / model / SlsPageEnumeration.hxx
blob6901a9ff16c93b3bdad979153359b6a35410228a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <model/SlsEnumeration.hxx>
23 #include <model/SlsSharedPageDescriptor.hxx>
25 #include <functional>
26 #include <memory>
28 namespace sd::slidesorter::model
30 class SlideSorterModel;
32 /** Public class of page enumerations that delegates its calls to an
33 implementation object that can filter pages by using a given predicate.
35 @see PageEnumerationProvider
36 The PageEnumerationProvider has methods for creating different types
37 of page enumerations.
39 class PageEnumeration final : public Enumeration<SharedPageDescriptor>
41 public:
42 /** Create a new page enumeration that enumerates a subset of the pages
43 of the given model.
44 @param rModel
45 The new page enumeration enumerates the pages of this model.
46 @param rPredicate
47 This predicate determines which pages to include in the
48 enumeration. Pages for which rPredicate returns <FALSE/> are
49 exclude.
51 typedef ::std::function<bool(const SharedPageDescriptor&)> PagePredicate;
52 static PageEnumeration Create(const SlideSorterModel& rModel, const PagePredicate& rPredicate);
54 /** This copy constructor creates a copy of the given enumeration.
56 PageEnumeration(const PageEnumeration& rEnumeration);
58 virtual ~PageEnumeration() override;
60 /** Create and return an exact copy of the called object.
62 virtual ::std::unique_ptr<Enumeration<SharedPageDescriptor>> Clone() override;
64 PageEnumeration& operator=(const PageEnumeration& rEnumeration);
66 /** Return <TRUE/> when the enumeration has more elements, i.e. it is
67 save to call GetNextElement() at least one more time.
69 virtual bool HasMoreElements() const override;
71 /** Return the next element of the enumeration. Call the
72 HasMoreElements() before to make sure that there exists at least one
73 more element. Calling this method with HasMoreElements() returning
74 <FALSE/> is an error.
76 virtual SharedPageDescriptor GetNextElement() override;
78 /** Rewind the enumeration so that the next call to GetNextElement()
79 will return its first element.
81 virtual void Rewind() override;
83 private:
84 /// Implementation object.
85 ::std::unique_ptr<Enumeration<SharedPageDescriptor>> mpImpl;
87 /** This constructor expects an implementation object that holds
88 the predicate that filters the pages.
90 PageEnumeration(::std::unique_ptr<Enumeration<SharedPageDescriptor>>&& pImpl);
93 } // end of namespace ::sd::slidesorter::model
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */