| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkDirectory.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:35 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
|
#ifndef __itkDirectory_h |
| 18 |
|
#define __itkDirectory_h |
| 19 |
|
|
| 20 |
|
#include "itkObject.h" |
| 21 |
|
#include "itkObjectFactory.h" |
| 22 |
|
#include <iostream> |
| 23 |
|
#include <string> |
| 24 |
|
#include <vector> |
| 25 |
|
|
| 26 |
|
namespace itk |
| 27 |
|
{ |
| 28 |
|
/** \class Directory |
| 29 |
|
* \brief Portable directory/filename traversal. |
| 30 |
|
* |
| 31 |
|
* itkDirectory provides a portable way of finding the names of the files |
| 32 |
|
* in a system directory. |
| 33 |
|
* |
| 34 |
|
* itkDirectory works with windows and unix only. |
| 35 |
|
* \ingroup OSSystemObjects |
| 36 |
|
*/ |
| 37 |
|
|
| 38 |
|
|
| 39 |
|
class ITKCommon_EXPORT Directory : public Object |
| 40 |
|
{ |
| 41 |
|
public: |
| 42 |
|
/** Standard class typedefs. */ |
| 43 |
|
typedef Directory Self; |
| 44 |
TDA |
typedef Object Superclass; |
| 45 |
|
typedef SmartPointer<Self> Pointer; |
| 46 |
TDA |
typedef SmartPointer<const Self> ConstPointer; |
| 47 |
|
|
| 48 |
|
/** Method for creation through the object factory. */ |
| 49 |
|
static Pointer New() |
| 50 |
|
{ Pointer n = new Self; n->UnRegister(); return n; } |
| 51 |
|
|
| 52 |
|
/** Return the class name as a string. */ |
| 53 |
|
itkTypeMacro(Directory,Object); |
| 54 |
|
|
| 55 |
|
/** Load the specified directory and load the names of the files |
| 56 |
|
* in that directory. 0 is returned if the directory can not be |
| 57 |
|
* opened, 1 if it is opened. */ |
| 58 |
|
bool Load(const char* dir); |
| 59 |
|
|
| 60 |
|
/** Return the number of files in the current directory. */ |
| 61 |
LEN |
std::vector<std::string>::size_type GetNumberOfFiles() { return m_Files.size();} |
| 62 |
|
|
| 63 |
|
/** Return the file at the given index, the indexing is 0 based */ |
| 64 |
|
const char* GetFile(unsigned int index); |
| 65 |
|
|
| 66 |
|
protected: |
| 67 |
|
Directory(); |
| 68 |
SEM |
~Directory() ; |
| 69 |
|
virtual void PrintSelf(std::ostream& os, Indent indent) const; |
| 70 |
|
|
| 71 |
|
private: |
| 72 |
|
Directory(const Self&); //purposely not implemented |
| 73 |
|
void operator=(const Self&); //purposely not implemented |
| 74 |
|
|
| 75 |
|
std::vector<std::string> m_Files; // Array of Files |
| 76 |
|
std::string m_Path; // Path to Open'ed directory |
| 77 |
|
}; // End Class: Directory |
| 78 |
|
|
| 79 |
|
} // end namespace itk |
| 80 |
|
|
| 81 |
|
#endif |
| 82 |
|
|