Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / printerproxy.h
1 /*****************************************************************************\
2   Copyright (c) 2002 - 2002, Hewlett-Packard Co.
3   All rights reserved.
4
5   Redistribution and use in source and binary forms, with or without
6   modification, are permitted provided that the following conditions
7   are met:
8   1. Redistributions of source code must retain the above copyright
9      notice, this list of conditions and the following disclaimer.
10   2. Redistributions in binary form must reproduce the above copyright
11      notice, this list of conditions and the following disclaimer in the
12      documentation and/or other materials provided with the distribution.
13   3. Neither the name of Hewlett-Packard nor the names of its
14      contributors may be used to endorse or promote products derived
15      from this software without specific prior written permission.
16
17   THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
18   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
20   NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22   TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
23   OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 \*****************************************************************************/
28 // PrinterProxy.h - Morpheus component code base
29
30 #if !defined(APDK_PRINTERPROXY_H)
31     #define APDK_PRINTERPROXY_H
32
33 APDK_BEGIN_NAMESPACE
34
35 typedef const void* MODEL_HANDLE;
36
37 //! Define voting ranges for the proxy voting system
38 typedef enum PROXY_VOTE
39 {
40     VOTE_NO_MATCH = 0,                      //!< can't do anything for this request
41     VOTE_LAST_DITCH_MATCH = 10,             //!< possible last ditch effort to do something
42     VOTE_POSSIBLE_MATCH = 50,               //!< might be able to generate output
43     VOTE_FAMILY_MATCH = 70,                 //!< matched by family
44     VOTE_VIP_MATCH = 80,                    //!< matched because it is a VIP printer
45     VOTE_SUBSTRING_MATCH = 90,              //!< a model was a substring of the full string
46     VOTE_EXACT_MATCH = 100                  //!< exact match id on this printer
47 } PROXY_VOTE;
48
49 // Specify a class prototype, otherwise "virtual printer" fails with error: ISO C++
50 // forbids declaration of "Printer" with no type
51 class Printer;
52
53 //PrinterProxy
54 //!Provide act on behalf of the printer class for matching, names, voting, etc
55 /*!
56 ******************************************************************************/
57 class PrinterProxy
58 {
59 public:
60     PrinterProxy
61     (
62         const char* szFamilyName,
63         const char* szModelNames
64     );
65
66     virtual ~PrinterProxy();                    // gcc wants it to be virtual
67
68     // Public API
69     inline const char* GetFamilyName() const { return m_szFamilyName; }
70     inline unsigned int GetModelCount() const { return m_uModelCount; }
71     virtual Printer* CreatePrinter(SystemServices* pSS) const = 0;
72         virtual PRINTER_TYPE GetPrinterType() const = 0;
73         virtual unsigned int GetModelBit() const = 0;
74
75     inline MODEL_HANDLE StartModelNameEnum() const { return NULL; }
76
77     const char* GetModelName(MODEL_HANDLE& theHandle) const;
78     const char* GetNextModelName(MODEL_HANDLE& theHandle) const;
79
80     PROXY_VOTE DeviceMatchQuery(const char* szDeviceString) const;
81     bool ModelMatchQuery(const char* szModelString) const;
82
83 protected:
84         PRINTER_TYPE m_iPrinterType;
85
86 private:
87     const char* m_szFamilyName;
88     const char* m_szModelNames;
89     unsigned int m_uModelCount;
90 }; //PrinterProxy
91
92 //GetModelName
93 //!Get the model name based on the handle
94 /*!
95 \return
96 model name based on the model handle
97 ******************************************************************************/
98 inline const char* PrinterProxy::GetModelName
99 (
100     MODEL_HANDLE& theModelHandle            //!< [in][out] handle to current model
101 ) const
102 {
103     TRACE("PP::GetModelName() returning %s\n", reinterpret_cast<const char*>(theModelHandle));
104     return reinterpret_cast<const char*>(theModelHandle);
105 } //GetNextModelName
106
107 APDK_END_NAMESPACE
108
109 #endif //APDK_PRINTERPROXY_H