1 //*****************************************************************************
2 // FILE: ossimElevCellHandlerFactory.cc
3 //
4 // Copyright (C) 2001 ImageLinks, Inc.
5 //
6 // License:  LGPL
7 //
8 // See LICENSE.txt file in the top level directory for more details.
9 //
10 // DESCRIPTION:
11 //   Contains implementation of class ossimElevCellHandlerFactory. This is
12 //   a "super-factory" owning a list of subfactories for each particular DEM
13 //   format class.
14 //
15 //   NOT CURRENTLY UTILIZED -- USE DTED MANAGER
16 //
17 // LIMITATIONS:
18 //   The intention of this factory is to produce individual instances of
19 //   elevation cell handlers. Presently this is not supported since DTED is
20 //   the only elevation source being handled. DTED is loaded via the
21 //   ossimDtedManager class as a DB interface, and not by accessing individual
22 //   DTED handlers.
23 //
24 // SOFTWARE HISTORY:
25 //>
26 //   01Aug2001  Oscar Kramer (okramer@imagelinks.com)
27 //              Initial coding.
28 //<
29 //*****************************************************************************
30 //  $Id: ossimElevCellHandlerFactory.cpp 14800 2009-06-30 08:58:55Z dburken $
31 
32 #include <ossim/elevation/ossimElevCellHandlerFactory.h>
33 #include <ossim/base/ossimString.h>
34 
35 ossimElevCellHandlerFactory* ossimElevCellHandlerFactory::theInstance = 0;
36 
37 //*****************************************************************************
38 //  STATIC METHOD: instance()
39 //
40 //*****************************************************************************
instance()41 ossimElevCellHandlerFactory* ossimElevCellHandlerFactory::instance()
42 {
43    if(!theInstance)
44       theInstance = new ossimElevCellHandlerFactory;
45 
46    return (ossimElevCellHandlerFactory*) theInstance;
47 }
48 
49 //*****************************************************************************
50 //  PROTECTED DEFAULT CONSTRUCTOR: ossimElevCellHandlerFactory
51 //
52 //*****************************************************************************
ossimElevCellHandlerFactory()53 ossimElevCellHandlerFactory::ossimElevCellHandlerFactory()
54 {
55    //***
56    // Add default sub factories to this factory's registry list:
57    // NOTE: DTED handlers are managed by their own ossimDtedManager so should
58    // never be created individually via a factory. This will be the typical
59    // pattern for all but custom DEM files.
60    //***
61 //   registerFactory(ossimUsgsDemCellFactory::instance());
62 }
63 
64 
65 //*****************************************************************************
66 //  METHOD: ossimElevCellHandlerFactory::create(kwl, prefix)
67 //
68 //*****************************************************************************
69 ossimElevCellHandler*
create(const ossimKeywordlist & keywordList,const char * prefix) const70 ossimElevCellHandlerFactory::create(const ossimKeywordlist &keywordList,
71                                     const char *prefix) const
72 {
73    std::list<ossimFactoryBase<ossimElevCellHandler>*>::const_iterator
74       elevCellFactory;
75 
76    ossimElevCellHandler* product = 0;
77 
78    elevCellFactory = theRegistry.begin();
79    while((elevCellFactory != theRegistry.end()) && (!product))
80    {
81       product = (*elevCellFactory)->create(keywordList, prefix);
82       elevCellFactory++;
83    }
84 
85    return product;
86 }
87 
88 //*****************************************************************************
89 //  METHOD: ossimElevCellHandlerFactory::create(proj_name)
90 //
91 //*****************************************************************************
92 ossimElevCellHandler*
create(const ossimString & name) const93 ossimElevCellHandlerFactory::create(const ossimString &name) const
94 {
95    std::list<ossimFactoryBase<ossimElevCellHandler>*>::const_iterator
96       elevCellFactory;
97 
98    ossimElevCellHandler* product = 0;
99 
100    elevCellFactory = theRegistry.begin();
101    while((elevCellFactory != theRegistry.end()) && (!product))
102    {
103       product = (*elevCellFactory)->create(name);
104       elevCellFactory++;
105    }
106 
107    return product;
108 }
109 
110 //*****************************************************************************
111 //  METHOD: ossimElevCellHandlerFactory::getList()
112 //
113 //*****************************************************************************
getList() const114 std::list<ossimString> ossimElevCellHandlerFactory::getList() const
115 {
116    std::list<ossimString> rtn_list;
117    std::list<ossimString> sub_list;
118    std::list<ossimFactoryBase<ossimElevCellHandler>*>::const_iterator factory_iter;
119 
120    factory_iter = theRegistry.begin();
121    while(factory_iter != theRegistry.end())
122    {
123       sub_list = (*factory_iter)->getList();
124       rtn_list.merge(sub_list);
125       factory_iter++;
126    }
127 
128    return rtn_list;
129 }
130 
131