Logo Search packages:      
Sourcecode: rosegarden version File versions  Download package

/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */

    A sequencer and musical notation editor.
    Copyright 2000-2011 the Rosegarden development team.
    See the AUTHORS file for more details.

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
    published by the Free Software Foundation; either version 2 of the
    License, or (at your option) any later version.  See the file
    COPYING included with this distribution for more information.


#include <QtGlobal>
#include <vector>

namespace Rosegarden 

/// Flag indicating that a refresh is needed.
 * This is a flag indicating that a refresh may be required for
 * some part of the user interface.  The implementation is
 * a simple wrapper around a bool.
 * See SegmentRefreshStatus which derives from this and adds a
 * time range.
 * See RefreshStatusArray which supports multiple observers.
00037 class RefreshStatus
    RefreshStatus() : m_needsRefresh(false) {}

    bool needsRefresh() { return m_needsRefresh; }
    void setNeedsRefresh(bool s) { m_needsRefresh = s; }

    bool m_needsRefresh;

/// Polled notification mechanism.
 * This supports providing refresh notification flags (e.g. RefreshStatus)
 * for a number of observers.  An observer can check the flag
 * periodically and perform a refresh when the flag is set.  Then they
 * can clear the flag.
 * Polling mechanisms such as this are useful when changes to an underlying
 * data object are fast and frequent but the observers would like to update
 * at a slower pace (usually to save CPU time).
 * See Composition which instantiates this with RefreshStatus and
 * Segment which instantiates this with SegmentRefreshStatus.
template<class RS>
00064 class RefreshStatusArray
    /// Creates a new flag for an observer.  Use the returned ID when calling
    /// getRefreshStatus() to check whether a refresh is needed.
    unsigned int getNewRefreshStatusId();

    /// Returns the number of observers.
00072     size_t size() { return m_refreshStatuses.size(); }

    /// Returns the refresh status object for a particular observer.
00075     RS& getRefreshStatus(unsigned int id)
        Q_ASSERT_X(id < m_refreshStatuses.size(),
                   "ID out of bounds");

        return m_refreshStatuses[id];

    /// Sets all the refresh flags to true.
    /// Rename: needsRefresh()
    void updateRefreshStatuses();

    std::vector<RS> m_refreshStatuses;

template<class RS>
00094 unsigned int RefreshStatusArray<RS>::getNewRefreshStatusId()
    unsigned int res = m_refreshStatuses.size() - 1;
    return res;

// Defined in Composition.cpp.
void breakpoint();

template<class RS>
00105 void RefreshStatusArray<RS>::updateRefreshStatuses()
    // breakpoint(); // for debug purposes, so one can set a breakpoint
    // in this template code (set it in breakpoint() itself which is in
    // Composition.cpp).

    // Set all the refresh flags to true.
    for(unsigned int i = 0; i < m_refreshStatuses.size(); ++i)



Generated by  Doxygen 1.6.0   Back to index