OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimHistogramSource.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2000 ImageLinks Inc.
3 //
4 // License: LGPL
5 //
6 // See LICENSE.txt file in the top level directory for more details.
7 //
8 // Author: Garrett Potts
9 //
10 //*************************************************************************
11 // $Id: ossimHistogramSource.cpp 11721 2007-09-13 13:19:34Z gpotts $
12 
16 
17 RTTI_DEF1(ossimHistogramSource, "ossimHistogramSource", ossimSource);
18 
19 
21  ossim_uint32 numberOfInputs,
22  ossim_uint32 numberOfOutputs,
23  bool inputListFixedFlag,
24  bool outputListFixedFlag)
25  : ossimSource(owner,
26  numberOfInputs,
27  numberOfOutputs,
28  inputListFixedFlag,
29  outputListFixedFlag),
30  theHistogram(0),
31  theFilename()
32 {
33 }
34 
36 {
37 }
38 
40 {
41  return theHistogram;
42 }
43 
45  const char* prefix)
46 {
47  theHistogram = 0;
48  const char* externalFile = kwl.find(prefix,
50 
52  if(externalFile)
53  {
54  if(!theHistogram->importHistogram(ossimFilename(externalFile)))
55  {
56  theHistogram = 0;
57  theFilename = "";
58  }
59  theFilename = externalFile;
60  }
61  else
62  {
63  ossimString newPrefix = ossimString(prefix) + "histogram.";
64  if(!theHistogram->loadState(kwl, newPrefix))
65  {
66  theHistogram = 0;
67  }
68  }
69 
70  return ossimSource::loadState(kwl, prefix);
71 }
72 
74  const char* prefix)const
75 {
76  if(theHistogram.valid())
77  {
78  if(!theFilename.empty()) {
79  ossimKeywordlist kwl2;
80 
81  if(theHistogram->saveState(kwl2))
82  {
83  kwl2.write(theFilename.c_str());
84  kwl.add(prefix,
87  true);
88  }
89  }
90  else
91  {
92  ossimString newPrefix = ossimString(prefix) + "histogram.";
93  theHistogram->saveState(kwl, newPrefix);
94  }
95  }
96 
97  return ossimSource::saveState(kwl, prefix);
98 }
99 
100 // Hidden from use.
102  :
103  theHistogram(0),
104  theFilename()
105 {
106 }
virtual bool importHistogram(const ossimFilename &inputFile)
Represents serializable keyword/value map.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Definition: ossimSource.cpp:55
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Definition: ossimSource.cpp:66
const char * find(const char *key) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
virtual bool write(const char *file, const char *comment=0) const
Methods to dump the ossimKeywordlist to a file on disk.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
ossimRefPtr< ossimMultiResLevelHistogram > theHistogram
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
RTTI_DEF1(ossimHistogramSource, "ossimHistogramSource", ossimSource)
unsigned int ossim_uint32
ossimHistogramSource(ossimObject *owner=NULL, ossim_uint32 numberOfInputs=0, ossim_uint32 numberOfOutputs=0, bool inputListFixedFlag=true, bool outputListFixedFlag=true)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
bool empty() const
Definition: ossimString.h:411
static const char * FILENAME_KW
virtual ossimRefPtr< ossimMultiResLevelHistogram > getHistogram()
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const