<commit_before>/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#include <MDebug>
#include <MDismissEvent>
#include <QChildEvent>
#include <QGestureEvent>
#include <QTapAndHoldGesture>
#include <QGraphicsSceneContextMenuEvent>
#include <QTimer>
#include "mscenewindow.h"
#include "mscenewindowmodel.h"
#include "mscenewindow_p.h"
#include "mscene.h"
#include "mscenemanager.h"
#include "mscenemanager_p.h"
#include "mapplication.h"
#include "mwidgetview.h"
#include "mwindow.h"
#include "mdialog.h"
#include "mcancelevent.h"

#include "mwidgetcreator.h"
M_REGISTER_WIDGET_NO_CREATE(MSceneWindow)

MSceneWindowPrivate::MSceneWindowPrivate()
        : windowType(MSceneWindow::PlainSceneWindow),
        policy(MSceneWindow::KeepWhenDone),
        sceneWindowState(MSceneWindow::Disappeared),
        managedManually(false),
        dismissed(false),
        waitingForContextMenuEvent(false),
        effect(0),
        appearanceAnimation(0),
        disappearanceAnimation(0),
        queuedTransition(0),
        sceneManager(0)
{
}

void MSceneWindowPrivate::setSceneWindowState(MSceneWindow::SceneWindowState newState)
{
    Q_Q(MSceneWindow);

    if (newState == sceneWindowState)
        return;

    MSceneWindow::SceneWindowState oldState = sceneWindowState;

    sceneWindowState = newState;

    emit q->sceneWindowStateChanged(newState, oldState);

    switch (newState) {
        case MSceneWindow::Appearing:
            emit q->appearing();
            break;

        case MSceneWindow::Appeared:
            emit q->appeared();
            break;

        case MSceneWindow::Disappearing:
            emit q->disappearing();
            break;

        case MSceneWindow::Disappeared:
            emit q->disappeared();
            break;

        default:
            break;
    }

}

MSceneWindow::MSceneWindow(QGraphicsItem *parent) :
        MWidgetController(new MSceneWindowPrivate, new MSceneWindowModel, parent)
{
    Q_D(MSceneWindow);

    d->windowType = PlainSceneWindow;
    grabGesture(Qt::TapAndHoldGesture);
}

MSceneWindow::MSceneWindow(MSceneWindowPrivate *dd, MSceneWindowModel *model, MSceneWindow::WindowType windowType, const QString &viewType, QGraphicsItem *parent) :
        MWidgetController(dd, model, parent)
{
    Q_D(MSceneWindow);
    setViewType(viewType);

    d->windowType = windowType;
    grabGesture(Qt::TapAndHoldGesture);
}

MSceneWindow::~MSceneWindow()
{
    if (sceneManager())
        sceneManager()->d_func()->removeSceneWindow(this);
}

MSceneWindow::WindowType MSceneWindow::windowType() const
{
    Q_D(const MSceneWindow);
    return d->windowType;
}

MSceneWindow::DeletionPolicy MSceneWindow::deletionPolicy() const
{
    Q_D(const MSceneWindow);
    return d->policy;
}

bool MSceneWindow::isManagedManually() const
{
    Q_D(const MSceneWindow);
    return d->managedManually;
}

void MSceneWindow::setManagedManually(bool managedManually)
{
    Q_D(MSceneWindow);
    d->managedManually = managedManually;
}

MSceneWindow::SceneWindowState MSceneWindow::sceneWindowState() const
{
    Q_D(const MSceneWindow);
    return d->sceneWindowState;
}

void MSceneWindow::appear(QGraphicsScene *scene, MSceneWindow::DeletionPolicy policy)
{
    if (!scene) {
        mWarning("MSceneWindow") << Q_FUNC_INFO << "NULL scene.";
        return;
    }

    MScene *mScene = qobject_cast<MScene *>(scene);
    if (!mScene || !mScene->sceneManager()) {
        mWarning("MSceneWindow") << Q_FUNC_INFO << "scene has no scene manager.";
        return;
    }

    if (view()) {
        if (model()->disappearTimeout() != 0) {
            QTimer::singleShot(model()->disappearTimeout(), this, SLOT(disappear()));
        }
    }

    mScene->sceneManager()->appearSceneWindow(this, policy);
}

void MSceneWindow::appear(MWindow *window, MSceneWindow::DeletionPolicy policy)
{
    if (!window) {
        // Remove this behavior along with the deprecated
        // MSceneWindow::appear(DeletionPolicy);
        window = MApplication::activeWindow();
        if (!window) {
            mWarning("MSceneWindow")
                    << "Construct and show MWindow before showing a scene window";
            return;
        }
    }

    // Force the creation of a scene manager (and scene) if none was
    // set to this window yet.
    //
    // Therefore:
    //    sceneWindow->appear(window);
    // Will yield a different result than:
    //    sceneWindow->appear(window->scene());
    // If window didn't have a scene and scene manager.
    window->sceneManager();

    appear(window->scene(), policy);
}

void MSceneWindow::appear(MSceneWindow::DeletionPolicy policy)
{
    mWarning("MSceneWindow") << Q_FUNC_INFO << "is deprecated."
             "Use appear(QGraphicsScene*) or appear(MWindow*) instead.";
    appear((MWindow *)0, policy);
}

void MSceneWindow::disappear()
{
    if (sceneManager())
        sceneManager()->disappearSceneWindow(this);
}

Qt::Alignment MSceneWindow::alignment() const
{
    Qt::Alignment result = 0;

    // There is an implicit property interface between the controller and the views
    // The controller expects the view to provide an "alignment" property.
    if (view()) {
        QVariant v = view()->property("alignment");
        if (v.isValid()) {
            result = Qt::Alignment(v.toInt());
        }
        else {
        }
    }

    if (layoutDirection() == Qt::RightToLeft) {
        if (result.testFlag(Qt::AlignLeft)) {
            result &= ~Qt::AlignLeft;
            result |= Qt::AlignRight;
        } else if (result.testFlag(Qt::AlignRight)) {
            result &= ~Qt::AlignRight;
            result |= Qt::AlignLeft;
        }
    }

    return result;
}

QPointF MSceneWindow::offset() const
{
    QPointF result;

    // There is an implicit property interface between the controller and the views
    // The controller expects the view to provide an "offset" property.
    if (view()) {
        QVariant v = view()->property("offset");
        if (v.isValid()) {
            result = v.toPointF();
        }
    } else {
        result = QPointF(0, 0);
    }

    return result;
}

bool MSceneWindow::dismiss()
{
    MDismissEvent dismissEvent;
    QApplication::sendEvent(this, &dismissEvent);

    if (!dismissEvent.isAccepted()) {
        return false;
    }

    if (sceneManager()) {
        sceneManager()->dismissSceneWindow(this);
    }

    return true;
}

void MSceneWindow::dismissEvent(MDismissEvent *event)
{
    event->accept();
}

void MSceneWindow::closeEvent(QCloseEvent *event)
{
    event->ignore();
    dismiss();
}

void MSceneWindow::tapAndHoldGestureEvent(QGestureEvent *event, QTapAndHoldGesture *gesture)
{
    Q_D(MSceneWindow);

    if (gesture->state() == Qt::GestureFinished) {

        QGraphicsSceneContextMenuEvent contextEvent(QEvent::GraphicsSceneContextMenu);
        contextEvent.setPos(gesture->hotSpot());
        contextEvent.setScenePos(gesture->hotSpot());
        contextEvent.setScreenPos(gesture->hotSpot().toPoint());

        d->waitingForContextMenuEvent = true;
        QApplication::sendEvent(scene(), &contextEvent);

        if (contextEvent.isAccepted() && d->waitingForContextMenuEvent) {
            //Event has been accepted by some widget on top of this scenewindow.
            if ((scene() == NULL) || (scene()->views().size() == 0)) {
                // If this widget has been removed from the scene and/or there
                // is no view, return
                return;
            }

            MCancelEvent cancelEvent;
            QList<QGraphicsItem*> affectedItems = scene()->items(gesture->hotSpot());
            QGraphicsItem *item = 0;

            foreach(item, affectedItems) {
                if (scene()->items().contains(item))
                    scene()->sendEvent(item, &cancelEvent);
            }
        }
        d->waitingForContextMenuEvent = false;

    }

    event->accept(gesture);
}

bool MSceneWindow::event(QEvent *event)
{
    Q_D(MSceneWindow);
    if (event->type() == MDismissEvent::eventType()) {
        dismissEvent(static_cast<MDismissEvent *>(event));
    } else if (event->type() == QEvent::GraphicsSceneContextMenu) {
        //Event was not accepted by any of our child widgets.
        //We need to accept it so that it doesn't propagate further and
        //clear the flag, so that the tap&hold gesture event handler
        //will know that the event wasn't delivered.
        if (d->waitingForContextMenuEvent) {
            event->accept();
            d->waitingForContextMenuEvent = false;
            return true;
        }
    } else if (event->type() == QEvent::ChildAdded) {
        QChildEvent *childEvent = static_cast<QChildEvent *>(event);
        if (childEvent->child()->objectName() == "_m_testBridge") {
            new MSceneWindowTestInterface(d, childEvent->child());
        }
    }

    return MWidgetController::event(event);
}

MSceneWindowTestInterface::MSceneWindowTestInterface(MSceneWindowPrivate *d, QObject *parent)
    : QObject(parent), d(d)
{
}

void MSceneWindowTestInterface::setSceneWindowState(MSceneWindow::SceneWindowState newState)
{
    d->setSceneWindowState(newState);
}
<commit_msg>Changes: made MSceneWindow to use ItemStopsClickFocusPropagation flag<commit_after>/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#include <MDebug>
#include <MDismissEvent>
#include <QChildEvent>
#include <QGestureEvent>
#include <QTapAndHoldGesture>
#include <QGraphicsSceneContextMenuEvent>
#include <QTimer>
#include "mscenewindow.h"
#include "mscenewindowmodel.h"
#include "mscenewindow_p.h"
#include "mscene.h"
#include "mscenemanager.h"
#include "mscenemanager_p.h"
#include "mapplication.h"
#include "mwidgetview.h"
#include "mwindow.h"
#include "mdialog.h"
#include "mcancelevent.h"

#include "mwidgetcreator.h"
M_REGISTER_WIDGET_NO_CREATE(MSceneWindow)

MSceneWindowPrivate::MSceneWindowPrivate()
        : windowType(MSceneWindow::PlainSceneWindow),
        policy(MSceneWindow::KeepWhenDone),
        sceneWindowState(MSceneWindow::Disappeared),
        managedManually(false),
        dismissed(false),
        waitingForContextMenuEvent(false),
        effect(0),
        appearanceAnimation(0),
        disappearanceAnimation(0),
        queuedTransition(0),
        sceneManager(0)
{
}

void MSceneWindowPrivate::setSceneWindowState(MSceneWindow::SceneWindowState newState)
{
    Q_Q(MSceneWindow);

    if (newState == sceneWindowState)
        return;

    MSceneWindow::SceneWindowState oldState = sceneWindowState;

    sceneWindowState = newState;

    emit q->sceneWindowStateChanged(newState, oldState);

    switch (newState) {
        case MSceneWindow::Appearing:
            emit q->appearing();
            break;

        case MSceneWindow::Appeared:
            emit q->appeared();
            break;

        case MSceneWindow::Disappearing:
            emit q->disappearing();
            break;

        case MSceneWindow::Disappeared:
            emit q->disappeared();
            break;

        default:
            break;
    }

}

MSceneWindow::MSceneWindow(QGraphicsItem *parent) :
        MWidgetController(new MSceneWindowPrivate, new MSceneWindowModel, parent)
{
    Q_D(MSceneWindow);

    d->windowType = PlainSceneWindow;
    grabGesture(Qt::TapAndHoldGesture);
    setFlag(QGraphicsItem::ItemStopsClickFocusPropagation);
}

MSceneWindow::MSceneWindow(MSceneWindowPrivate *dd, MSceneWindowModel *model, MSceneWindow::WindowType windowType, const QString &viewType, QGraphicsItem *parent) :
        MWidgetController(dd, model, parent)
{
    Q_D(MSceneWindow);
    setViewType(viewType);

    d->windowType = windowType;
    grabGesture(Qt::TapAndHoldGesture);
    setFlag(QGraphicsItem::ItemStopsClickFocusPropagation);
}

MSceneWindow::~MSceneWindow()
{
    if (sceneManager())
        sceneManager()->d_func()->removeSceneWindow(this);
}

MSceneWindow::WindowType MSceneWindow::windowType() const
{
    Q_D(const MSceneWindow);
    return d->windowType;
}

MSceneWindow::DeletionPolicy MSceneWindow::deletionPolicy() const
{
    Q_D(const MSceneWindow);
    return d->policy;
}

bool MSceneWindow::isManagedManually() const
{
    Q_D(const MSceneWindow);
    return d->managedManually;
}

void MSceneWindow::setManagedManually(bool managedManually)
{
    Q_D(MSceneWindow);
    d->managedManually = managedManually;
}

MSceneWindow::SceneWindowState MSceneWindow::sceneWindowState() const
{
    Q_D(const MSceneWindow);
    return d->sceneWindowState;
}

void MSceneWindow::appear(QGraphicsScene *scene, MSceneWindow::DeletionPolicy policy)
{
    if (!scene) {
        mWarning("MSceneWindow") << Q_FUNC_INFO << "NULL scene.";
        return;
    }

    MScene *mScene = qobject_cast<MScene *>(scene);
    if (!mScene || !mScene->sceneManager()) {
        mWarning("MSceneWindow") << Q_FUNC_INFO << "scene has no scene manager.";
        return;
    }

    if (view()) {
        if (model()->disappearTimeout() != 0) {
            QTimer::singleShot(model()->disappearTimeout(), this, SLOT(disappear()));
        }
    }

    mScene->sceneManager()->appearSceneWindow(this, policy);
}

void MSceneWindow::appear(MWindow *window, MSceneWindow::DeletionPolicy policy)
{
    if (!window) {
        // Remove this behavior along with the deprecated
        // MSceneWindow::appear(DeletionPolicy);
        window = MApplication::activeWindow();
        if (!window) {
            mWarning("MSceneWindow")
                    << "Construct and show MWindow before showing a scene window";
            return;
        }
    }

    // Force the creation of a scene manager (and scene) if none was
    // set to this window yet.
    //
    // Therefore:
    //    sceneWindow->appear(window);
    // Will yield a different result than:
    //    sceneWindow->appear(window->scene());
    // If window didn't have a scene and scene manager.
    window->sceneManager();

    appear(window->scene(), policy);
}

void MSceneWindow::appear(MSceneWindow::DeletionPolicy policy)
{
    mWarning("MSceneWindow") << Q_FUNC_INFO << "is deprecated."
             "Use appear(QGraphicsScene*) or appear(MWindow*) instead.";
    appear((MWindow *)0, policy);
}

void MSceneWindow::disappear()
{
    if (sceneManager())
        sceneManager()->disappearSceneWindow(this);
}

Qt::Alignment MSceneWindow::alignment() const
{
    Qt::Alignment result = 0;

    // There is an implicit property interface between the controller and the views
    // The controller expects the view to provide an "alignment" property.
    if (view()) {
        QVariant v = view()->property("alignment");
        if (v.isValid()) {
            result = Qt::Alignment(v.toInt());
        }
        else {
        }
    }

    if (layoutDirection() == Qt::RightToLeft) {
        if (result.testFlag(Qt::AlignLeft)) {
            result &= ~Qt::AlignLeft;
            result |= Qt::AlignRight;
        } else if (result.testFlag(Qt::AlignRight)) {
            result &= ~Qt::AlignRight;
            result |= Qt::AlignLeft;
        }
    }

    return result;
}

QPointF MSceneWindow::offset() const
{
    QPointF result;

    // There is an implicit property interface between the controller and the views
    // The controller expects the view to provide an "offset" property.
    if (view()) {
        QVariant v = view()->property("offset");
        if (v.isValid()) {
            result = v.toPointF();
        }
    } else {
        result = QPointF(0, 0);
    }

    return result;
}

bool MSceneWindow::dismiss()
{
    MDismissEvent dismissEvent;
    QApplication::sendEvent(this, &dismissEvent);

    if (!dismissEvent.isAccepted()) {
        return false;
    }

    if (sceneManager()) {
        sceneManager()->dismissSceneWindow(this);
    }

    return true;
}

void MSceneWindow::dismissEvent(MDismissEvent *event)
{
    event->accept();
}

void MSceneWindow::closeEvent(QCloseEvent *event)
{
    event->ignore();
    dismiss();
}

void MSceneWindow::tapAndHoldGestureEvent(QGestureEvent *event, QTapAndHoldGesture *gesture)
{
    Q_D(MSceneWindow);

    if (gesture->state() == Qt::GestureFinished) {

        QGraphicsSceneContextMenuEvent contextEvent(QEvent::GraphicsSceneContextMenu);
        contextEvent.setPos(gesture->hotSpot());
        contextEvent.setScenePos(gesture->hotSpot());
        contextEvent.setScreenPos(gesture->hotSpot().toPoint());

        d->waitingForContextMenuEvent = true;
        QApplication::sendEvent(scene(), &contextEvent);

        if (contextEvent.isAccepted() && d->waitingForContextMenuEvent) {
            //Event has been accepted by some widget on top of this scenewindow.
            if ((scene() == NULL) || (scene()->views().size() == 0)) {
                // If this widget has been removed from the scene and/or there
                // is no view, return
                return;
            }

            MCancelEvent cancelEvent;
            QList<QGraphicsItem*> affectedItems = scene()->items(gesture->hotSpot());
            QGraphicsItem *item = 0;

            foreach(item, affectedItems) {
                if (scene()->items().contains(item))
                    scene()->sendEvent(item, &cancelEvent);
            }
        }
        d->waitingForContextMenuEvent = false;

    }

    event->accept(gesture);
}

bool MSceneWindow::event(QEvent *event)
{
    Q_D(MSceneWindow);
    if (event->type() == MDismissEvent::eventType()) {
        dismissEvent(static_cast<MDismissEvent *>(event));
    } else if (event->type() == QEvent::GraphicsSceneContextMenu) {
        //Event was not accepted by any of our child widgets.
        //We need to accept it so that it doesn't propagate further and
        //clear the flag, so that the tap&hold gesture event handler
        //will know that the event wasn't delivered.
        if (d->waitingForContextMenuEvent) {
            event->accept();
            d->waitingForContextMenuEvent = false;
            return true;
        }
    } else if (event->type() == QEvent::ChildAdded) {
        QChildEvent *childEvent = static_cast<QChildEvent *>(event);
        if (childEvent->child()->objectName() == "_m_testBridge") {
            new MSceneWindowTestInterface(d, childEvent->child());
        }
    }

    return MWidgetController::event(event);
}

MSceneWindowTestInterface::MSceneWindowTestInterface(MSceneWindowPrivate *d, QObject *parent)
    : QObject(parent), d(d)
{
}

void MSceneWindowTestInterface::setSceneWindowState(MSceneWindow::SceneWindowState newState)
{
    d->setSceneWindowState(newState);
}
<|endoftext|>


<commit_before>#include "engine/config/precompiled.h"

#if (DEA_PLATFORM == DEA_PLATFORM_WINDOWS)
#include "engine/system/system.h"

#include <Windows.h>

DEA_START()

struct window_platform
{
	HWND hwnd;
	LPCWSTR name;
};

/* Translation unit locals */
namespace
{
	void close_windows(pod_vector<window> &windows, pod_vector<HWND> &windows_to_close)
	{
		for (auto window_to_close = windows_to_close.get_begin(); window_to_close != windows_to_close.get_end(); ++window_to_close)
		{
			for (auto window = windows.get_begin(); window != windows.get_end(); ++window)
			{
				if (*window_to_close == window->wnd->hwnd)
				{
					destroy_window(*window, false);
					windows.remove_it(window);

					break;
				}
			}
		}

		windows_to_close.clear();
	}

	/* Could use a better implementation */
	pod_vector<HWND> *windows_to_close = NULL;

	LRESULT CALLBACK wnd_proc(HWND hwnd, UINT umessage, WPARAM wparam, LPARAM lparam)
	{
		/* Unused parametres, can't get rid of these */
		(void *)hwnd;
		(void *)wparam;
		(void *)lparam;

		switch (umessage)
		{
		case WM_DESTROY:
		{
			/* We don't want to do anything as we manually destroy windows */
			return 0;
		}
		case WM_CLOSE:
		{
			if (windows_to_close)
			{
				windows_to_close->push_back(hwnd);
			}
			else
			{
				/* TODO: Localization/Error number */
				error_popup("Error closing a window", false);
			}

			return 0;
		}
		default:
		{
			return DefWindowProc(hwnd, umessage, wparam, lparam);
		}
		}
	}
}

void init_system_data()
{
	/* TODO: Memory manager */
	windows_to_close = new pod_vector<HWND>(1);
}

void destroy_system_data()
{
	/* TODO: Memory manager */
	if (windows_to_close)
		delete windows_to_close;
}

void error_popup(const char *msg, const bool kill_program)
{
	dea_assert(msg && "error_popup: msg is NULL");

	MessageBoxA(NULL, msg, kill_program ? "Fatal Error" : "Error", MB_OK | MB_ICONERROR);
	if (kill_program)
		ExitProcess(~(UINT)0);
}

/* TODO: Create a string class for the name */
void create_window(const uint width, const uint height, const float pos_x, const float pos_y, const wchar_t *name, const bool fullscreen, window &out_wnd)
{
	int position_x = 0;
	int position_y = 0;

	HINSTANCE hinstance = GetModuleHandle(NULL);

	/* TODO: Memory manager */
	out_wnd.wnd = new window_platform;
	out_wnd.wnd->hwnd = NULL;
	out_wnd.wnd->name = name;
	out_wnd.width = width;
	out_wnd.height = height;

	/* Setup the windows class with default settings */
	WNDCLASSEX wc;
	memset(&wc, 0, sizeof(wc));
	wc.cbSize = sizeof(wc);
	wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	wc.lpfnWndProc = wnd_proc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hinstance;
	wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
	wc.hIconSm = wc.hIcon;
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = name;

	// Register the window class.
	if (RegisterClassEx(&wc) == 0)
	{
		/* TODO: Localization/Error number */
		error_popup("Failed to register window class", true);
	}

	if (!fullscreen)
	{
		position_x = (int)((GetSystemMetrics(SM_CXSCREEN) - width) * pos_x);
		position_y = (int)((GetSystemMetrics(SM_CYSCREEN) - height) * pos_y);
	}
	else
	{
		DEVMODE screen_settings;
		memset(&screen_settings, 0, sizeof(screen_settings));
		screen_settings.dmSize = sizeof(screen_settings);
		screen_settings.dmPelsHeight = (unsigned long)height;
		screen_settings.dmPelsWidth = (unsigned long)width;
		screen_settings.dmBitsPerPel = 32;
		screen_settings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

		ChangeDisplaySettings(&screen_settings, CDS_FULLSCREEN);
	}

	DWORD style = WS_OVERLAPPEDWINDOW | WS_VISIBLE;
	DWORD exStyle = 0;

	// Create the window with the screen settings and get the handle to it.
	out_wnd.wnd->hwnd = CreateWindowEx(exStyle,
	                                  name,
	                                  name,
	                                  style,
	                                  position_x, position_y,
	                                  (int)width, (int)height,
	                                  NULL,
	                                  NULL,
	                                  hinstance,
	                                  NULL);

	if (out_wnd.wnd->hwnd == NULL)
	{
		/* TODO: Localization/Error number */
		error_popup("Failed to create a window", true);
	}

	ShowWindow(out_wnd.wnd->hwnd, SW_SHOW);
}

void destroy_window(window &wnd, const bool fullscreen)
{
	dea_assert(wnd.wnd && "destroy_window: Platform specific window pointer is NULL");

	if (fullscreen)
	{
		ChangeDisplaySettings(NULL, 0);
	}

	DestroyWindow(wnd.wnd->hwnd);
	wnd.wnd->hwnd = NULL;

	HINSTANCE hinstance = GetModuleHandle(NULL);
	UnregisterClass(wnd.wnd->name, hinstance);
	hinstance = NULL;

	/* TODO: Memory manager */
	delete wnd.wnd;
}

void focus_window(window &wnd)
{
	dea_assert(wnd.wnd && wnd.wnd->hwnd);
	SetForegroundWindow(wnd.wnd->hwnd);
	SetFocus(wnd.wnd->hwnd);
}

void run(pod_vector<window> &windows)
{
	MSG msg;
	ZeroMemory(&msg, sizeof(MSG));

	bool running = true;
	while (running)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

		if (msg.message == WM_QUIT)
		{
			running = false;
		}
		else
		{
			if (windows_to_close && !windows_to_close->empty())
			{
				close_windows(windows, *windows_to_close);

				if (windows.empty())
					running = false;
			}

			/* Run frame */
		}
	}
}

DEA_END()

#endif // DEA_PLATFORM == DEA_PLATFORM_WINDOWS<commit_msg>System: Add string_to_wchar function to system_windows.<commit_after>#include "engine/config/precompiled.h"

#if (DEA_PLATFORM == DEA_PLATFORM_WINDOWS)
#include "engine/system/system.h"

#include <Windows.h>

DEA_START()

struct window_platform
{
	HWND hwnd;
	LPCWSTR name;
};

/* Translation unit locals */
namespace
{
	void close_windows(pod_vector<window> &windows, pod_vector<HWND> &windows_to_close)
	{
		for (auto window_to_close = windows_to_close.get_begin(); window_to_close != windows_to_close.get_end(); ++window_to_close)
		{
			for (auto window = windows.get_begin(); window != windows.get_end(); ++window)
			{
				if (*window_to_close == window->wnd->hwnd)
				{
					destroy_window(*window, false);
					windows.remove_it(window);

					break;
				}
			}
		}

		windows_to_close.clear();
	}

	/* Could use a better implementation */
	pod_vector<HWND> *windows_to_close = NULL;

	LRESULT CALLBACK wnd_proc(HWND hwnd, UINT umessage, WPARAM wparam, LPARAM lparam)
	{
		/* Unused parametres, can't get rid of these */
		(void *)hwnd;
		(void *)wparam;
		(void *)lparam;

		switch (umessage)
		{
		case WM_DESTROY:
		{
			/* We don't want to do anything as we manually destroy windows */
			return 0;
		}
		case WM_CLOSE:
		{
			if (windows_to_close)
			{
				windows_to_close->push_back(hwnd);
			}
			else
			{
				/* TODO: Localization/Error number */
				error_popup("Error closing a window", false);
			}

			return 0;
		}
		default:
		{
			return DefWindowProc(hwnd, umessage, wparam, lparam);
		}
		}
	}

	/* This function allocates the buffer, freeing it is up to the
	 * caller */
	WCHAR *string_to_wchar(const string &str)
	{
		int required_buf_size = MultiByteToWideChar(CP_ACP|CP_UTF8, 0, str.c_str(), -1, 0, 0);
		/* TODO: Memory manager */
		WCHAR *result = (WCHAR *)malloc(sizeof(WCHAR) * required_buf_size);
		MultiByteToWideChar(CP_ACP|CP_UTF8, 0, str.c_str(), -1, result, required_buf_size);
		return result;
	}
}

void init_system_data()
{
	/* TODO: Memory manager */
	windows_to_close = new pod_vector<HWND>(1);
}

void destroy_system_data()
{
	/* TODO: Memory manager */
	if (windows_to_close)
		delete windows_to_close;
}

void error_popup(const char *msg, const bool kill_program)
{
	dea_assert(msg && "error_popup: msg is NULL");

	MessageBoxA(NULL, msg, kill_program ? "Fatal Error" : "Error", MB_OK | MB_ICONERROR);
	if (kill_program)
		ExitProcess(~(UINT)0);
}

/* TODO: Create a string class for the name */
void create_window(const uint width, const uint height, const float pos_x, const float pos_y, const wchar_t *name, const bool fullscreen, window &out_wnd)
{
	int position_x = 0;
	int position_y = 0;

	HINSTANCE hinstance = GetModuleHandle(NULL);

	/* TODO: Memory manager */
	out_wnd.wnd = new window_platform;
	out_wnd.wnd->hwnd = NULL;
	out_wnd.wnd->name = name;
	out_wnd.width = width;
	out_wnd.height = height;

	/* Setup the windows class with default settings */
	WNDCLASSEX wc;
	memset(&wc, 0, sizeof(wc));
	wc.cbSize = sizeof(wc);
	wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	wc.lpfnWndProc = wnd_proc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hinstance;
	wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
	wc.hIconSm = wc.hIcon;
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = name;

	// Register the window class.
	if (RegisterClassEx(&wc) == 0)
	{
		/* TODO: Localization/Error number */
		error_popup("Failed to register window class", true);
	}

	if (!fullscreen)
	{
		position_x = (int)((GetSystemMetrics(SM_CXSCREEN) - width) * pos_x);
		position_y = (int)((GetSystemMetrics(SM_CYSCREEN) - height) * pos_y);
	}
	else
	{
		DEVMODE screen_settings;
		memset(&screen_settings, 0, sizeof(screen_settings));
		screen_settings.dmSize = sizeof(screen_settings);
		screen_settings.dmPelsHeight = (unsigned long)height;
		screen_settings.dmPelsWidth = (unsigned long)width;
		screen_settings.dmBitsPerPel = 32;
		screen_settings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

		ChangeDisplaySettings(&screen_settings, CDS_FULLSCREEN);
	}

	DWORD style = WS_OVERLAPPEDWINDOW | WS_VISIBLE;
	DWORD exStyle = 0;

	// Create the window with the screen settings and get the handle to it.
	out_wnd.wnd->hwnd = CreateWindowEx(exStyle,
	                                  name,
	                                  name,
	                                  style,
	                                  position_x, position_y,
	                                  (int)width, (int)height,
	                                  NULL,
	                                  NULL,
	                                  hinstance,
	                                  NULL);

	if (out_wnd.wnd->hwnd == NULL)
	{
		/* TODO: Localization/Error number */
		error_popup("Failed to create a window", true);
	}

	ShowWindow(out_wnd.wnd->hwnd, SW_SHOW);
}

void destroy_window(window &wnd, const bool fullscreen)
{
	dea_assert(wnd.wnd && "destroy_window: Platform specific window pointer is NULL");

	if (fullscreen)
	{
		ChangeDisplaySettings(NULL, 0);
	}

	DestroyWindow(wnd.wnd->hwnd);
	wnd.wnd->hwnd = NULL;

	HINSTANCE hinstance = GetModuleHandle(NULL);
	UnregisterClass(wnd.wnd->name, hinstance);
	hinstance = NULL;

	/* TODO: Memory manager */
	delete wnd.wnd;
}

void focus_window(window &wnd)
{
	dea_assert(wnd.wnd && wnd.wnd->hwnd);
	SetForegroundWindow(wnd.wnd->hwnd);
	SetFocus(wnd.wnd->hwnd);
}

void run(pod_vector<window> &windows)
{
	MSG msg;
	ZeroMemory(&msg, sizeof(MSG));

	bool running = true;
	while (running)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

		if (msg.message == WM_QUIT)
		{
			running = false;
		}
		else
		{
			if (windows_to_close && !windows_to_close->empty())
			{
				close_windows(windows, *windows_to_close);

				if (windows.empty())
					running = false;
			}

			/* Run frame */
		}
	}
}

DEA_END()

#endif // DEA_PLATFORM == DEA_PLATFORM_WINDOWS
<|endoftext|>


<commit_before>//
//  Video.cpp
//  Clock Signal
//
//  Created by Thomas Harte on 03/05/2019.
//  Copyright © 2019 Thomas Harte. All rights reserved.
//

#include "Video.hpp"

#include <algorithm>

using namespace Apple::Macintosh;

namespace {

const HalfCycles line_length(704);
const int number_of_lines = 370;
const HalfCycles frame_length(line_length * HalfCycles(number_of_lines));

}

// Re: CRT timings, see the Apple Guide to the Macintosh Hardware Family,
// bottom of page 400:
//
//	"For each scan line, 512 pixels are drawn on the screen ...
//	The horizontal blanking interval takes the time of an additional 192 pixels"
//
// And, at the top of 401:
//
//	"The visible portion of a full-screen display consists of 342 horizontal scan lines...
//	During the vertical blanking interval, the turned-off beam ... traces out an additional 28 scan lines,"
//
Video::Video(uint16_t *ram) :
 	crt_(704, 1, 370, Outputs::Display::ColourSpace::YIQ, 1, 1, 6, false, Outputs::Display::InputDataType::Luminance1),
 	ram_(ram) {

 	crt_.set_display_type(Outputs::Display::DisplayType::CompositeMonochrome);
	crt_.set_visible_area(Outputs::Display::Rect(0.02f, 0.025f, 0.94f, 0.94f));
}

void Video::set_scan_target(Outputs::Display::ScanTarget *scan_target) {
	crt_.set_scan_target(scan_target);
}

void Video::run_for(HalfCycles duration) {
	const int sync_start = 36;
	const int sync_end = 38;

	// The number of HalfCycles is literally the number of pixel clocks to move through,
	// since pixel output occurs at twice the processor clock. So divide by 16 to get
	// the number of fetches.
	while(duration > HalfCycles(0)) {
		auto cycles_left_in_line = std::min(line_length - frame_position_%line_length, duration);

		const int line = (frame_position_ / line_length).as_int();
		const auto pixel_start = frame_position_ % line_length;

		// Line timing, entirely invented as I can find exactly zero words of documentation:
		//
		//	First 342 lines:
		//
		//	First 32 words = pixels;
		//	next 5 words = right border;
		//	next 2 words = sync level;
		//	final 5 words = left border.
		//
		//	Then 12 lines of border, 3 of sync, 11 more of border.

		const int first_word = pixel_start.as_int() >> 4;
		const int final_word = (pixel_start + cycles_left_in_line).as_int() >> 4;

		if(first_word != final_word) {
			if(line < 342) {
				// If there are any pixels left to output, do so.
				if(first_word < 32) {
					const int final_pixel_word = std::min(final_word, 32);

					if(!first_word) {
						pixel_buffer_ = crt_.begin_data(512);
					}

					if(pixel_buffer_) {
						for(int c = first_word; c < final_pixel_word; ++c) {
							uint16_t pixels = ram_[video_address_] ^ 0xffff;
							++video_address_;

							pixel_buffer_[15] = pixels & 0x01;
							pixel_buffer_[14] = pixels & 0x02;
							pixel_buffer_[13] = pixels & 0x04;
							pixel_buffer_[12] = pixels & 0x08;
							pixel_buffer_[11] = pixels & 0x10;
							pixel_buffer_[10] = pixels & 0x20;
							pixel_buffer_[9] = pixels & 0x40;
							pixel_buffer_[8] = pixels & 0x80;

							pixels >>= 8;
							pixel_buffer_[7] = pixels & 0x01;
							pixel_buffer_[6] = pixels & 0x02;
							pixel_buffer_[5] = pixels & 0x04;
							pixel_buffer_[4] = pixels & 0x08;
							pixel_buffer_[3] = pixels & 0x10;
							pixel_buffer_[2] = pixels & 0x20;
							pixel_buffer_[1] = pixels & 0x40;
							pixel_buffer_[0] = pixels & 0x80;

							pixel_buffer_ += 16;
						}
					}

					if(final_pixel_word == 32) {
						crt_.output_data(512);
					}
				}

				if(first_word < sync_start && final_word >= sync_start)	crt_.output_blank((sync_start - 32) * 16);
				if(first_word < sync_end && final_word >= sync_end)		crt_.output_sync((sync_end - sync_start) * 16);
				if(final_word == 44)									crt_.output_blank((44 - sync_end) * 16);
			} else if(line >= 353 && line < 356) {
				/* Output a sync line. */
				if(final_word == 44) {
					crt_.output_sync(sync_start * 16);
					crt_.output_blank((sync_end - sync_start) * 16);
					crt_.output_sync((44 - sync_end) * 16);
				}
			} else {
				/* Output a blank line. */
				if(final_word == 44) {
					crt_.output_blank(sync_start * 16);
					crt_.output_sync((sync_end - sync_start) * 16);
					crt_.output_blank((44 - sync_end) * 16);
				}
			}
		}

		duration -= cycles_left_in_line;
		frame_position_ = frame_position_ + cycles_left_in_line;
		if(frame_position_ == frame_length) {
			frame_position_ = HalfCycles(0);
			/*
				Video: $1A700 and the alternate buffer starts at $12700; for a 512K Macintosh, add $60000 to these numbers.
			*/
			video_address_ = use_alternate_screen_buffer_ ? (0x12700 >> 1) : (0x1a700 >> 1);
		}
	}
}

void Video::set_use_alternate_screen_buffer(bool use_alternate_screen_buffer) {
	use_alternate_screen_buffer_ = use_alternate_screen_buffer;
}
<commit_msg>Sets a more appropriate display type.<commit_after>//
//  Video.cpp
//  Clock Signal
//
//  Created by Thomas Harte on 03/05/2019.
//  Copyright © 2019 Thomas Harte. All rights reserved.
//

#include "Video.hpp"

#include <algorithm>

using namespace Apple::Macintosh;

namespace {

const HalfCycles line_length(704);
const int number_of_lines = 370;
const HalfCycles frame_length(line_length * HalfCycles(number_of_lines));

}

// Re: CRT timings, see the Apple Guide to the Macintosh Hardware Family,
// bottom of page 400:
//
//	"For each scan line, 512 pixels are drawn on the screen ...
//	The horizontal blanking interval takes the time of an additional 192 pixels"
//
// And, at the top of 401:
//
//	"The visible portion of a full-screen display consists of 342 horizontal scan lines...
//	During the vertical blanking interval, the turned-off beam ... traces out an additional 28 scan lines,"
//
Video::Video(uint16_t *ram) :
 	crt_(704, 1, 370, Outputs::Display::ColourSpace::YIQ, 1, 1, 6, false, Outputs::Display::InputDataType::Luminance1),
 	ram_(ram) {

 	crt_.set_display_type(Outputs::Display::DisplayType::RGB);
	crt_.set_visible_area(Outputs::Display::Rect(0.02f, 0.025f, 0.94f, 0.94f));
}

void Video::set_scan_target(Outputs::Display::ScanTarget *scan_target) {
	crt_.set_scan_target(scan_target);
}

void Video::run_for(HalfCycles duration) {
	const int sync_start = 36;
	const int sync_end = 38;

	// The number of HalfCycles is literally the number of pixel clocks to move through,
	// since pixel output occurs at twice the processor clock. So divide by 16 to get
	// the number of fetches.
	while(duration > HalfCycles(0)) {
		auto cycles_left_in_line = std::min(line_length - frame_position_%line_length, duration);

		const int line = (frame_position_ / line_length).as_int();
		const auto pixel_start = frame_position_ % line_length;

		// Line timing, entirely invented as I can find exactly zero words of documentation:
		//
		//	First 342 lines:
		//
		//	First 32 words = pixels;
		//	next 5 words = right border;
		//	next 2 words = sync level;
		//	final 5 words = left border.
		//
		//	Then 12 lines of border, 3 of sync, 11 more of border.

		const int first_word = pixel_start.as_int() >> 4;
		const int final_word = (pixel_start + cycles_left_in_line).as_int() >> 4;

		if(first_word != final_word) {
			if(line < 342) {
				// If there are any pixels left to output, do so.
				if(first_word < 32) {
					const int final_pixel_word = std::min(final_word, 32);

					if(!first_word) {
						pixel_buffer_ = crt_.begin_data(512);
					}

					if(pixel_buffer_) {
						for(int c = first_word; c < final_pixel_word; ++c) {
							uint16_t pixels = ram_[video_address_] ^ 0xffff;
							++video_address_;

							pixel_buffer_[15] = pixels & 0x01;
							pixel_buffer_[14] = pixels & 0x02;
							pixel_buffer_[13] = pixels & 0x04;
							pixel_buffer_[12] = pixels & 0x08;
							pixel_buffer_[11] = pixels & 0x10;
							pixel_buffer_[10] = pixels & 0x20;
							pixel_buffer_[9] = pixels & 0x40;
							pixel_buffer_[8] = pixels & 0x80;

							pixels >>= 8;
							pixel_buffer_[7] = pixels & 0x01;
							pixel_buffer_[6] = pixels & 0x02;
							pixel_buffer_[5] = pixels & 0x04;
							pixel_buffer_[4] = pixels & 0x08;
							pixel_buffer_[3] = pixels & 0x10;
							pixel_buffer_[2] = pixels & 0x20;
							pixel_buffer_[1] = pixels & 0x40;
							pixel_buffer_[0] = pixels & 0x80;

							pixel_buffer_ += 16;
						}
					}

					if(final_pixel_word == 32) {
						crt_.output_data(512);
					}
				}

				if(first_word < sync_start && final_word >= sync_start)	crt_.output_blank((sync_start - 32) * 16);
				if(first_word < sync_end && final_word >= sync_end)		crt_.output_sync((sync_end - sync_start) * 16);
				if(final_word == 44)									crt_.output_blank((44 - sync_end) * 16);
			} else if(line >= 353 && line < 356) {
				/* Output a sync line. */
				if(final_word == 44) {
					crt_.output_sync(sync_start * 16);
					crt_.output_blank((sync_end - sync_start) * 16);
					crt_.output_sync((44 - sync_end) * 16);
				}
			} else {
				/* Output a blank line. */
				if(final_word == 44) {
					crt_.output_blank(sync_start * 16);
					crt_.output_sync((sync_end - sync_start) * 16);
					crt_.output_blank((44 - sync_end) * 16);
				}
			}
		}

		duration -= cycles_left_in_line;
		frame_position_ = frame_position_ + cycles_left_in_line;
		if(frame_position_ == frame_length) {
			frame_position_ = HalfCycles(0);
			/*
				Video: $1A700 and the alternate buffer starts at $12700; for a 512K Macintosh, add $60000 to these numbers.
			*/
			video_address_ = use_alternate_screen_buffer_ ? (0x12700 >> 1) : (0x1a700 >> 1);
		}
	}
}

void Video::set_use_alternate_screen_buffer(bool use_alternate_screen_buffer) {
	use_alternate_screen_buffer_ = use_alternate_screen_buffer;
}
<|endoftext|>


<commit_before>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
#ifndef _CONNECTIVITY_OBOUNPARAM_HXX_
#define _CONNECTIVITY_OBOUNPARAM_HXX_

#include <com/sun/star/io/XInputStream.hpp>
#include "odbc/odbcbasedllapi.hxx"

namespace connectivity
{
    namespace odbc
    {
        class OOO_DLLPUBLIC_ODBCBASE OBoundParam
        {

        public:
            OBoundParam()
            {
                paramLength = NULL;
                binaryData  = NULL;
                pA1=0;
                pA2=0;
                pB1=0;
                pB2=0;
                pC1=0;
                pC2=0;
                pS1=0;
                pS2=0;
            }
            ~OBoundParam()
            {
                delete [] binaryData;
                delete [] paramLength;
            }
            //--------------------------------------------------------------------
            // initialize
            // Perform an necessary initialization
            //--------------------------------------------------------------------
            void initialize ()
            {
                // Allocate storage for the length.  Note - the length is
                // stored in native format, and will have to be converted
                // to a Java sal_Int32.  The jdbcodbc 'C' bridge provides an
                // interface to do this.

                paramLength = new sal_Int8[4];
            }

            //--------------------------------------------------------------------
            // allocBindDataBuffer
            // Allocates and returns a new bind data buffer of the specified
            // length
            //--------------------------------------------------------------------
            sal_Int8* allocBindDataBuffer (sal_Int32 bufLen)
            {
                if ( binaryData )
                    delete [] binaryData;
                binaryData = new sal_Int8[bufLen];

                // Reset the input stream, we are doing a new bind
                setInputStream (NULL, 0);

                return binaryData;
            }

            //--------------------------------------------------------------------
            // getBindDataBuffer
            // Returns the data buffer to be used when binding to a parameter
            //--------------------------------------------------------------------
            sal_Int8* getBindDataBuffer ()
            {
                return binaryData;
            }

            //--------------------------------------------------------------------
            // getBindLengthBuffer
            // Returns the length buffer to be used when binding to a parameter
            //--------------------------------------------------------------------
            sal_Int8* getBindLengthBuffer ()
            {
                return paramLength;
            }

            //--------------------------------------------------------------------
            // setInputStream
            // Sets the input stream for the bound parameter
            //--------------------------------------------------------------------
            void setInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& inputStream,
                                sal_Int32 len)
            {
                paramInputStream = inputStream;
                paramInputStreamLen = len;
            }

            void setSequence(const ::com::sun::star::uno::Sequence< sal_Int8 >& _aSequence)
            {
                aSequence = _aSequence;
            }

            //--------------------------------------------------------------------
            // getInputStream
            // Gets the input stream for the bound parameter
            //--------------------------------------------------------------------
            ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> getInputStream ()
            {
                return paramInputStream;
            }

            //--------------------------------------------------------------------
            // getInputStreamLen
            // Gets the input stream length for the bound parameter
            //--------------------------------------------------------------------
            sal_Int32 getInputStreamLen ()
            {
                return paramInputStreamLen;
            }

            //--------------------------------------------------------------------
            // setSqlType
            // Sets the Java sql type used to register an OUT parameter
            //--------------------------------------------------------------------

            void setSqlType(sal_Int32 type)
            {
                sqlType = type;
            }

            //--------------------------------------------------------------------
            // getSqlType
            // Gets the Java sql type used to register an OUT parameter
            //--------------------------------------------------------------------

            sal_Int32 getSqlType ()
            {
                return sqlType;
            }

            //--------------------------------------------------------------------
            // setOutputParameter
            // Sets the flag indicating if this is an OUTPUT parameter
            //--------------------------------------------------------------------

            void setOutputParameter (sal_Bool output)
            {
                outputParameter = output;
            }

            //--------------------------------------------------------------------
            // isOutputParameter
            // Gets the OUTPUT parameter flag
            //--------------------------------------------------------------------

            sal_Bool isOutputParameter ()
            {
                return outputParameter;
            }

        protected:
            //====================================================================
            // Data attributes
            //====================================================================

            sal_Int8* binaryData;       // Storage area to be used
                                        // when binding the parameter

            sal_Int8* paramLength;      // Storage area to be used
                                        // for the bound length of the
                                        // parameter.  Note that this
                                        // data is in native format.

            ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> paramInputStream;
            ::com::sun::star::uno::Sequence< sal_Int8 > aSequence;
                                        // When an input stream is
                                        // bound to a parameter, the
                                        // input stream is saved
                                        // until needed.

            sal_Int32 paramInputStreamLen;                // Length of input stream

            sal_Int32 sqlType;                          // Java SQL type used to
                                                            // register an OUT parameter

            sal_Bool outputParameter;   // true for OUTPUT parameters

            sal_Int32 pA1;              //pointers
            sal_Int32 pA2;
            sal_Int32 pB1;
            sal_Int32 pB2;
            sal_Int32 pC1;
            sal_Int32 pC2;
            sal_Int32 pS1;
            sal_Int32 pS2;// reserved for strings(UTFChars)
        };
    }
}
#endif // _CONNECTIVITY_OBOUNPARAM_HXX_

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<commit_msg>odbc 64 bit crash: correct buffer length allocation for a SQLLEN<commit_after>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
#ifndef _CONNECTIVITY_OBOUNPARAM_HXX_
#define _CONNECTIVITY_OBOUNPARAM_HXX_

#include <com/sun/star/io/XInputStream.hpp>
#include "odbc/odbcbasedllapi.hxx"

namespace connectivity
{
    namespace odbc
    {
        class OOO_DLLPUBLIC_ODBCBASE OBoundParam
        {

        public:
            OBoundParam()
            {
                paramLength = NULL;
                binaryData  = NULL;
                pA1=0;
                pA2=0;
                pB1=0;
                pB2=0;
                pC1=0;
                pC2=0;
                pS1=0;
                pS2=0;
            }
            ~OBoundParam()
            {
                delete [] binaryData;
                delete [] paramLength;
            }
            //--------------------------------------------------------------------
            // initialize
            // Perform an necessary initialization
            //--------------------------------------------------------------------
            void initialize ()
            {
                // Allocate storage for the length.  Note - the length is
                // stored in native format, and will have to be converted
                // to a Java sal_Int32.  The jdbcodbc 'C' bridge provides an
                // interface to do this.

                paramLength = new sal_Int8[sizeof(SQLLEN)];
            }

            //--------------------------------------------------------------------
            // allocBindDataBuffer
            // Allocates and returns a new bind data buffer of the specified
            // length
            //--------------------------------------------------------------------
            sal_Int8* allocBindDataBuffer (sal_Int32 bufLen)
            {
                if ( binaryData )
                    delete [] binaryData;
                binaryData = new sal_Int8[bufLen];

                // Reset the input stream, we are doing a new bind
                setInputStream (NULL, 0);

                return binaryData;
            }

            //--------------------------------------------------------------------
            // getBindDataBuffer
            // Returns the data buffer to be used when binding to a parameter
            //--------------------------------------------------------------------
            sal_Int8* getBindDataBuffer ()
            {
                return binaryData;
            }

            //--------------------------------------------------------------------
            // getBindLengthBuffer
            // Returns the length buffer to be used when binding to a parameter
            //--------------------------------------------------------------------
            sal_Int8* getBindLengthBuffer ()
            {
                return paramLength;
            }

            //--------------------------------------------------------------------
            // setInputStream
            // Sets the input stream for the bound parameter
            //--------------------------------------------------------------------
            void setInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& inputStream,
                                sal_Int32 len)
            {
                paramInputStream = inputStream;
                paramInputStreamLen = len;
            }

            void setSequence(const ::com::sun::star::uno::Sequence< sal_Int8 >& _aSequence)
            {
                aSequence = _aSequence;
            }

            //--------------------------------------------------------------------
            // getInputStream
            // Gets the input stream for the bound parameter
            //--------------------------------------------------------------------
            ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> getInputStream ()
            {
                return paramInputStream;
            }

            //--------------------------------------------------------------------
            // getInputStreamLen
            // Gets the input stream length for the bound parameter
            //--------------------------------------------------------------------
            sal_Int32 getInputStreamLen ()
            {
                return paramInputStreamLen;
            }

            //--------------------------------------------------------------------
            // setSqlType
            // Sets the Java sql type used to register an OUT parameter
            //--------------------------------------------------------------------

            void setSqlType(sal_Int32 type)
            {
                sqlType = type;
            }

            //--------------------------------------------------------------------
            // getSqlType
            // Gets the Java sql type used to register an OUT parameter
            //--------------------------------------------------------------------

            sal_Int32 getSqlType ()
            {
                return sqlType;
            }

            //--------------------------------------------------------------------
            // setOutputParameter
            // Sets the flag indicating if this is an OUTPUT parameter
            //--------------------------------------------------------------------

            void setOutputParameter (sal_Bool output)
            {
                outputParameter = output;
            }

            //--------------------------------------------------------------------
            // isOutputParameter
            // Gets the OUTPUT parameter flag
            //--------------------------------------------------------------------

            sal_Bool isOutputParameter ()
            {
                return outputParameter;
            }

        protected:
            //====================================================================
            // Data attributes
            //====================================================================

            sal_Int8* binaryData;       // Storage area to be used
                                        // when binding the parameter

            sal_Int8* paramLength;      // Storage area to be used
                                        // for the bound length of the
                                        // parameter.  Note that this
                                        // data is in native format.

            ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> paramInputStream;
            ::com::sun::star::uno::Sequence< sal_Int8 > aSequence;
                                        // When an input stream is
                                        // bound to a parameter, the
                                        // input stream is saved
                                        // until needed.

            sal_Int32 paramInputStreamLen;                // Length of input stream

            sal_Int32 sqlType;                          // Java SQL type used to
                                                            // register an OUT parameter

            sal_Bool outputParameter;   // true for OUTPUT parameters

            sal_Int32 pA1;              //pointers
            sal_Int32 pA2;
            sal_Int32 pB1;
            sal_Int32 pB2;
            sal_Int32 pC1;
            sal_Int32 pC2;
            sal_Int32 pS1;
            sal_Int32 pS2;// reserved for strings(UTFChars)
        };
    }
}
#endif // _CONNECTIVITY_OBOUNPARAM_HXX_

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<|endoftext|>


<commit_before>/*
  analog.c - analogRead implementation for esp8266

  Copyright (c) 2015 Hristo Gochkov. All rights reserved.
  This file is part of the esp8266 core for Arduino environment.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 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
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

  18/06/2015 analogRead bugfix by Testato
*/

#include "wiring_private.h"
#include "pins_arduino.h"
#include "user_interface.h"

extern "C" {

extern int __analogRead(uint8_t pin)
{
    // accept both A0 constant and ADC channel number
    if(pin == 17 || pin == 0) {
        return system_adc_read();
    }
    return digitalRead(pin) * 1023;
}

extern int analogRead(uint8_t pin) __attribute__ ((weak, alias("__analogRead")));

};
<commit_msg>Add stub for analogReference (#7809)<commit_after>/*
  analog.c - analogRead implementation for esp8266

  Copyright (c) 2015 Hristo Gochkov. All rights reserved.
  This file is part of the esp8266 core for Arduino environment.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 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
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

  18/06/2015 analogRead bugfix by Testato
*/

#include "wiring_private.h"
#include "pins_arduino.h"
#include "user_interface.h"

extern "C" {

extern int __analogRead(uint8_t pin)
{
    // accept both A0 constant and ADC channel number
    if(pin == 17 || pin == 0) {
        return system_adc_read();
    }
    return digitalRead(pin) * 1023;
}

extern int analogRead(uint8_t pin) __attribute__ ((weak, alias("__analogRead")));

void __analogReference(uint8_t mode)
{
    // Only DEFAULT is supported on the ESP8266
    if (mode != DEFAULT) {
        DEBUGV("analogReference called with illegal mode");
    }
}

extern void analogReference(uint8_t mode) __attribute__ ((weak, alias("__analogReference")));

};
<|endoftext|>


<commit_before>#include <vector>
#include <gtest/gtest.h>
#include "../../main/utils/ToplistCreator.h"
#include "../../main/loggers/OnlinePredictor.h"

namespace {

  class DummyToplistCreator : public ToplistCreator{
    public:
      DummyToplistCreator(ToplistCreatorParameters* params):ToplistCreator(params){counter=0;}
      vector<RecDat>* run(RecDat*) override {counter++;return &topPredictions;}
      vector<RecDat> topPredictions;
      int counter;
  };
  class TestOnlinePredictor : public ::testing::Test  {
    public:
      OnlinePredictor* onlinePredictor;
      DummyToplistCreator* predictionCreator;
      vector<RecDat> recDats;

      TestOnlinePredictor() {}
      virtual ~TestOnlinePredictor(){}
      void SetUp() override {
        ToplistCreatorParameters params1;
        params1.top_k=0;
        params1.exclude_known=0;
        predictionCreator = new DummyToplistCreator(&params1);

        OnlinePredictorParameters params;
        params.evaluation_start_time = 10;
        params.time_frame = 20;
        onlinePredictor = new OnlinePredictor(&params);
        onlinePredictor->set_prediction_creator(predictionCreator);
      }
      void TearDown() override {
        delete predictionCreator;
        delete onlinePredictor;
      }
      RecDat* createRecDat(int user, int item, double score, double time){
        RecDat recDat;
        recDat.user = user;
        recDat.item = item;
        recDat.score = score;
        recDat.time = time;
        recDats.push_back(recDat);
        return &(recDats[recDats.size()-1]);
      }
  };
} //namespace

TEST_F(TestOnlinePredictor, test) {
  //evaluation_start_time=10
  //time_frame=20
  //time_frame bounds: [10, 30), [30, 50), 70, 90 etc.
  EXPECT_EQ(0,predictionCreator->counter);
  EXPECT_EQ(0,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(0,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,0));
  EXPECT_EQ(0,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(0,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,10));
  EXPECT_EQ(0,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(0,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,15));
  EXPECT_EQ(0,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(0,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,20));
  EXPECT_EQ(0,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(0,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,29));
  EXPECT_EQ(0,predictionCreator->counter);
  EXPECT_EQ(0,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(0,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,30));
  EXPECT_EQ(1,predictionCreator->counter);
  EXPECT_EQ(1,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(1,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,30));
  onlinePredictor->run(createRecDat(0,0,0,35));
  onlinePredictor->run(createRecDat(0,0,0,36));
  onlinePredictor->run(createRecDat(0,0,0,49));
  EXPECT_EQ(1,predictionCreator->counter);
  EXPECT_EQ(1,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(1,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,53));
  EXPECT_EQ(2,predictionCreator->counter);
  EXPECT_EQ(2,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(2,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,95));
  EXPECT_EQ(3,predictionCreator->counter);
  EXPECT_EQ(4,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(4,onlinePredictor->past_time_frame_);
}

int main (int argc, char **argv) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

<commit_msg>add tests for OnlinePredictor::init, destructor<commit_after>#include <vector>
#include <gtest/gtest.h>
#include "../../main/utils/ToplistCreator.h"
#include "../../main/loggers/OnlinePredictor.h"

namespace {
  class DummyToplistCreator : public ToplistCreator{
    public:
      DummyToplistCreator(ToplistCreatorParameters* params):ToplistCreator(params){}
      vector<RecDat>* run(RecDat*) override {counter++;return &topPredictions;}
      vector<RecDat> topPredictions;
      int counter = 0;
  };
  class TestOnlinePredictor : public ::testing::Test  {
    public:
      OnlinePredictor* onlinePredictor;
      DummyToplistCreator* predictionCreator;
      vector<RecDat> recDats;

      TestOnlinePredictor() {}
      virtual ~TestOnlinePredictor(){}
      void SetUp() override {
        ToplistCreatorParameters params1;
        params1.top_k=0;
        params1.exclude_known=0;
        predictionCreator = new DummyToplistCreator(&params1);
        predictionCreator->topPredictions.push_back(
          *createRecDat(1,2,0.0,100) //the RecDat will be copied there
        );

        OnlinePredictorParameters params;
        params.evaluation_start_time = 10;
        params.time_frame = 20;
        onlinePredictor = new OnlinePredictor(&params);
        onlinePredictor->set_prediction_creator(predictionCreator);
      }
      void TearDown() override {
        delete predictionCreator;
        delete onlinePredictor;
      }
      RecDat* createRecDat(int user, int item, double score, double time){
        RecDat recDat;
        recDat.user = user;
        recDat.item = item;
        recDat.score = score;
        recDat.time = time;
        recDats.push_back(recDat);
        return &(recDats[recDats.size()-1]);
      }
  };
} //namespace

TEST_F(TestOnlinePredictor, test) {
  //evaluation_start_time=10
  //time_frame=20
  //time_frame bounds: [10, 30), [30, 50), 70, 90 etc.
  EXPECT_EQ(0,predictionCreator->counter);
  EXPECT_EQ(0,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(0,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,0));
  EXPECT_EQ(0,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(0,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,10));
  EXPECT_EQ(0,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(0,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,15));
  EXPECT_EQ(0,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(0,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,20));
  EXPECT_EQ(0,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(0,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,29));
  EXPECT_EQ(0,predictionCreator->counter);
  EXPECT_EQ(0,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(0,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,30));
  EXPECT_EQ(1,predictionCreator->counter);
  EXPECT_EQ(1,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(1,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,30));
  onlinePredictor->run(createRecDat(0,0,0,35));
  onlinePredictor->run(createRecDat(0,0,0,36));
  onlinePredictor->run(createRecDat(0,0,0,49));
  EXPECT_EQ(1,predictionCreator->counter);
  EXPECT_EQ(1,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(1,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,53));
  EXPECT_EQ(2,predictionCreator->counter);
  EXPECT_EQ(2,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(2,onlinePredictor->past_time_frame_);
  onlinePredictor->run(createRecDat(0,0,0,95));
  EXPECT_EQ(3,predictionCreator->counter);
  EXPECT_EQ(4,onlinePredictor->actual_time_frame_);
  EXPECT_EQ(4,onlinePredictor->past_time_frame_);
}
TEST_F(TestOnlinePredictor, init) {
  OnlinePredictorParameters params;
  params.evaluation_start_time = -1;
  params.time_frame = 20;
  OnlinePredictor online_predictor(&params);
  online_predictor.set_prediction_creator(predictionCreator);

  ExperimentEnvironment exp_env;
  online_predictor.set_experiment_environment(&exp_env);

  EXPECT_TRUE(online_predictor.initialize());
}

int main (int argc, char **argv) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: ww8dout.cxx,v $
 *
 *  $Revision: 1.7 $
 *
 *  last change: $Author: obo $ $Date: 2006-09-16 22:26:45 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"

#include <stdio.h>          // getchar

//#include "defs.hxx"
#include <tools/solar.h>            // BYTE
//#include "wwscan.hxx" // aWwStor
#include "ww8dout.hxx"

#ifndef _STREAM_HXX //autogen
#include <tools/stream.hxx>
#endif

#include <sot/storage.hxx>

extern SvStorageStreamRef xStrm;
extern SvStorageStreamRef xTableStream;
extern SvStorageStreamRef xDataStream;  // ist bei Ver6-7 mit xStrm identisch,
void DumpSprms( BYTE nVersion, SvStream& rSt, short nLen );

ostream* pOut = 0;

#define DumpVer8

//-----------------------------------------
//          Streams
//-----------------------------------------

static int level = 0;
static long lastpos = -1;

ostream& __cdecl endl1( ostream& s ){
//ostream& endl1( ostream& s ) {
    s << endl;
    return s;
}

ostream&  __cdecl hex2( ostream& s ) {
    s.width( 2 ); s.fill( (const char)250 );
    s << hex;
    return s;
}

ostream&  __cdecl hex4( ostream& s ) {
    s.width( 4 ); s.fill( (const char)250 );
    s << hex ;
    return s;
}

ostream&  __cdecl hex6( ostream& s ) {
    s.width( 6 ); s.fill( (const char)250 );
    s << hex ;
    return s;
}

ostream&  __cdecl hex8( ostream& s ) {
    s.width( 8 ); s.fill( (const char)250 );
    s << hex ;
    return s;
}

ostream&  __cdecl dec2( ostream& s ) {
    s << dec;
    s.width( 0 ); s.fill( 0 );
    return s;
}

ostream&  __cdecl filepos( ostream& s, SvStream& rSt ) {
    register long pos = rSt.Tell();

    if ( pos != lastpos ){
#ifndef DumpVer8
        if( &rSt == &xStrm )
            s << "D";
        else
            s << "T";
#endif
        s.width( 6 );
        s.fill( (const char)250 );
        s << hex << pos << dec << ' ';
        s.width( 0 ); s.fill( 0 );
        lastpos = pos;
    }else{
#ifndef DumpVer8
        s << "        ";
#else
        s << "       ";
#endif
    }
    return s;
}

ostream&  __cdecl indent( ostream& s, SvStream& rSt ) {
    filepos( s, rSt );
    for( int i = 0; i < level; i++ ) s << "  ";
    return s;
}

ostream&  __cdecl indent1( ostream& s ) {
    for( int i = 0; i < level; i++ ) s << "  ";
    return s;
}

ostream&  __cdecl indent2( ostream& s ) {
#ifndef DumpVer8
    s << "        " << indent1;
#else
    s << "       " << indent1;
#endif
    return s;
}

ostream&  __cdecl begin( ostream& s, SvStream& rSt  ) { indent( s, rSt ) << "BEGIN "; level++; return s; }

// begin1 ohne indent
ostream&  __cdecl begin1( ostream& s ) { s << "BEGIN "; level++; return s; }

// begin2 ohne Nummer
ostream&  __cdecl begin2( ostream& s ) { s << indent2 << "BEGIN "; level++; return s; }

ostream&  __cdecl end( ostream& s, SvStream& rSt  ) { level--; return indent( s, rSt ) << "END "; }

// end1 ohne filepos
ostream&  __cdecl end1( ostream& s ) { level--; return s << indent1 << "END "; }

// end2 ohne Nummer
ostream&  __cdecl end2( ostream& s ) { level--; return s << indent2 << "END "; }

//-----------------------------------------
//          Ausgabe-Funktionen
//-----------------------------------------

void OutBool( SvStream& rSt, short )
{
    BYTE nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    switch( nPara ){
    case 0:  *pOut << "F"; break;
    case 1:  *pOut << "T"; break;
    default: *pOut << "ERROR:" << (USHORT)nPara; break;
    }
}

void OutBool4( SvStream& rSt, short )
{
    BYTE nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    switch( nPara ){
    case 0:   *pOut << "F"; break;
    case 1:   *pOut << "T"; break;
    case 128: *pOut << "==Style"; break;
    case 129: *pOut << "!=Style"; break;
    default:  *pOut << "ERROR:" << (USHORT)nPara; break;
    }
}

void OutByte( SvStream& rSt, short )
{
    BYTE nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    *pOut << (USHORT)nPara;
}

void OutShort( SvStream& rSt, short )
{
    short nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    *pOut << nPara;
}

void OutShorts( SvStream& rSt, short nLen )
{
    INT16 nPara;

    for( short i = 0; i < nLen / 2; i++ ){
        rSt.Read( &nPara, sizeof( nPara ) );
        *pOut << nPara << ' ';
    }
}

void OutWord( SvStream& rSt, short )
{
    USHORT nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    *pOut << nPara;
}

void OutWords( SvStream& rSt, short nLen )
{
    USHORT nPara;

    for( short i = 0; i < nLen / 2; i++ ){
        rSt.Read( &nPara, sizeof( nPara ) );
        *pOut << nPara;
    }
}

void OutWordHex( SvStream& rSt, short )
{
    USHORT nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    *pOut << "0x" << hex4 << nPara << dec;
}

void OutWordsHex( SvStream& rSt, short nLen )
{
    USHORT nPara;
    nLen /= sizeof( nPara );
    for( short i = 0; i < nLen; i++ ){
        rSt.Read( &nPara, sizeof( nPara ) );
        *pOut << "0x" << hex4 << nPara << dec;
        if( i < nLen - 1 )
            *pOut << ' ';
    }
}

void OutLongsHex( SvStream& rSt, short nLen )
{
    long nPara;
    nLen /= sizeof( nPara );
    for( short i = 0; i < nLen; i++ )
    {
        rSt.Read( &nPara, sizeof( nPara ) );
        *pOut << "0x" << hex8 << nPara << dec;
        if( i < nLen - 1 )
            *pOut << ' ';
    }
}

void OutLongHex( SvStream& rSt, short )
{
    ULONG nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    *pOut << "0x" << hex8 << nPara << dec;
}

void OutTab68( SvStream& rSt, short )
{
    ULONG nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    if(  nPara == 0 )
        *pOut << "None";
    else
        *pOut << "0x" << hex8 << nPara << dec;
}

void OutTab( SvStream& rSt, short )
{
    BYTE nDel, nIns, nType;
    short nPos, i;

    rSt.Read( &nDel, sizeof( nDel ) );
    *pOut << "Del " << (USHORT)nDel;
    if ( nDel ) *pOut << ": ";
    else        *pOut << ", ";

    for( i=1; i<=nDel; i++){
        rSt.Read( &nPos, sizeof( nPos ) );
        *pOut << nPos;
        if( i<nDel ) *pOut << ',';
        else *pOut << ' ';
    }
    rSt.Read( &nIns, sizeof( nIns ) );
    *pOut << "Ins " << (USHORT)nIns;
    if ( nIns ) *pOut << ": ";

    for( i=1; i<=nIns; i++){
        rSt.Read( &nPos, sizeof( nPos ) );
        *pOut << nPos;
        if( i<nIns ) *pOut << ',';
        else *pOut << ' ';
    }
    if ( nIns ) *pOut << "Typ: ";

    for( i=1; i<=nIns; i++){
        rSt.Read( &nType, sizeof( nType ) );
        *pOut << (USHORT)nType;
        if( i<nIns ) *pOut << ',';
        else *pOut << ' ';
    }

//  nSiz = 1 + 2 * nDel + 1 + nIns * 3; // genaue Laenge,
//      stimmt auch bei Laenge > 256
//  bei diesem Tab-Befehl anscheinend nicht noetig
}

void OutTab190( SvStream& rSt, short nLen )
{
    BYTE nCols;
    rSt.Read( &nCols, sizeof( nCols ) );
    *pOut << (USHORT)nCols << " Cols: ";

    short nPos, i;
    for( i = 0; i <= nCols; i++ ){
        rSt.Read( &nPos, sizeof( nPos ) );
        *pOut << nPos;
        if( i < nCols )
            *pOut << ", ";
    }
    *pOut << dec << "; ";
    for( i = 0; i < nCols; i++ ){
        *pOut << "Col " << i << " TC: ";
        OutWordsHex( rSt, 10 );
        if( i < nCols - 1 )
            *pOut << "; ";
    }
}

void OutTab191( SvStream& rSt, short nLen )
{
    BYTE nCols;
    rSt.Read( &nCols, sizeof( nCols ) );
    *pOut << (USHORT)nCols << " Cols, SHDs: ";
    OutWordsHex( rSt, ( nCols + 1 ) * 2 );
}

void OutTab192( SvStream& rSt, short )
{
    OutWord(    rSt, 0 );
    OutWordHex( rSt, 0 );
}

void OutHugeHex( SvStream& rSt, short nLen )
{
    long nPos;
    rSt.Read( &nPos, sizeof( nPos ) );

    long nCurr = xDataStream->Tell();
    xDataStream->Seek( nPos );

    xDataStream->Read( &nLen, sizeof( nLen ) );

//  *pOut << ", Len max: " << nLen << ", ID:" << nIStd << endl1;
    *pOut << endl1;
    DumpSprms( 8, *xDataStream, nLen );

    xDataStream->Seek( nCurr );
}

void OutTabD608( SvStream& rSt, short nLen )
{
    BYTE nHi, nCols;
    rSt.Read( &nHi, sizeof( nHi ) );
//  nLen += ((short)nHi) << 8;

    rSt.Read( &nCols, sizeof( nCols ) );
    *pOut << " Cols: " << (short)nCols << ' ' << endl1 << indent2;

    short nPos, i;
    for( i = 0; i <= nCols; ++i )
    {
        rSt.Read( &nPos, sizeof( nPos ) );
        *pOut << nPos;
        if( i < nCols )
            *pOut << ", ";
    }
    nLen -= ( nCols + 1 ) * 2;
    nLen /= 20;

    for( i = 0; i < nLen; ++i )
    {
        *pOut << endl1 << indent2 << "Col " << i << " TC: ";
        OutLongsHex( rSt, 20 );
        if( i < nLen - 1 )
            *pOut << "; ";
    }
}

void OutTabD609( SvStream& rSt, short nLen )
{
    *pOut << " Brush(FBS): ";
    for( short i = 0; i < nLen / 2; ++i )
    {
        UINT16 nVal;
        rSt.Read( &nVal, sizeof( nVal ) );
        *pOut << (nVal & 0x1f);
        *pOut << "|" << ((nVal >> 5) & 0x1f);
        *pOut << "|" << ((nVal >> 10) & 0x3f);
        if( i < nLen )
            *pOut << ", ";
    }
}

<commit_msg>INTEGRATION: CWS swwarnings (1.7.222); FILE MERGED 2007/04/03 13:00:56 tl 1.7.222.1: #i69287# warning-free code<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: ww8dout.cxx,v $
 *
 *  $Revision: 1.8 $
 *
 *  last change: $Author: hr $ $Date: 2007-09-27 10:07:22 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"

#include <stdio.h>          // getchar

//#include "defs.hxx"
#include <tools/solar.h>            // BYTE
//#include "wwscan.hxx" // aWwStor
#include "ww8dout.hxx"

#ifndef _STREAM_HXX //autogen
#include <tools/stream.hxx>
#endif

#include <sot/storage.hxx>

extern SvStorageStreamRef xStrm;
extern SvStorageStreamRef xTableStream;
extern SvStorageStreamRef xDataStream;  // ist bei Ver6-7 mit xStrm identisch,
void DumpSprms( BYTE nVersion, SvStream& rSt, short nLen );

ostream* pOut = 0;

#define DumpVer8

//-----------------------------------------
//          Streams
//-----------------------------------------

static int level = 0;
static long lastpos = -1;

ostream& __cdecl endl1( ostream& s ){
//ostream& endl1( ostream& s ) {
    s << endl;
    return s;
}

ostream&  __cdecl hex2( ostream& s ) {
    s.width( 2 ); s.fill( (const char)250 );
    s << hex;
    return s;
}

ostream&  __cdecl hex4( ostream& s ) {
    s.width( 4 ); s.fill( (const char)250 );
    s << hex ;
    return s;
}

ostream&  __cdecl hex6( ostream& s ) {
    s.width( 6 ); s.fill( (const char)250 );
    s << hex ;
    return s;
}

ostream&  __cdecl hex8( ostream& s ) {
    s.width( 8 ); s.fill( (const char)250 );
    s << hex ;
    return s;
}

ostream&  __cdecl dec2( ostream& s ) {
    s << dec;
    s.width( 0 ); s.fill( 0 );
    return s;
}

ostream&  __cdecl filepos( ostream& s, SvStream& rSt ) {
    long pos = rSt.Tell();

    if ( pos != lastpos ){
#ifndef DumpVer8
        if( &rSt == &xStrm )
            s << "D";
        else
            s << "T";
#endif
        s.width( 6 );
        s.fill( (const char)250 );
        s << hex << pos << dec << ' ';
        s.width( 0 ); s.fill( 0 );
        lastpos = pos;
    }else{
#ifndef DumpVer8
        s << "        ";
#else
        s << "       ";
#endif
    }
    return s;
}

ostream&  __cdecl indent( ostream& s, SvStream& rSt ) {
    filepos( s, rSt );
    for( int i = 0; i < level; i++ ) s << "  ";
    return s;
}

ostream&  __cdecl indent1( ostream& s ) {
    for( int i = 0; i < level; i++ ) s << "  ";
    return s;
}

ostream&  __cdecl indent2( ostream& s ) {
#ifndef DumpVer8
    s << "        " << indent1;
#else
    s << "       " << indent1;
#endif
    return s;
}

ostream&  __cdecl begin( ostream& s, SvStream& rSt  ) { indent( s, rSt ) << "BEGIN "; level++; return s; }

// begin1 ohne indent
ostream&  __cdecl begin1( ostream& s ) { s << "BEGIN "; level++; return s; }

// begin2 ohne Nummer
ostream&  __cdecl begin2( ostream& s ) { s << indent2 << "BEGIN "; level++; return s; }

ostream&  __cdecl end( ostream& s, SvStream& rSt  ) { level--; return indent( s, rSt ) << "END "; }

// end1 ohne filepos
ostream&  __cdecl end1( ostream& s ) { level--; return s << indent1 << "END "; }

// end2 ohne Nummer
ostream&  __cdecl end2( ostream& s ) { level--; return s << indent2 << "END "; }

//-----------------------------------------
//          Ausgabe-Funktionen
//-----------------------------------------

void OutBool( SvStream& rSt, short )
{
    BYTE nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    switch( nPara ){
    case 0:  *pOut << "F"; break;
    case 1:  *pOut << "T"; break;
    default: *pOut << "ERROR:" << (USHORT)nPara; break;
    }
}

void OutBool4( SvStream& rSt, short )
{
    BYTE nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    switch( nPara ){
    case 0:   *pOut << "F"; break;
    case 1:   *pOut << "T"; break;
    case 128: *pOut << "==Style"; break;
    case 129: *pOut << "!=Style"; break;
    default:  *pOut << "ERROR:" << (USHORT)nPara; break;
    }
}

void OutByte( SvStream& rSt, short )
{
    BYTE nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    *pOut << (USHORT)nPara;
}

void OutShort( SvStream& rSt, short )
{
    short nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    *pOut << nPara;
}

void OutShorts( SvStream& rSt, short nLen )
{
    INT16 nPara;

    for( short i = 0; i < nLen / 2; i++ ){
        rSt.Read( &nPara, sizeof( nPara ) );
        *pOut << nPara << ' ';
    }
}

void OutWord( SvStream& rSt, short )
{
    USHORT nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    *pOut << nPara;
}

void OutWords( SvStream& rSt, short nLen )
{
    USHORT nPara;

    for( short i = 0; i < nLen / 2; i++ ){
        rSt.Read( &nPara, sizeof( nPara ) );
        *pOut << nPara;
    }
}

void OutWordHex( SvStream& rSt, short )
{
    USHORT nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    *pOut << "0x" << hex4 << nPara << dec;
}

void OutWordsHex( SvStream& rSt, short nLen )
{
    USHORT nPara;
    nLen /= sizeof( nPara );
    for( short i = 0; i < nLen; i++ ){
        rSt.Read( &nPara, sizeof( nPara ) );
        *pOut << "0x" << hex4 << nPara << dec;
        if( i < nLen - 1 )
            *pOut << ' ';
    }
}

void OutLongsHex( SvStream& rSt, short nLen )
{
    long nPara;
    nLen /= sizeof( nPara );
    for( short i = 0; i < nLen; i++ )
    {
        rSt.Read( &nPara, sizeof( nPara ) );
        *pOut << "0x" << hex8 << nPara << dec;
        if( i < nLen - 1 )
            *pOut << ' ';
    }
}

void OutLongHex( SvStream& rSt, short )
{
    ULONG nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    *pOut << "0x" << hex8 << nPara << dec;
}

void OutTab68( SvStream& rSt, short )
{
    ULONG nPara;

    rSt.Read( &nPara, sizeof( nPara ) );
    if(  nPara == 0 )
        *pOut << "None";
    else
        *pOut << "0x" << hex8 << nPara << dec;
}

void OutTab( SvStream& rSt, short )
{
    BYTE nDel, nIns, nType;
    short nPos, i;

    rSt.Read( &nDel, sizeof( nDel ) );
    *pOut << "Del " << (USHORT)nDel;
    if ( nDel ) *pOut << ": ";
    else        *pOut << ", ";

    for( i=1; i<=nDel; i++){
        rSt.Read( &nPos, sizeof( nPos ) );
        *pOut << nPos;
        if( i<nDel ) *pOut << ',';
        else *pOut << ' ';
    }
    rSt.Read( &nIns, sizeof( nIns ) );
    *pOut << "Ins " << (USHORT)nIns;
    if ( nIns ) *pOut << ": ";

    for( i=1; i<=nIns; i++){
        rSt.Read( &nPos, sizeof( nPos ) );
        *pOut << nPos;
        if( i<nIns ) *pOut << ',';
        else *pOut << ' ';
    }
    if ( nIns ) *pOut << "Typ: ";

    for( i=1; i<=nIns; i++){
        rSt.Read( &nType, sizeof( nType ) );
        *pOut << (USHORT)nType;
        if( i<nIns ) *pOut << ',';
        else *pOut << ' ';
    }

//  nSiz = 1 + 2 * nDel + 1 + nIns * 3; // genaue Laenge,
//      stimmt auch bei Laenge > 256
//  bei diesem Tab-Befehl anscheinend nicht noetig
}

void OutTab190( SvStream& rSt, short nLen )
{
    BYTE nCols;
    rSt.Read( &nCols, sizeof( nCols ) );
    *pOut << (USHORT)nCols << " Cols: ";

    short nPos, i;
    for( i = 0; i <= nCols; i++ ){
        rSt.Read( &nPos, sizeof( nPos ) );
        *pOut << nPos;
        if( i < nCols )
            *pOut << ", ";
    }
    *pOut << dec << "; ";
    for( i = 0; i < nCols; i++ ){
        *pOut << "Col " << i << " TC: ";
        OutWordsHex( rSt, 10 );
        if( i < nCols - 1 )
            *pOut << "; ";
    }
}

void OutTab191( SvStream& rSt, short nLen )
{
    BYTE nCols;
    rSt.Read( &nCols, sizeof( nCols ) );
    *pOut << (USHORT)nCols << " Cols, SHDs: ";
    OutWordsHex( rSt, ( nCols + 1 ) * 2 );
}

void OutTab192( SvStream& rSt, short )
{
    OutWord(    rSt, 0 );
    OutWordHex( rSt, 0 );
}

void OutHugeHex( SvStream& rSt, short nLen )
{
    long nPos;
    rSt.Read( &nPos, sizeof( nPos ) );

    long nCurr = xDataStream->Tell();
    xDataStream->Seek( nPos );

    xDataStream->Read( &nLen, sizeof( nLen ) );

//  *pOut << ", Len max: " << nLen << ", ID:" << nIStd << endl1;
    *pOut << endl1;
    DumpSprms( 8, *xDataStream, nLen );

    xDataStream->Seek( nCurr );
}

void OutTabD608( SvStream& rSt, short nLen )
{
    BYTE nHi, nCols;
    rSt.Read( &nHi, sizeof( nHi ) );
//  nLen += ((short)nHi) << 8;

    rSt.Read( &nCols, sizeof( nCols ) );
    *pOut << " Cols: " << (short)nCols << ' ' << endl1 << indent2;

    short nPos, i;
    for( i = 0; i <= nCols; ++i )
    {
        rSt.Read( &nPos, sizeof( nPos ) );
        *pOut << nPos;
        if( i < nCols )
            *pOut << ", ";
    }
    nLen -= ( nCols + 1 ) * 2;
    nLen /= 20;

    for( i = 0; i < nLen; ++i )
    {
        *pOut << endl1 << indent2 << "Col " << i << " TC: ";
        OutLongsHex( rSt, 20 );
        if( i < nLen - 1 )
            *pOut << "; ";
    }
}

void OutTabD609( SvStream& rSt, short nLen )
{
    *pOut << " Brush(FBS): ";
    for( short i = 0; i < nLen / 2; ++i )
    {
        UINT16 nVal;
        rSt.Read( &nVal, sizeof( nVal ) );
        *pOut << (nVal & 0x1f);
        *pOut << "|" << ((nVal >> 5) & 0x1f);
        *pOut << "|" << ((nVal >> 10) & 0x3f);
        if( i < nLen )
            *pOut << ", ";
    }
}

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: cachemulticaster.hxx,v $
 *
 *  $Revision: 1.1 $
 *
 *  last change: $Author: jb $ $Date: 2002-03-15 11:48:53 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

/* PLEASE DON'T DELETE ANY COMMENT LINES, ALSO IT'S UNNECESSARY. */

#ifndef CONFIGMGR_BACKEND_CACHEMULTICASTER_HXX
#define CONFIGMGR_BACKEND_CACHEMULTICASTER_HXX

#ifndef CONFIGMGR_BACKEND_CACHEDDATAPROVIDER_HXX
#include "cacheddataprovider.hxx"
#endif

#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
#endif

#ifndef INCLUDED_LIST
#include <list>
#define INCLUDED_LIST
#endif

namespace configmgr
{
// ---------------------------------------------------------------------------
    namespace backend
    {
// ---------------------------------------------------------------------------

    /** Interface providing a multicasting service for changes to the cache
        managed by a <type>ICachedDataProvider</type>
    */
    class CacheChangeMulticaster : public ICachedDataNotifier
    {
    public:
        CacheChangeMulticaster();
        ~CacheChangeMulticaster();

    // ICachedDataNotifier implementation
    public:
        /// notify all registered listeners and close down this notifier
        virtual void dispose(ICachedDataProvider & _rProvider) CFG_NOTHROW();

        /** notify a new component to all registered listeners.

 Must be called after the component has been created in the cache.

        */
        virtual void notifyCreated(ComponentRequest const & _aComponentName) CFG_NOTHROW();

        /** notify changed data to all registered listeners.

 Must be called after the change has been applied to the cache
                and before any subsequent changes to the same component.

        */
        virtual void notifyChanged(UpdateRequest const & _anUpdate) CFG_NOTHROW();

    // notification support.
        /// register a listener for observing changes to the cached data
        virtual void addListener(ListenerRef _xListener) CFG_NOTHROW();
        /// unregister a listener previously registered
        virtual void removeListener(ListenerRef _xListener) CFG_NOTHROW();
    private:
        typedef std::list<ListenerRef> ListenerList;

        ListenerList copyListenerList();

        osl::Mutex   m_aMutex;
        ListenerList m_aListeners;
    };
// ---------------------------------------------------------------------------
    } // namespace backend

// ---------------------------------------------------------------------------
} // namespace configmgr

#endif

<commit_msg>INTEGRATION: CWS cfgcleanup (1.1.100); FILE MERGED 2004/02/09 15:30:33 jb 1.1.100.1: #i25025# Eliminate warnings from gcc<commit_after>/*************************************************************************
 *
 *  $RCSfile: cachemulticaster.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: kz $ $Date: 2004-03-23 10:30:52 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

/* PLEASE DON'T DELETE ANY COMMENT LINES, ALSO IT'S UNNECESSARY. */

#ifndef CONFIGMGR_BACKEND_CACHEMULTICASTER_HXX
#define CONFIGMGR_BACKEND_CACHEMULTICASTER_HXX

#ifndef CONFIGMGR_BACKEND_CACHEDDATAPROVIDER_HXX
#include "cacheddataprovider.hxx"
#endif

#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
#endif

#ifndef INCLUDED_LIST
#include <list>
#define INCLUDED_LIST
#endif

namespace configmgr
{
// ---------------------------------------------------------------------------
    namespace backend
    {
// ---------------------------------------------------------------------------

    /** Interface providing a multicasting service for changes to the cache
        managed by a <type>ICachedDataProvider</type>
    */
    class CacheChangeMulticaster : public ICachedDataNotifier
    {
    public:
        CacheChangeMulticaster();
        virtual ~CacheChangeMulticaster();

    // ICachedDataNotifier implementation
    public:
        /// notify all registered listeners and close down this notifier
        virtual void dispose(ICachedDataProvider & _rProvider) CFG_NOTHROW();

        /** notify a new component to all registered listeners.

 Must be called after the component has been created in the cache.

        */
        virtual void notifyCreated(ComponentRequest const & _aComponentName) CFG_NOTHROW();

        /** notify changed data to all registered listeners.

 Must be called after the change has been applied to the cache
                and before any subsequent changes to the same component.

        */
        virtual void notifyChanged(UpdateRequest const & _anUpdate) CFG_NOTHROW();

    // notification support.
        /// register a listener for observing changes to the cached data
        virtual void addListener(ListenerRef _xListener) CFG_NOTHROW();
        /// unregister a listener previously registered
        virtual void removeListener(ListenerRef _xListener) CFG_NOTHROW();
    private:
        typedef std::list<ListenerRef> ListenerList;

        ListenerList copyListenerList();

        osl::Mutex   m_aMutex;
        ListenerList m_aListeners;
    };
// ---------------------------------------------------------------------------
    } // namespace backend

// ---------------------------------------------------------------------------
} // namespace configmgr

#endif

<|endoftext|>