Sha256: c0edc26f0a0d599c7902a126f43edba08692879ae531dc8e11fe699b9057e823

Contents?: true

Size: 1.8 KB

Versions: 14

Compression:

Stored size: 1.8 KB

Contents

#pragma once

#include <common/RhoStd.h>
#include "../../../shared/generated/cpp/IPrinterZebra.h"

namespace rho
{
namespace printing
{

template<typename PrinterType, typename PrinterImplType>
class PrinterManager
{
public:
    typedef rho::String PrinterID;

private:
    static PrinterManager<PrinterType, PrinterImplType>* g_managerInstance;

    std::map<PrinterID, PrinterType*> m_priterCache;

private:
    PrinterManager() {}

public:

    PrinterType* addPrinterWithID(const PrinterID& printerID)
    {
        PrinterType* printer = getPrinterByID(printerID);

        if (!printer)
        {
            PrinterImplType* newPrinter = new PrinterImplType();
            newPrinter->setID(printerID);
            m_priterCache[printerID] = newPrinter;
            return newPrinter;
        }

        return printer;
    }

    PrinterType* getPrinterByID(const PrinterID& printerID)
    {
        try
        {
            return m_priterCache[printerID];
        }
        catch (std::out_of_range& e)
        {
            return 0;
        }
    }

    void enumerate(rho::Vector<rho::String>& printers)
    {
        std::map<PrinterID, PrinterType*>::const_iterator cit = m_priterCache.begin();
        std::map<PrinterID, PrinterType*>::const_iterator eit = m_priterCache.end();

        for (;cit != eit; ++cit)
        {
            printers.push_back(cit->first);
        }
    }

    static PrinterManager<PrinterType, PrinterImplType>* getInstance()
    {
        if (g_managerInstance == NULL)
        {
            g_managerInstance = new PrinterManager<PrinterType, PrinterImplType>();
        }

        return g_managerInstance;
    }
};

template<typename PrinterType, typename PrinterImplType>
PrinterManager<PrinterType, PrinterImplType>* PrinterManager<PrinterType, PrinterImplType>::g_managerInstance = 0;

}
}

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rhodes-7.6.0 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h
rhodes-7.5.1 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h
rhodes-7.4.1 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h
rhodes-7.1.17 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h
rhodes-6.2.0 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h
rhodes-6.0.11 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h
rhodes-5.5.18 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h
rhodes-5.5.17 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h
rhodes-5.5.15 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h
rhodes-5.5.0.22 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h
rhodes-5.5.2 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h
rhodes-5.5.0.7 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h
rhodes-5.5.0.3 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h
rhodes-5.5.0 lib/commonAPI/printing_zebra/ext/platform/wm/src/PrinterManager.h