MPEG CDVA Experimentation Model (CXM)  1.0
Compact Descriptors for Visual Analisys
FileManager.h
Go to the documentation of this file.
1 /*
2 The copyright in this software is being made available under this MPEG Reference Software Copyright License. This software may be subject to other third party and contributor rights, including patent rights, and no such rights are granted under this license.
3 
4 Copyright (c) 2016, Telecom Italia
5 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8 * Neither the name of Telecom Italia nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10  */
11 
12 #pragma once
13 
14 #include <string>
15 #include <vector>
16 
17 namespace mpeg7cdva
18 {
19 
26 class FileManager {
27 private:
28  std::vector<std::string> lines;
29  std::string datasetBaseDir;
30  std::string datasetName;
31  std::string workspaceDir;
32  size_t ds_size; // number of elements in the dataset
33  int irlevel; // include recursion level
34  bool hasWorkspaceDir;
35 
41  size_t readAnnotation(const char * filepathname);
42 
47  void appendAnnotation(std::string line);
48 
49 public:
50 
56  FileManager(const char * annotationpathname, int level = 0);
57 
58  virtual ~FileManager();
59 
64  std::string getDatasetPath() const;
65 
70  std::string getDatasetName() const;
71 
76  std::string getDatasetPathName() const;
77 
82  void setWorkspaceDir(const char * workdir);
83 
88  std::string getWorkspaceDir() const;
89 
90 
95  size_t getDatasetSize() const;
96 
103  std::string replaceExt(const std::string & imageName, const char * ext) const;
104 
111  static std::string replacePath(const std::string & imageName, const char * newpath);
112 
120  std::string getQueryName(size_t i, bool absolutePathname = true) const;
121 
129  std::string getReferenceName(size_t i, bool absolutePathname = true) const;
130 
136  int countNames(size_t i) const;
137 };
138 
139 } // end namespace
FileManager(const char *annotationpathname, int level=0)
Read the list of images from the given annotation file.
Helper class to manage lists of file names.
Definition: FileManager.h:26
std::string getQueryName(size_t i, bool absolutePathname=true) const
Get the first image name found at the i-th position in the annotation file.
int countNames(size_t i) const
Count how many pathnames are contained in the i-th line.
std::string replaceExt(const std::string &imageName, const char *ext) const
Convert a pathname into a pathname with the given extension.
Namespace used to encapsulate all MPEG-7 CDVA declarations.
Definition: Buffer.h:14
size_t getDatasetSize() const
Get the dataset size.
std::string getReferenceName(size_t i, bool absolutePathname=true) const
Get the second image name found at the i-th position in the annotation file.
std::string getDatasetPath() const
Get the dataset base directory.
void setWorkspaceDir(const char *workdir)
Set the workspace directory.
std::string getDatasetPathName() const
Get the dataset full pathname.
static std::string replacePath(const std::string &imageName, const char *newpath)
Convert a pathname into a pathname with the given new path.
std::string getWorkspaceDir() const
Get the workspace directory.
std::string getDatasetName() const
Get the dataset name.