1 //
2 // This file is part of the SDTS++ toolkit, written by the U.S.
3 // Geological Survey.  It is experimental software, written to support
4 // USGS research and cartographic data production.
5 //
6 // SDTS++ is public domain software.  It may be freely copied,
7 // distributed, and modified.  The USGS welcomes user feedback, but makes
8 // no committment to any level of support for this code.  See the SDTS
9 // web site at http://mcmcweb.er.usgs.gov/sdts for more information,
10 // including points of contact.
11 //
12 #ifndef INCLUDED_SIO_CONVERTERFACTORY_H
13 #define INCLUDED_SIO_CONVERTERFACTORY_H
14 
15 #include <string>
16 #include <memory>
17 
18 
19 
20 class sio_8211Converter;
21 
22 
23 /// opaque implementation structure for ConverterFactory
24 struct ConverterFactory_Imp;
25 
26 
27 /**
28 
29    This is a convenience class for creating an appropriate converter
30    based on a string that dictates an SDTS data represenation.
31 
32  */
33 class sio_ConverterFactory
34 {
35    public:
36 
37       /// return a converter that matches the given type
38       /**
39 
40          The type is one of:
41 
42             A: graphic characters, alphanumeric characters, or
43                alphabetic characters.
44             I: implicit-point (integer)
45             R: explicit-point unscaled (fixed point real)
46             S: explicit-point scaled (floating point real)
47             B: bitfield data NOT SUPPORTED
48             C: character mode bitfield (binary in zero and one characters)
49                NOT SUPPORTED
50 
51          The 'B' type may have additional qualification as follows:
52             BI8:    8 bit signed integer
53             BI16:   16 bit signed integer
54             BI24:   24 bit signed integer
55             BI32:   32 bit signed integer
56             BUI:    unsigned integer, length specified by implementation
57             BUI8:   8 bit unsigned integer
58             BUI16:  16 bit unsigned integer
59             BUI24:  24 bit unsigned integer
60             BUI32:  32 bit unsigned integer
61             BFP32:  32 bit floating point real
62             BFP64:  64 bit floating point real
63 
64        */
65       sio_8211Converter * get( std::string const & type );
66 
67       /// return the canonical instance of the converter factory
68       static sio_ConverterFactory * instance();
69 
70    private:
71 
72       /// private because this is a Singleton
73       sio_ConverterFactory();
74 
75       /// implementation detail
76       std::auto_ptr<ConverterFactory_Imp> imp_;
77 
78       static std::auto_ptr<sio_ConverterFactory> instance_;
79 
80 }; // class sio_ConverterFactory
81 
82 #endif
83