blob: 02bf921c882d4cdaffdd3ca62df4691e6e211886 [file] [log] [blame]
jat@google.com134be542009-08-03 15:30:11 +00001#ifndef _H_ServerMethods
2#define _H_ServerMethods
3/*
4 * Copyright 2008 Google Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
7 * use this file except in compliance with the License. You may obtain a copy of
8 * the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 * License for the specific language governing permissions and limitations under
16 * the License.
17 */
18
19#include "Value.h"
20
21class HostChannel;
22class SessionHandler;
23
24/**
25 * Encapsulates the methods defined on the special server object.
26 */
27class ServerMethods {
28public:
29 /**
30 * Get the value of a property on an object.
31 *
32 * @param objectRef ID of object to fetch field on
33 * @param dispatchID dispatch ID of field
34 * @return the value of the property, undef if none (or on error)
35 */
acleung@google.comcd201b72012-01-24 16:23:41 +000036 static gwt::Value getProperty(HostChannel& channel, SessionHandler* handler, int objectRef,
jat@google.com134be542009-08-03 15:30:11 +000037 int dispatchId);
38
39 /**
40 * Lookup the named method on the specified class.
41 *
42 * @return the dispatch ID (non-negative) of the method if present, or -1 if not.
43 * If an error is encountered, -2 is returned.
44 */
45 static int hasMethod(HostChannel& channel, SessionHandler* handler, int classId,
46 const std::string& name);
47
48 /**
49 * Lookup the named property on the specified class.
50 *
51 * @return the dispatch ID (non-negative) of the property if present, or -1 if not.
52 * If an error is encountered, -2 is returned.
53 */
54 static int hasProperty(HostChannel& channel, SessionHandler* handler, int classId,
55 const std::string& name);
56
57 /**
58 * Set the value of a property on an object.
59 *
60 * @param objectRef ID of object to fetch field on
61 * @param dispatchID dispatch ID of field
62 * @param value value to store in the property
63 * @return false if an error occurred
64 */
65 static bool setProperty(HostChannel& channel, SessionHandler* handler, int objectRef,
acleung@google.comcd201b72012-01-24 16:23:41 +000066 int dispatchId, const gwt::Value& value);
jat@google.com134be542009-08-03 15:30:11 +000067
68 /**
69 * Tell the server that the client no longer has any references to the specified
70 * Java object.
71 *
72 * @param objcetRef ID of object to free
73 * @return false if an error occurred
74 */
75 static bool freeJava(HostChannel& channel, SessionHandler* handler, int idCount, const int* ids);
76};
77
78#endif