DirectoryEntry.hpp 2.89 KB
Newer Older
Steven Murray's avatar
Steven Murray committed
1
2
#pragma once

3
#include <list>
4
#include <stdint.h>
Steven Murray's avatar
Steven Murray committed
5
6
7
8
#include <string>

namespace cta {

9
/**
Steven Murray's avatar
Steven Murray committed
10
 * A directory entry.
11
 */
Steven Murray's avatar
Steven Murray committed
12
13
class DirectoryEntry {
public:
14

Steven Murray's avatar
Steven Murray committed
15
16
17
18
  /**
   * Enumeration of the different possible type so directory entry.
   */
  enum EntryType {
Steven Murray's avatar
Steven Murray committed
19
    ENTRYTYPE_NONE,
Steven Murray's avatar
Steven Murray committed
20
21
22
23
24
25
26
27
28
29
    ENTRYTYPE_FILE,
    ENTRYTYPE_DIRECTORY};

  /**
   * Thread safe method that returns the string reprsentation of the specified
   * enumeration value.
   */
  static const char *entryTypeToStr(const EntryType enumValue) throw();

  /**
Steven Murray's avatar
Steven Murray committed
30
31
32
   * Constructor.
   *
   * Initialises all integer member-variables to 0.
Steven Murray's avatar
Steven Murray committed
33
   */
Steven Murray's avatar
Steven Murray committed
34
  DirectoryEntry();
Steven Murray's avatar
Steven Murray committed
35

36
  /**
Steven Murray's avatar
Steven Murray committed
37
38
39
40
41
42
43
44
   * Constructor.
   *
   * Initialises all integer member-variables to 0.
   *
   * @param entryType The type of the entry.
   * @param name The name of the directory entry.
   * @param storageClassName The name of the directory's storage class or an
   * empty string if the directory does not have a storage class.
45
   */
Steven Murray's avatar
Steven Murray committed
46
47
  DirectoryEntry(const EntryType entryType, const std::string &name,
    const std::string &storageClassName);
48

49
  /**
Steven Murray's avatar
Steven Murray committed
50
51
52
   * Returns the type of the directory entry.
   *
   * @return The type of the directory entry.
53
   */
54
  EntryType getType() const throw();
55
56

  /**
Steven Murray's avatar
Steven Murray committed
57
58
59
   * Returns the name of the directory entry.
   *
   * @return The name of the directory entry.
60
   */
Steven Murray's avatar
Steven Murray committed
61
  const std::string &getName() const throw();
62
63

  /**
Steven Murray's avatar
Steven Murray committed
64
65
66
   * Returns the user ID of the directory entry's owner.
   *
   * @return The user ID of the directory entry's owner.
67
   */
Steven Murray's avatar
Steven Murray committed
68
  uint32_t getOwnerId() const throw();
69

70
  /**
71
   * Returns the group ID of the directory entry.
Steven Murray's avatar
Steven Murray committed
72
73
   *
   * @return The group ID of the directory entry.
74
   */
Steven Murray's avatar
Steven Murray committed
75
  uint32_t getGroupId() const throw();
76

77
  /**
78
   * Returns the mode bits of the directory entry.
Steven Murray's avatar
Steven Murray committed
79
80
   *
   * @return The mode bits of the directory entry.
81
   */
Steven Murray's avatar
Steven Murray committed
82
  uint16_t getMode() const throw();
83
84

  /**
Steven Murray's avatar
Steven Murray committed
85
   * Sets the name of the storage class.
86
   *
Steven Murray's avatar
Steven Murray committed
87
   * @param storageClassName The name of the storage class.
88
   */
Steven Murray's avatar
Steven Murray committed
89
  void setStorageClassName(const std::string &storageClassName);
90

91
  /**
Steven Murray's avatar
Steven Murray committed
92
93
   * Returns the name of the directory's storage class or an empty string if the
   * directory does not have a storage class.
94
   *
Steven Murray's avatar
Steven Murray committed
95
96
   * @return The name of the directory's storage class or an empty string if the
   * directory does not have a storage class.
97
   */
Steven Murray's avatar
Steven Murray committed
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
  const std::string &getStorageClassName() const throw();

private:

  /**
   * The type of the directory entry.
   */
  EntryType m_entryType;

  /**
   * The name of the directory entry.
   */
  std::string m_name;

  /**
   * The user ID of the directory entry's owner.
   */
  uint32_t m_ownerId;

  /**
   * The group ID of the directory entry.
   */
  uint32_t m_groupId;

  /**
   * The mode bits of the directory entry.
   */
  uint16_t m_mode;

  /**
   * The name of the directory's storage class or an empty string if the
   * directory does not have a storage class.
   */
  std::string m_storageClassName;
132

133
}; // class DirectoryEntry
Steven Murray's avatar
Steven Murray committed
134
135

} // namespace cta