KSquare Utilities
KKB::ImageDirTree Class Reference

Creates a index of all images in a specified directory structure. More...

#include <ImageDirTree.h>

Public Member Functions

 ImageDirTree (KKStr _subDir)
 Construct a Index of images for a specified SubDirectory structure. details Given a specified directory '_subDir' will scan for all images in all sub-directories below it. More...
 
 ~ImageDirTree ()
 
KKStrListPtr Directories (const KKStr &fileName) const
 Returns list of directories that 'fileName' occurs in. More...
 
KKStrConstPtr LocateImage (const KKStr &fileName)
 Locate image specified by 'fileName' and return the directory where it is located. More...
 
kkuint32 Size ()
 returns the number of image files found the sub-directory tree. More...
 

Detailed Description

Creates a index of all images in a specified directory structure.

Given a SubDirectory Starting Point. Will create a list of all image files in the sub directory tree. This will allow us to quickly locate a image file by name. Originally developed it to help in the recalculation of feature data. Used in ImageFeaturesList.

Definition at line 22 of file ImageDirTree.h.

Constructor & Destructor Documentation

ImageDirTree::ImageDirTree ( KKStr  _subDir)

Construct a Index of images for a specified SubDirectory structure. details Given a specified directory '_subDir' will scan for all images in all sub-directories below it.

Parameters
[in]_subDirSub Directory to search for image files.

Definition at line 27 of file ImageDirTree.cpp.

References KKB::KKStr::KKStr().

Referenced by KKMLL::GrayScaleImagesFVList::RecalcFeatureValuesFromImagesInDirTree().

27  :
28  subDir (_subDir)
29 {
30  Load (_subDir);
31 }
ImageDirTree::~ImageDirTree ( )

Definition at line 35 of file ImageDirTree.cpp.

36 {
37  kkuint32 x;
38  for (x = 0; x < directories.size (); x++)
39  delete directories[x];
40 }
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89

Member Function Documentation

KKStrListPtr ImageDirTree::Directories ( const KKStr fileName) const

Returns list of directories that 'fileName' occurs in.

The caller will own the list of directories and be responsible for deleting. if 'fileName' does not exist in the sub-directory structure then NULL will be returned.

Parameters
[in]fileNameName of image file that is being searched for.
Returns
List of directories that contain a image with the name specified by 'fileName'. If the file does not exist a NULL will be returned. The caller will own the string list returned.

Definition at line 133 of file ImageDirTree.cpp.

References KKB::KKStrList::KKStrList().

134 {
135  EntryTable::const_iterator p;
136  p = entries.find (fileName);
137  if (p == entries.end ())
138  return NULL;
139 
140  KKStrListPtr dirList = new KKStrList (true);
141  while (p != entries.end ())
142  {
143  if (p->first != fileName)
144  break;
145  dirList->PushOnBack (new KKStr ((*p->second)));
146  }
147 
148  return dirList;
149 } /* Directories */
virtual void PushOnBack(EntryPtr _entry)
Definition: KKQueue.h:398
KKStrConstPtr ImageDirTree::LocateImage ( const KKStr fileName)

Locate image specified by 'fileName' and return the directory where it is located.

Parameters
[in]fileNameImage File you are searching for.
Returns
Pointer to directory where 'fileName' is found.

Definition at line 116 of file ImageDirTree.cpp.

Referenced by KKMLL::GrayScaleImagesFVList::RecalcFeatureValuesFromImagesInDirTree().

117 {
118  EntryTable::const_iterator p;
119 
120  p = entries.find (fileName);
121  if (p == entries.end ())
122  return NULL;
123 
124  if (p->first == fileName)
125  return p->second;
126 
127  return NULL;
128 } /* LocateImage */
kkuint32 KKB::ImageDirTree::Size ( )
inline

returns the number of image files found the sub-directory tree.

Definition at line 43 of file ImageDirTree.h.

Referenced by KKMLL::GrayScaleImagesFVList::RecalcFeatureValuesFromImagesInDirTree().

43 {return (kkuint32)entries.size ();}
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89

The documentation for this class was generated from the following files: