KSquare Utilities
ImageDirTree.h
Go to the documentation of this file.
1 /* ImageDirTree.h -- Builds list of Image Files in a Sub Directory Tree.
2  * Copyright (C) 1994-2014 Kurt Kramer
3  * For conditions of distribution and use, see copyright notice in KKB.h
4  */
5 #ifndef _IMAGEDIRTREE_
6 #define _IMAGEDIRTREE_
7 
8 //typedef vector<DirEntryPtr> DirEntryList;
9 
10 
11 #include "KKStr.h"
12 
13 
14 namespace KKB
15 {
16  /**
17  *@brief Creates a index of all images in a specified directory structure.
18  *@details Given a SubDirectory Starting Point. Will create a list of all image files in the sub directory
19  * tree. This will allow us to quickly locate a image file by name. Originally developed it to help in the
20  * recalculation of feature data. Used in ImageFeaturesList.
21  */
23  {
24  public:
25  /**
26  *@brief Construct a Index of images for a specified SubDirectory structure.
27  * details Given a specified directory '_subDir' will scan for all images in all sub-directories below it.
28  *@param[in] _subDir Sub Directory to search for image files.
29  */
30  ImageDirTree (KKStr _subDir);
31 
32  ~ImageDirTree ();
33 
34  /**
35  *@brief Locate image specified by 'fileName' and return the directory where it is located.
36  *@param[in] fileName Image File you are searching for.
37  *@return Pointer to directory where 'fileName' is found.
38  */
39  KKStrConstPtr LocateImage (const KKStr& fileName);
40 
41 
42  /** @brief returns the number of image files found the sub-directory tree. */
43  kkuint32 Size () {return (kkuint32)entries.size ();}
44 
45 
46  /**
47  *@brief Returns list of directories that 'fileName' occurs in.
48  *@details The caller will own the list of directories and be responsible for deleting. if 'fileName' does not exist
49  * in the sub-directory structure then NULL will be returned.
50  *@param[in] fileName Name of image file that is being searched for.
51  *@return List of directories that contain a image with the name specified by 'fileName'. If the file does not exist
52  * a NULL will be returned. The caller will own the string list returned.
53  */
54  KKStrListPtr Directories (const KKStr& fileName) const;
55 
56  private:
57  typedef map<KKStr,kkint32> DuplicateTable;
58  typedef multimap<KKStr,KKStrPtr> EntryTable;
59 
60  void Load (const KKStr& _subDir);
61 
62  EntryTable entries;
63  DuplicateTable duplicates; /*!< List of Image File Names that are duplicated. */
64 
65  vector<KKStrPtr> directories; /*!< List of directories that are searched. */
66 
67  KKStr subDir;
68  };
69 } /* namespace KKB */
70 
71 #endif
kkuint32 Size()
returns the number of image files found the sub-directory tree.
Definition: ImageDirTree.h:43
Creates a index of all images in a specified directory structure.
Definition: ImageDirTree.h:22
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
KKTHread * KKTHreadPtr
KKStrConstPtr LocateImage(const KKStr &fileName)
Locate image specified by &#39;fileName&#39; and return the directory where it is located.
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
ImageDirTree(KKStr _subDir)
Construct a Index of images for a specified SubDirectory structure. details Given a specified directo...
KKStrListPtr Directories(const KKStr &fileName) const
Returns list of directories that &#39;fileName&#39; occurs in.