Nicolas Jager | eeef17c | 2016-08-16 10:21:54 -0400 | [diff] [blame] | 1 | /***************************************************************************
|
| 2 | * Copyright (C) 2016 by Savoir-faire Linux *
|
| 3 | * Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
|
| 4 | * *
|
| 5 | * This program is free software; you can redistribute it and/or modify *
|
| 6 | * it under the terms of the GNU General Public License as published by *
|
| 7 | * the Free Software Foundation; either version 3 of the License, or *
|
| 8 | * (at your option) any later version. *
|
| 9 | * *
|
| 10 | * This program is distributed in the hope that it will be useful, *
|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
| 13 | * GNU General Public License for more details. *
|
| 14 | * *
|
| 15 | * You should have received a copy of the GNU General Public License *
|
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
| 17 | **************************************************************************/
|
| 18 | #pragma once
|
| 19 |
|
| 20 | namespace RingClientUWP
|
| 21 | {
|
| 22 |
|
| 23 | /* forward declaration */
|
| 24 | ref class RingDebug;
|
| 25 |
|
| 26 | /* delegate */
|
| 27 | delegate void debugMessageToScreen(Platform::String^ message);
|
| 28 |
|
| 29 | /* this is how to implement a singleton class*/
|
| 30 | public ref class RingDebug sealed
|
| 31 | {
|
| 32 | public:
|
| 33 | /* singleton */
|
| 34 | static property RingDebug^ instance
|
| 35 | {
|
| 36 | RingDebug^ get()
|
| 37 | {
|
| 38 | static RingDebug^ instance_ = ref new RingDebug();
|
| 39 | return instance_;
|
| 40 | }
|
| 41 | }
|
| 42 |
|
| 43 | /* properties */
|
| 44 |
|
| 45 | /* functions */
|
| 46 | internal:
|
| 47 | enum class Type { MSG, WNG, ERR };
|
| 48 | void print(const std::string& message, const Type& type = Type::MSG);
|
| 49 |
|
| 50 | /* event */
|
| 51 | event debugMessageToScreen^ messageToScreen;
|
| 52 |
|
| 53 | private:
|
| 54 | RingDebug() {}; // singleton
|
| 55 | };
|
| 56 |
|
| 57 | #define MSG_(cstr) CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Low, \
|
| 58 | ref new DispatchedHandler([=]() { RingDebug::instance->print(cstr); }))
|
| 59 |
|
| 60 | #define WNG_(cstr) CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Low, \
|
| 61 | ref new DispatchedHandler([=]() { RingDebug::instance->print(std::string(cstr), RingDebug::Type::WNG); }))
|
| 62 |
|
| 63 | #define ERR_(cstr) CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Low, \
|
| 64 | ref new DispatchedHandler([=]() { RingDebug::instance->print(std::string(cstr), RingDebug::Type::ERR); }))
|
| 65 |
|
Nicolas Jager | 32ed1a2 | 2016-08-17 08:36:02 -0400 | [diff] [blame] | 66 | }
|