/usr/include/bakery-2.6/bakery/View/View_Composite.h is in libbakery-2.6-dev 2.6.3-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | /*
* Copyright 2000 Murray Cumming
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef BAKERY_VIEW_COMPOSITE_H
#define BAKERY_VIEW_COMPOSITE_H
#include "bakery/View/View.h"
#include <vector>
#include <algorithm> //For std::find
namespace Bakery
{
/** This View delegates to sub-views.
* It is very simplistic - maybe your View should be more intelligent.
*/
template< class T_Document >
class View_Composite : public View<T_Document>
{
public:
View_Composite()
{
}
virtual ~View_Composite()
{
}
typedef View<T_Document> type_view;
virtual void add_view(type_view* pView)
{
//Ensure that the view has the same document:
//This should be unnecessary.
if(pView)
{
pView->set_document(View<T_Document>::get_document());
//Add it to the list of child views:
m_vecViews.push_back(pView);
}
}
virtual void remove_view(type_view* pView)
{
typename type_vecViews::iterator iter = std::find(m_vecViews.begin(), m_vecViews.end(), pView);
if(iter != m_vecViews.end())
m_vecViews.erase(iter);
}
virtual void set_document(T_Document* pDocument)
{
//Call base class:
View<T_Document>::set_document(pDocument);
//Change the document in the child views.
for(typename type_vecViews::iterator iter = m_vecViews.begin(); iter != m_vecViews.end(); iter++)
{
type_view* pView = *iter;
if(pView)
pView->set_document(pDocument);
}
}
virtual void load_from_document()
{
//Delegate to the child views:
for(typename type_vecViews::iterator iter = m_vecViews.begin(); iter != m_vecViews.end(); iter++)
{
type_view* pView = *iter;
if(pView)
pView->load_from_document();
}
}
virtual void save_to_document()
{
//Delegate to the child views:
for(typename type_vecViews::iterator iter = m_vecViews.begin(); iter != m_vecViews.end(); iter++)
{
type_view* pView = *iter;
if(pView)
pView->save_to_document();
}
}
protected:
typedef std::vector<type_view*> type_vecViews;
type_vecViews m_vecViews;
};
} //namespace
#endif
|