Filename.h

Go to the documentation of this file.
00001 /*
00002  * The information in this file is
00003  * Copyright(c) 2007 Ball Aerospace & Technologies Corporation
00004  * and is subject to the terms and conditions of the
00005  * GNU Lesser General Public License Version 2.1
00006  * The license text is available from   
00007  * http://www.gnu.org/licenses/lgpl.html
00008  */
00009 
00010 #ifndef __FILENAME_H
00011 #define __FILENAME_H
00012 
00013 #include "Serializable.h"
00014 #include "DataVariantValidator.h"
00015 
00016 #include <string>
00017 #include <vector>
00018 
00019 /**
00020  * Provides capability for filename manipulation
00021  *
00022  * Filename provides a platform-independent interface for manipulating
00023  * operating system file paths and names. It allows developers to avoid
00024  * conditional compile directives yet still write portable code.
00025  *
00026  * @see      FileFinder
00027  */
00028 class Filename : public Serializable
00029 {
00030 public:
00031    /**
00032     *  Set/change the full path specification (directory, title and extension,
00033     *  if any).
00034     *
00035     *  @param   pathAndName
00036     *           A string with the file path information.
00037     *
00038     */
00039    virtual void setFullPathAndName(const std::string& pathAndName) = 0;
00040 
00041    /**
00042     *  Get the full path specification (directory, title and extension,
00043     *  if any).
00044     *
00045     *  @return  A string with the file path information.
00046     */
00047    virtual std::string getFullPathAndName() const = 0;
00048 
00049    /**
00050     *  Get the directory specification.The appropriate
00051     *  separator(s) will be used regardless of the original string, so the
00052     *  client need not worry about the platform portability.
00053     *
00054     *  @return A  string with the file extension.
00055     */
00056    virtual std::string getPath() const = 0;
00057 
00058    /**
00059     *  Get the file name (title and extension, if any).
00060     *
00061     *  @return  A string with the file name, absent any path information.
00062     */
00063    virtual std::string getFileName() const = 0;
00064 
00065    /**
00066     *  Get the file title.
00067     *
00068     *  @return  A string with the file title.
00069     */
00070    virtual std::string getTitle() const = 0;
00071 
00072    /**
00073     *  Get the extension, if any.
00074     *
00075     *  @return  A string with the file extension.
00076     */
00077    virtual std::string getExtension() const = 0;
00078 
00079    /**
00080     *  Checks whether the current filename is actually a directory.
00081     *
00082     *  @return  TRUE if the filename is a directory, otherwise FALSE.
00083     */
00084    virtual bool isDirectory() const = 0;
00085 
00086    /**
00087     *  Set the filename from a string.
00088     *
00089     *  This convenience function is equivalent to Filename::setFullPathAndName().
00090     *
00091     *  @param path
00092     *         The string path to set.
00093     *
00094     *  @return the string passed in as an argument.
00095     */
00096    virtual const std::string& operator=(const std::string& path) = 0;
00097 
00098    /**
00099     *  Equality operator.
00100     *
00101     *  Checks if two Filenames have identical full path and name representations.
00102     *
00103     *  @param other
00104     *         The other Filename to compare against.
00105     *
00106     *  @return true if the Filename objects do contain equal filenames.
00107     */
00108    virtual bool operator==(const Filename& other) const = 0;
00109 
00110    /**
00111     *  Inequality operator.
00112     *
00113     *  Checks if two Filenames do not have identical full path and name representations.
00114     *
00115     *  @param other
00116     *         The other Filename to compare against.
00117     *
00118     *  @return true if the Filename objects do not contain equal filenames.
00119     */
00120    virtual bool operator!=(const Filename& other) const = 0;
00121 
00122    /**
00123     *  Obtain a string representation of the Filename.
00124     *
00125     *  This convenience function is equivalent to Filename::getFullPathAndName().
00126     *
00127     *  @return A string representation of the Filename.
00128     */
00129    virtual operator std::string() const = 0;
00130   
00131 protected:
00132    /**
00133     * This should be destroyed by calling ObjectFactory::destroyObject.
00134     */
00135    virtual ~Filename() {}
00136 };
00137 
00138 /**
00139  * \cond INTERNAL
00140  * These template specialization are required to allow these types to be put into a DataVariant.
00141  */
00142 template <> class VariantTypeValidator<Filename> {};
00143 template <> class VariantTypeValidator<const Filename> {};
00144 template <> class VariantTypeValidator<std::vector<Filename*> > {};
00145 template <> class VariantTypeValidator<std::vector<const Filename*> > {};
00146 /// \endcond
00147 
00148 #endif

Software Development Kit - Opticks 4.9.0 Build 16218