nidas  v1.2-1520
FsMount.h
Go to the documentation of this file.
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2 // vim: set shiftwidth=4 softtabstop=4 expandtab:
3 /*
4  ********************************************************************
5  ** NIDAS: NCAR In-situ Data Acquistion Software
6  **
7  ** 2009, Copyright University Corporation for Atmospheric Research
8  **
9  ** This program is free software; you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation; either version 2 of the License, or
12  ** (at your option) any later version.
13  **
14  ** This program is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** The LICENSE.txt file accompanying this software contains
20  ** a copy of the GNU General Public License. If it is not found,
21  ** write to the Free Software Foundation, Inc.,
22  ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  **
24  ********************************************************************
25 */
26 
27 #ifndef NIDAS_CORE_FSMOUNT_H
28 #define NIDAS_CORE_FSMOUNT_H
29 
30 #include <nidas/util/Thread.h>
31 #include <nidas/util/Process.h>
32 #include <nidas/util/IOException.h>
33 
34 #include "DOMable.h"
35 
36 #include <sys/mount.h>
37 
38 #include <string>
39 #include <iostream>
40 
41 namespace nidas { namespace core {
42 
43 using namespace nidas::core;
44 
45 class FileSet;
47 
51 class FsMount : public DOMable {
52 
53 public:
54 
55  FsMount();
56 
60  FsMount(const FsMount& x);
61 
62  ~FsMount() {}
63 
67  FsMount& operator=(const FsMount& rhs);
68 
73  void setDir(const std::string& val);
74 
75  const std::string& getDir() const { return _dir; }
76 
80  const std::string& getDirExpanded() const { return _dirExpanded; }
81 
82  void setDevice(const std::string& val);
83 
84  const std::string& getDevice() const { return _device; }
85 
86  const std::string& getDeviceExpanded() const { return _deviceExpanded; }
87 
88  void setType(const std::string& val)
89  {
90  _type = val;
91  }
92 
93  const std::string& getType() const { return _type; }
94 
95  void setOptions(const std::string& val)
96  {
97  _options = val;
98  }
99 
100  const std::string& getOptions() const { return _options; }
101 
105  bool isMounted();
106 
110  void mount() throw(nidas::util::IOException);
111 
117  void autoMount() throw(nidas::util::IOException);
118 
124  void mount(FileSet*) throw(nidas::util::IOException);
125 
126  void unmount() throw(nidas::util::IOException);
127 
128  void cancel();
129 
130  void finished();
131 
132  void fromDOMElement(const xercesc::DOMElement* node)
133  throw(nidas::util::InvalidParameterException);
134 
135 protected:
136 
137  std::string _dir;
138 
139  std::string _dirExpanded;
140 
141  std::string _dirMsg;
142 
143  std::string _device;
144 
145  std::string _deviceExpanded;
146 
147  std::string _deviceMsg;
148 
149  std::string _type;
150 
151  std::string _options;
152 
153  FileSet* _fileset;
154 
156 
157  nidas::util::Mutex _workerLock;
158 
159  nidas::util::Process _mountProcess;
160 
161  nidas::util::Process _umountProcess;
162 
163 };
164 
168 class FsMountWorkerThread : public nidas::util::Thread
169 {
170 public:
172  int run() throw(nidas::util::Exception);
173 
174 private:
176 
181 
185  FsMountWorkerThread& operator=(const FsMountWorkerThread&);
186 };
187 
188 }} // namespace nidas namespace core
189 
190 #endif
const std::string & getDirExpanded() const
Get the mount point directory, with environment variables expanded.
Definition: FsMount.h:80
Filesystem mounter/unmounter.
Definition: FsMount.h:51
void setType(const std::string &val)
Definition: FsMount.h:88
Implementation of an IOChannel using an nidas::util::FileSet.
Definition: FileSet.h:42
const std::string & getDir() const
Definition: FsMount.h:75
const std::string & getType() const
Definition: FsMount.h:93
const std::string & getDevice() const
Definition: FsMount.h:84
Interface of an object that can be instantiated from a DOM element, via the fromDOMElement method...
Definition: DOMable.h:51
Definition: Exception.h:35
FsMount * fsmount
Definition: FsMount.h:175
Filesystem mounter/unmounter.
Definition: FsMount.h:168
~FsMount()
Definition: FsMount.h:62
const std::string & getDeviceExpanded() const
Definition: FsMount.h:86
void setOptions(const std::string &val)
Definition: FsMount.h:95
const std::string & getOptions() const
Definition: FsMount.h:100