clsparportdev.cpp

来自「set of classes for parallel port device 」· C++ 代码 · 共 67 行

CPP
67
字号
#include "clsparportdev.h"std::map<std::string,clsEpp19*> clsParportDev::m_mapDevices;clsEpp19*                       clsParportDev::m_pDefaultDevice = 0;//#############################################################################clsEpp19*   clsParportDev::Instance    ( const std::string& rDeviceName ){    if ( !rDeviceName.size() )        return m_pDefaultDevice;    std::map<std::string,clsEpp19*>::iterator oIt = m_mapDevices.find ( rDeviceName );    if ( oIt != m_mapDevices.end() )        return oIt->second;    clsEpp19* pDev = new clsEpp19 ( rDeviceName.c_str() );    if ( pDev )        m_mapDevices[rDeviceName] = pDev;    return pDev;}//#############################################################################void        clsParportDev::Destroy     ( const std::string& rDeviceName ){    if ( ! rDeviceName.size() )    {        for ( std::map<std::string,clsEpp19*>::iterator oIt = m_mapDevices.begin();              oIt != m_mapDevices.end(); ++oIt )        {            delete oIt->second;        }        m_mapDevices.clear();        m_pDefaultDevice = 0;    }    else    {        std::map<std::string,clsEpp19*>::iterator oIt = m_mapDevices.find ( rDeviceName );        if ( oIt != m_mapDevices.end() )        {            if ( m_pDefaultDevice == oIt->second )                m_pDefaultDevice = 0;            delete oIt->second;            m_mapDevices.erase ( oIt );        }    }}//#############################################################################int         clsParportDev::SetDefault  ( const std::string& rDeviceName ){    int iRet = 1;    if ( ! rDeviceName.size() )    {        std::map<std::string,clsEpp19*>::iterator oIt = m_mapDevices.find ( rDeviceName );        if ( oIt != m_mapDevices.end() )        {            m_pDefaultDevice = oIt->second;            iRet = 0;        }    }    return iRet;}//#############################################################################

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?