xref: /haiku/src/add-ons/kernel/file_systems/netfs/shared/RequestFactory.cpp (revision 4052469d007d17112b0fdf8814c92c77414a1398)
1 // RequestFactory.cpp
2 
3 #include <new>
4 
5 #include "RequestFactory.h"
6 #include "Requests.h"
7 
8 // constructor
9 RequestFactory::RequestFactory()
10 {
11 }
12 
13 // destructor
14 RequestFactory::~RequestFactory()
15 {
16 }
17 
18 // CreateRequest
19 status_t
20 RequestFactory::CreateRequest(uint32 type, Request** request)
21 {
22 	if (!request)
23 		return B_BAD_VALUE;
24 	switch (type) {
25 		case INIT_CONNECTION_REQUEST:
26 			*request = new(std::nothrow) InitConnectionRequest;
27 			break;
28 		case INIT_CONNECTION_REPLY:
29 			*request = new(std::nothrow) InitConnectionReply;
30 			break;
31 		case MOUNT_REQUEST:
32 			*request = new(std::nothrow) MountRequest;
33 			break;
34 		case MOUNT_REPLY:
35 			*request = new(std::nothrow) MountReply;
36 			break;
37 		case UNMOUNT_REQUEST:
38 			*request = new(std::nothrow) UnmountRequest;
39 			break;
40 		case READ_VNODE_REQUEST:
41 			*request = new(std::nothrow) ReadVNodeRequest;
42 			break;
43 		case READ_VNODE_REPLY:
44 			*request = new(std::nothrow) ReadVNodeReply;
45 			break;
46 		case WRITE_STAT_REQUEST:
47 			*request = new(std::nothrow) WriteStatRequest;
48 			break;
49 		case WRITE_STAT_REPLY:
50 			*request = new(std::nothrow) WriteStatReply;
51 			break;
52 		case CREATE_FILE_REQUEST:
53 			*request = new(std::nothrow) CreateFileRequest;
54 			break;
55 		case CREATE_FILE_REPLY:
56 			*request = new(std::nothrow) CreateFileReply;
57 			break;
58 		case OPEN_REQUEST:
59 			*request = new(std::nothrow) OpenRequest;
60 			break;
61 		case OPEN_REPLY:
62 			*request = new(std::nothrow) OpenReply;
63 			break;
64 		case CLOSE_REQUEST:
65 			*request = new(std::nothrow) CloseRequest;
66 			break;
67 		case CLOSE_REPLY:
68 			*request = new(std::nothrow) CloseReply;
69 			break;
70 		case READ_REQUEST:
71 			*request = new(std::nothrow) ReadRequest;
72 			break;
73 		case READ_REPLY:
74 			*request = new(std::nothrow) ReadReply;
75 			break;
76 		case WRITE_REQUEST:
77 			*request = new(std::nothrow) WriteRequest;
78 			break;
79 		case WRITE_REPLY:
80 			*request = new(std::nothrow) WriteReply;
81 			break;
82 		case CREATE_LINK_REQUEST:
83 			*request = new(std::nothrow) CreateLinkRequest;
84 			break;
85 		case CREATE_LINK_REPLY:
86 			*request = new(std::nothrow) CreateLinkReply;
87 			break;
88 		case UNLINK_REQUEST:
89 			*request = new(std::nothrow) UnlinkRequest;
90 			break;
91 		case UNLINK_REPLY:
92 			*request = new(std::nothrow) UnlinkReply;
93 			break;
94 		case CREATE_SYMLINK_REQUEST:
95 			*request = new(std::nothrow) CreateSymlinkRequest;
96 			break;
97 		case CREATE_SYMLINK_REPLY:
98 			*request = new(std::nothrow) CreateSymlinkReply;
99 			break;
100 		case READ_LINK_REQUEST:
101 			*request = new(std::nothrow) ReadLinkRequest;
102 			break;
103 		case READ_LINK_REPLY:
104 			*request = new(std::nothrow) ReadLinkReply;
105 			break;
106 		case RENAME_REQUEST:
107 			*request = new(std::nothrow) RenameRequest;
108 			break;
109 		case RENAME_REPLY:
110 			*request = new(std::nothrow) RenameReply;
111 			break;
112 		case MAKE_DIR_REQUEST:
113 			*request = new(std::nothrow) MakeDirRequest;
114 			break;
115 		case MAKE_DIR_REPLY:
116 			*request = new(std::nothrow) MakeDirReply;
117 			break;
118 		case REMOVE_DIR_REQUEST:
119 			*request = new(std::nothrow) RemoveDirRequest;
120 			break;
121 		case REMOVE_DIR_REPLY:
122 			*request = new(std::nothrow) RemoveDirReply;
123 			break;
124 		case OPEN_DIR_REQUEST:
125 			*request = new(std::nothrow) OpenDirRequest;
126 			break;
127 		case OPEN_DIR_REPLY:
128 			*request = new(std::nothrow) OpenDirReply;
129 			break;
130 		case READ_DIR_REQUEST:
131 			*request = new(std::nothrow) ReadDirRequest;
132 			break;
133 		case READ_DIR_REPLY:
134 			*request = new(std::nothrow) ReadDirReply;
135 			break;
136 		case WALK_REQUEST:
137 			*request = new(std::nothrow) WalkRequest;
138 			break;
139 		case WALK_REPLY:
140 			*request = new(std::nothrow) WalkReply;
141 			break;
142 		case MULTI_WALK_REQUEST:
143 			*request = new(std::nothrow) MultiWalkRequest;
144 			break;
145 		case MULTI_WALK_REPLY:
146 			*request = new(std::nothrow) MultiWalkReply;
147 			break;
148 		case OPEN_ATTR_DIR_REQUEST:
149 			*request = new(std::nothrow) OpenAttrDirRequest;
150 			break;
151 		case OPEN_ATTR_DIR_REPLY:
152 			*request = new(std::nothrow) OpenAttrDirReply;
153 			break;
154 		case READ_ATTR_DIR_REQUEST:
155 			*request = new(std::nothrow) ReadAttrDirRequest;
156 			break;
157 		case READ_ATTR_DIR_REPLY:
158 			*request = new(std::nothrow) ReadAttrDirReply;
159 			break;
160 		case READ_ATTR_REQUEST:
161 			*request = new(std::nothrow) ReadAttrRequest;
162 			break;
163 		case READ_ATTR_REPLY:
164 			*request = new(std::nothrow) ReadAttrReply;
165 			break;
166 		case WRITE_ATTR_REQUEST:
167 			*request = new(std::nothrow) WriteAttrRequest;
168 			break;
169 		case WRITE_ATTR_REPLY:
170 			*request = new(std::nothrow) WriteAttrReply;
171 			break;
172 		case REMOVE_ATTR_REQUEST:
173 			*request = new(std::nothrow) RemoveAttrRequest;
174 			break;
175 		case REMOVE_ATTR_REPLY:
176 			*request = new(std::nothrow) RemoveAttrReply;
177 			break;
178 		case RENAME_ATTR_REQUEST:
179 			*request = new(std::nothrow) RenameAttrRequest;
180 			break;
181 		case RENAME_ATTR_REPLY:
182 			*request = new(std::nothrow) RenameAttrReply;
183 			break;
184 		case STAT_ATTR_REQUEST:
185 			*request = new(std::nothrow) StatAttrRequest;
186 			break;
187 		case STAT_ATTR_REPLY:
188 			*request = new(std::nothrow) StatAttrReply;
189 			break;
190 		case OPEN_QUERY_REQUEST:
191 			*request = new(std::nothrow) OpenQueryRequest;
192 			break;
193 		case OPEN_QUERY_REPLY:
194 			*request = new(std::nothrow) OpenQueryReply;
195 			break;
196 		case READ_QUERY_REQUEST:
197 			*request = new(std::nothrow) ReadQueryRequest;
198 			break;
199 		case READ_QUERY_REPLY:
200 			*request = new(std::nothrow) ReadQueryReply;
201 			break;
202 		case ENTRY_CREATED_REQUEST:
203 			*request = new(std::nothrow) EntryCreatedRequest;
204 			break;
205 		case ENTRY_REMOVED_REQUEST:
206 			*request = new(std::nothrow) EntryRemovedRequest;
207 			break;
208 		case ENTRY_MOVED_REQUEST:
209 			*request = new(std::nothrow) EntryMovedRequest;
210 			break;
211 		case ENTRY_STAT_CHANGED_REQUEST:
212 			*request = new(std::nothrow) StatChangedRequest;
213 			break;
214 		case ENTRY_ATTRIBUTE_CHANGED_REQUEST:
215 			*request = new(std::nothrow) AttributeChangedRequest;
216 			break;
217 		case SERVER_INFO_REQUEST:
218 			*request = new(std::nothrow) ServerInfoRequest;
219 			break;
220 		default:
221 			return B_BAD_VALUE;
222 	}
223 	return (*request ? B_OK : B_NO_MEMORY);
224 }
225 
226