aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llplugin/llplugininstance.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xlinden/indra/llplugin/llplugininstance.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/linden/indra/llplugin/llplugininstance.h b/linden/indra/llplugin/llplugininstance.h
new file mode 100755
index 0000000..9cf6075
--- /dev/null
+++ b/linden/indra/llplugin/llplugininstance.h
@@ -0,0 +1,106 @@
1/**
2 * @file llplugininstance.h
3 *
4 * @cond
5 * $LicenseInfo:firstyear=2008&license=viewergpl$
6 *
7 * Copyright (c) 2008-2010, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlife.com/developers/opensource/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at
21 * http://secondlife.com/developers/opensource/flossexception
22 *
23 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above,
25 * and agree to abide by those obligations.
26 *
27 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
28 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
29 * COMPLETENESS OR PERFORMANCE.
30 * $/LicenseInfo$
31 *
32 * @endcond
33 */
34
35#ifndef LL_LLPLUGININSTANCE_H
36#define LL_LLPLUGININSTANCE_H
37
38#include "llstring.h"
39#include "llapr.h"
40
41#include "apr_dso.h"
42
43/**
44 * @brief LLPluginInstanceMessageListener receives messages sent from the plugin loader shell to the plugin.
45 */
46class LLPluginInstanceMessageListener
47{
48public:
49 virtual ~LLPluginInstanceMessageListener();
50 /** Plugin receives message from plugin loader shell. */
51 virtual void receivePluginMessage(const std::string &message) = 0;
52};
53
54/**
55 * @brief LLPluginInstance handles loading the dynamic library of a plugin and setting up its entry points for message passing.
56 */
57class LLPluginInstance
58{
59 LOG_CLASS(LLPluginInstance);
60public:
61 LLPluginInstance(LLPluginInstanceMessageListener *owner);
62 virtual ~LLPluginInstance();
63
64 // Load a plugin dll/dylib/so
65 // Returns 0 if successful, APR error code or error code returned from the plugin's init function on failure.
66 int load(std::string &plugin_file);
67
68 // Sends a message to the plugin.
69 void sendMessage(const std::string &message);
70
71 // TODO:DOC is this comment obsolete? can't find "send_count" anywhere in indra tree.
72 // send_count is the maximum number of message to process from the send queue. If negative, it will drain the queue completely.
73 // The receive queue is always drained completely.
74 // Returns the total number of messages processed from both queues.
75 void idle(void);
76
77 /** The signature of the function for sending a message from plugin to plugin loader shell.
78 *
79 * @param[in] message_string Null-terminated C string
80 * @param[in] user_data The opaque reference that the callee supplied during setup.
81 */
82 typedef void (*sendMessageFunction) (const char *message_string, void **user_data);
83
84 /** The signature of the plugin init function. TODO:DOC check direction (pluging loader shell to plugin?)
85 *
86 * @param[in] host_user_data Data from plugin loader shell.
87 * @param[in] plugin_send_function Function for sending from the plugin loader shell to plugin.
88 */
89 typedef int (*pluginInitFunction) (sendMessageFunction host_send_func, void *host_user_data, sendMessageFunction *plugin_send_func, void **plugin_user_data);
90
91 /** Name of plugin init function */
92 static const char *PLUGIN_INIT_FUNCTION_NAME;
93
94private:
95 static void staticReceiveMessage(const char *message_string, void **user_data);
96 void receiveMessage(const char *message_string);
97
98 apr_dso_handle_t *mDSOHandle;
99
100 void *mPluginUserData;
101 sendMessageFunction mPluginSendMessageFunction;
102
103 LLPluginInstanceMessageListener *mOwner;
104};
105
106#endif // LL_LLPLUGININSTANCE_H