Data Access Library (DAL)
|
00001 /* Copyright 2011-2012 ASTRON, Netherlands Institute for Radio Astronomy 00002 * This file is part of the Data Access Library (DAL). 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 3 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 #ifndef DAL_NODE_H 00018 #define DAL_NODE_H 00019 00020 #include <string> 00021 #include <vector> 00022 #include <typeinfo> 00023 #include "types/hid_gc.h" 00024 #include "types/FileInfo.h" 00025 #include "types/versiontype.h" 00026 00027 namespace dal { 00028 00029 class Group; 00030 00034 class Node { 00035 public: 00043 typedef /*FileInfo::FileMode*/int FileMode; // TODO: have SWIG declare FileInfo::FileMode constants, also as Node members 00044 // Not an enum, because enums cannot be forward declared (until C++11) and 00045 // we (only) need all values here. The enum here instead would give a circular dep with FileInfo. 00046 //static const FileMode NONE = 0; // value used in FileInfoType only 00047 static const FileMode READ = 1; 00048 static const FileMode READWRITE = 2; 00049 static const FileMode CREATE = 3; 00050 static const FileMode CREATE_EXCL = 4; 00051 00052 00053 Node(); 00054 00055 Node( Group &parent, const std::string &name ); 00056 00057 virtual ~Node(); 00058 00059 Node& operator=(Node rhs); 00060 00061 friend void swap(Node& first, Node& second); 00062 00066 std::string name() const { return _name; } 00067 00098 virtual bool exists() const { return false; } 00099 00140 bool supported() { return minVersion <= fileInfoVersion(); } 00141 00142 /* 00143 std::string className() const { return typeid(*this).name(); } 00144 */ 00145 00163 const std::string& filename() const; 00164 00166 FileMode fileMode() const; 00167 00195 bool canWrite() const; 00196 00198 const std::string& versionAttrName() const; 00199 00200 protected: 00201 hid_gc parent; 00202 std::string _name; 00203 00231 VersionType minVersion; // TODO: move this elsewhere? 00232 00233 FileInfo fileInfo; // proxy/reference object to reference-counted structure 00234 00236 Node( const hid_gc &parent, const std::string &name, FileInfo fileInfo); 00237 00242 int fileDirfd() const; 00243 00247 VersionType& fileInfoVersion() const; // keep protected to avoid escaped dangling ref in applications 00248 00253 void setFileInfoVersion(const VersionType& newVersion); 00254 }; 00255 00256 } 00257 00258 #endif 00259