1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_MODEL_SLSPAGEENUMERATION_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_MODEL_SLSPAGEENUMERATION_HXX
23 #include <sal/types.h>
27 #include "model/SlsEnumeration.hxx"
28 #include "model/SlsSharedPageDescriptor.hxx"
30 #include <boost/function.hpp>
33 namespace sd
{ namespace slidesorter
{ namespace model
{
35 class SlideSorterModel
;
37 /** Public class of page enumerations that delegates its calls to an
38 implementation object that can filter pages by using a given predicate.
40 @see PageEnumerationProvider
41 The PageEnumerationProvider has methods for creating different types
45 : public Enumeration
<SharedPageDescriptor
>
48 /** Create a new page enumeration that enumerates a subset of the pages
51 The new page enumeration enumerates the pages of this model.
53 This predicate determines which pages to include in the
54 enumeration. Pages for which rPredicate returns <FALSE/> are
57 typedef ::boost::function
<bool(const SharedPageDescriptor
&)> PagePredicate
;
58 static PageEnumeration
Create (
59 const SlideSorterModel
& rModel
,
60 const PagePredicate
& rPredicate
);
62 /** This copy constructor creates a copy of the given enumeration.
64 PageEnumeration (const PageEnumeration
& rEnumeration
);
66 virtual ~PageEnumeration();
68 /** Create a new enumeration object. The ownership of the
69 implementation object goes to the new object. Use this copy
70 constructor only when you know what you are doing. When in doubt,
71 use the one argument version.
73 When <TRUE/> is given this constructor behaves exactly like its
74 one argument version. When <FALSE/> is given then the
75 implementation object is not copied but moved from the given
76 enumeration to the newly created one. The given enumeration
79 PageEnumeration (PageEnumeration
& rEnumeration
, bool bCloneImpl
);
81 /** Create and return an exact copy of the called object.
83 virtual ::std::unique_ptr
<Enumeration
<SharedPageDescriptor
> > Clone() SAL_OVERRIDE
;
85 PageEnumeration
& operator= (const PageEnumeration
& rEnumeration
);
87 /** Return <TRUE/> when the enumeration has more elements, i.e. it is
88 save to call GetNextElement() at least one more time.
90 virtual bool HasMoreElements() const SAL_OVERRIDE
;
92 /** Return the next element of the enumeration. Call the
93 HasMoreElements() before to make sure that there exists at least one
94 more element. Calling this method with HasMoreElements() returning
97 virtual SharedPageDescriptor
GetNextElement() SAL_OVERRIDE
;
99 /** Rewind the enumeration so that the next call to GetNextElement()
100 will return its first element.
102 virtual void Rewind() SAL_OVERRIDE
;
105 /// Implementation object.
106 ::std::unique_ptr
<Enumeration
<SharedPageDescriptor
> > mpImpl
;
108 /** This constructor expects an implementation object that holds
109 the predicate that filters the pages.
111 PageEnumeration (::std::unique_ptr
<Enumeration
<SharedPageDescriptor
> > && pImpl
);
113 // Default constructor not implemented.
117 } } } // end of namespace ::sd::slidesorter::model
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */