📄 printerfactory.cpp
字号:
{ szModelName = getPrinterProxy(theFamilyHandle)->GetNextModelName(theModelHandle); } return szModelName;} //GetNextModelName//GetNextPrinterName//! return the next printer name in the factory/*!This returns the next printer (model) name supported in the factory. Thisiterates over the whole factory without regard to families. PRINTER_HANDLE isupdated during this process.\returnName of the printer in the factory. Will be NULL after all the printers in thefactory have been enumerated.******************************************************************************/const char* PrinterFactory::GetNextPrinterName( PRINTER_HANDLE& thePrinterHandle //!< [in][out] handle to the printer) const{ TRACE("PF::GetNextPrinterName()\n"); static FAMILY_HANDLE familyHandle; nextPrinter(familyHandle, thePrinterHandle); return reinterpret_cast<const char*>(thePrinterHandle);} //GetNextPrinterName//nextFamily//! moves the family handle to the next family in the factory/*!updates the FAMILY_HANDLE to the next family in the factory. After the lastfamily in the factory the FAMILY_HANDLE will be NULL.\returntrue - there was another family in the factory (ie FAMILY_HANDLE is not NULL)<br>false - there were no more families in the factory (ie FAMILY_HANDLE is NULL)******************************************************************************/bool PrinterFactory::nextFamily( FAMILY_HANDLE& theFamilyHandle //!< [in][out] handle to the family) const{ TRACE("PF::nextFamily()\n"); bool bMore = true; const ProxyListElement* proxyList = getProxyListElement(theFamilyHandle); if (proxyList == NULL) { TRACE("PF::nextFamily - reset to head of list\n"); theFamilyHandle = s_ProxyList; } else { TRACE("PF::nextFamily - next element\n"); theFamilyHandle = proxyList->next; } if (theFamilyHandle == NULL) { TRACE("PF::nextFamily - NULL (end of list)\n"); bMore = false; } return bMore;} //nextFamily//EnumDevices//! moves the family handle to the next family in the factory/*!updates the FAMILY_HANDLE to the next family in the factory. After the lastfamily in the factory the FAMILY_HANDLE will be NULL.\returntrue - there was another family in the factory (ie FAMILY_HANDLE is not NULL)<br>false - there were no more families in the factory (ie FAMILY_HANDLE is NULL)******************************************************************************/const PRINTER_TYPE PrinterFactory::EnumDevices( FAMILY_HANDLE& theFamilyHandle) const{ TRACE("PF::EnumDevices()\n"); if (nextFamily(theFamilyHandle)) { return getPrinterProxy(theFamilyHandle)->GetPrinterType(); } else { return UNSUPPORTED; }}//nextPrinter//! determines of there is another printer in the factory/*! moves the modle handle to the next model in the family. If there are no moremodels in the family then it moves the family handle to the next family and themodel handle to the start of that families model list.both the family and model handels can be updated during this process. Both willbe NULL if there are no more printers in this iteration of the factory.\returntrue - there was another printer in the factory and the family/model handle references it<br>false - there were no more printers in the factory and both handles are NULL******************************************************************************/bool PrinterFactory::nextPrinter( FAMILY_HANDLE& theFamilyHandle, //!< [in][out] current family handle MODEL_HANDLE& theModelHandle //!< [in][out] current model handle) const{ TRACE("PF::nextPrinter(,)\n"); bool bMore = true; if (theFamilyHandle == NULL) //this is the first time through { theFamilyHandle = StartFamilyNameEnum(); if (nextFamily(theFamilyHandle)) { theModelHandle = StartModelNameEnum(theFamilyHandle); } else { bMore = false; // no families in the list goto EXIT; } } if (GetNextModelName(theFamilyHandle, theModelHandle) == NULL) //end of model list { if(nextFamily(theFamilyHandle)) { theModelHandle = StartModelNameEnum(theFamilyHandle); if (GetNextModelName(theFamilyHandle, theModelHandle) == NULL) { bMore = false; } } else { bMore = false; } }EXIT: { return bMore; }} //nextPrinter//FindDevIdMatch//! Find a match for a Device ID string in the factory/*!The device ID string can be a device ID string retrived from a printer or itcan be a simple model name or family name. This will walk through each familyin the factory and will check to see if it is a simple family or model stringand if not then will check for a valid device ID string.\returnA family handle based on the device ID string passed in.<br>NULL if there is no match.******************************************************************************/const FAMILY_HANDLE PrinterFactory::FindDevIdMatch( const char* szDevIdString //!< [in] well formed device id string) const{ TRACE("PF::FindDevIdMatch(%s)\n", szDevIdString); FAMILY_HANDLE myFamilyHandle = StartFamilyNameEnum(); bool bDevIDString = TRUE; if ((!strstr(szDevIdString, "MFG:") && !strstr(szDevIdString+2, "MFG:") && !strstr(szDevIdString, "MANUFACTURER:") && !strstr(szDevIdString+2, "MANUFACTURER:")) || (!strstr(szDevIdString, "MDL:") && !strstr(szDevIdString+2, "MDL:") && !strstr(szDevIdString, "MODEL:") && !strstr(szDevIdString+2, "MODEL:")) || ((szDevIdString[0] == '\0') && (szDevIdString[1] == '\0'))) { bDevIDString = FALSE; } while (nextFamily(myFamilyHandle)) { if (bDevIDString) { // check to see if a full device ID String match if (getPrinterProxy(myFamilyHandle)->DeviceMatchQuery(szDevIdString)) { break; // found it! } } else { // check the family and see if they passed a simple model string if (getPrinterProxy(myFamilyHandle)->ModelMatchQuery(szDevIdString)) { break; // found it! } } } // if we never had a match (i.e. did the break) then myFamilyHandle is NULL return myFamilyHandle;} //FindDevIdMatch//GetModelBits//! Get the bitwise return based on the registered family/*!\returnA bitwise int based on the family registered.<br0 if there is no printer registered.******************************************************************************/const unsigned int PrinterFactory::GetModelBits() const{ unsigned int bits=0; TRACE("PF::GetModelBits\n"); FAMILY_HANDLE myFamilyHandle = StartFamilyNameEnum(); while (nextFamily(myFamilyHandle)) { if (myFamilyHandle) { bits = bits | getPrinterProxy(myFamilyHandle)->GetModelBit(); } } return bits;} //GetModelBits//GetModelString//! Get the bitwise return based on the registered family/*!\returnconcatnated string based on the family registered.<brnull string if there is no printer registered.******************************************************************************/const void PrinterFactory::GetModelString( char* mresult) const{ assert(mresult); mresult[0] = '\0'; TRACE("PF::GetModelString\n"); FAMILY_HANDLE myFamilyHandle = StartFamilyNameEnum(); while (nextFamily(myFamilyHandle)) { HP_strcat(mresult, getPrinterProxy(myFamilyHandle)->GetFamilyName()); HP_strcat(mresult, " "); }} //GetModelBitsAPDK_END_NAMESPACE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -