diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llmessage/llservice.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llmessage/llservice.h')
-rw-r--r-- | linden/indra/llmessage/llservice.h | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llservice.h b/linden/indra/llmessage/llservice.h new file mode 100644 index 0000000..3866dbc --- /dev/null +++ b/linden/indra/llmessage/llservice.h | |||
@@ -0,0 +1,186 @@ | |||
1 | /** | ||
2 | * @file llservice.h | ||
3 | * @author Phoenix | ||
4 | * @date 2004-11-21 | ||
5 | * @brief Declaration file for LLService and related classes. | ||
6 | * | ||
7 | * Copyright (c) 2004-2007, Linden Research, Inc. | ||
8 | * | ||
9 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
10 | * to you under the terms of the GNU General Public License, version 2.0 | ||
11 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
12 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
13 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
14 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
15 | * | ||
16 | * There are special exceptions to the terms and conditions of the GPL as | ||
17 | * it is applied to this Source Code. View the full text of the exception | ||
18 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
19 | * online at http://secondlife.com/developers/opensource/flossexception | ||
20 | * | ||
21 | * By copying, modifying or distributing this software, you acknowledge | ||
22 | * that you have read and understood your obligations described above, | ||
23 | * and agree to abide by those obligations. | ||
24 | * | ||
25 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
26 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
27 | * COMPLETENESS OR PERFORMANCE. | ||
28 | */ | ||
29 | |||
30 | #ifndef LL_LLSERVICE_H | ||
31 | #define LL_LLSERVICE_H | ||
32 | |||
33 | #include <string> | ||
34 | #include <map> | ||
35 | //#include <boost/intrusive_ptr.hpp> | ||
36 | //#include <boost/shared_ptr.hpp> | ||
37 | |||
38 | //#include "llframetimer.h" | ||
39 | #include "lliopipe.h" | ||
40 | #include "llchainio.h" | ||
41 | |||
42 | #if 0 | ||
43 | class LLServiceCreator; | ||
44 | /** | ||
45 | * intrusive pointer support | ||
46 | */ | ||
47 | namespace boost | ||
48 | { | ||
49 | void intrusive_ptr_add_ref(LLServiceCreator* p); | ||
50 | void intrusive_ptr_release(LLServiceCreator* p); | ||
51 | }; | ||
52 | #endif | ||
53 | |||
54 | /** | ||
55 | * @class LLServiceCreator | ||
56 | * @brief This class is an abstract base class for classes which create | ||
57 | * new <code>LLService</code> instances. | ||
58 | * | ||
59 | * Derive classes from this class which appropriately implement the | ||
60 | * <code>operator()</code> and destructor. | ||
61 | * @see LLService | ||
62 | */ | ||
63 | #if 0 | ||
64 | class LLServiceCreator | ||
65 | { | ||
66 | public: | ||
67 | typedef boost::intrusive_ptr<LLService> service_t; | ||
68 | virtual ~LLServiceCreator() {} | ||
69 | virtual service_t activate() = 0; | ||
70 | virtual void discard() = 0; | ||
71 | |||
72 | protected: | ||
73 | LLServiceCreator() : mReferenceCount(0) | ||
74 | { | ||
75 | } | ||
76 | |||
77 | private: | ||
78 | friend void boost::intrusive_ptr_add_ref(LLServiceCreator* p); | ||
79 | friend void boost::intrusive_ptr_release(LLServiceCreator* p); | ||
80 | U32 mReferenceCount; | ||
81 | }; | ||
82 | #endif | ||
83 | |||
84 | #if 0 | ||
85 | namespace boost | ||
86 | { | ||
87 | inline void intrusive_ptr_add_ref(LLServiceCreator* p) | ||
88 | { | ||
89 | ++p->mReferenceCount; | ||
90 | } | ||
91 | inline void intrusive_ptr_release(LLServiceCreator* p) | ||
92 | { | ||
93 | if(0 == --p->mReferenceCount) | ||
94 | { | ||
95 | delete p; | ||
96 | } | ||
97 | } | ||
98 | }; | ||
99 | #endif | ||
100 | |||
101 | /** | ||
102 | * @class LLService | ||
103 | * @brief This class is the base class for the service classes. | ||
104 | * @see LLIOPipe | ||
105 | * | ||
106 | * The services map a string to a chain factory with a known interface | ||
107 | * at the front of the chain. So, to activate a service, call | ||
108 | * <code>activate()</code> with the name of the service needed which | ||
109 | * will call the associated factory, and return a pointer to the | ||
110 | * known interface. | ||
111 | * <b>NOTE:</b> If you are implementing a service factory, it is | ||
112 | * vitally important that the service pipe is at the front of the | ||
113 | * chain. | ||
114 | */ | ||
115 | class LLService : public LLIOPipe | ||
116 | { | ||
117 | public: | ||
118 | //typedef boost::intrusive_ptr<LLServiceCreator> creator_t; | ||
119 | //typedef boost::intrusive_ptr<LLService> service_t; | ||
120 | typedef boost::shared_ptr<LLChainIOFactory> creator_t; | ||
121 | |||
122 | /** | ||
123 | * @brief This method is used to register a protocol name with a | ||
124 | * a functor that creates the service. | ||
125 | * | ||
126 | * THOROUGH_DESCRIPTION | ||
127 | * @param aParameter A brief description of aParameter. | ||
128 | * @return Returns true if a service was successfully registered. | ||
129 | */ | ||
130 | static bool registerCreator(const std::string& name, creator_t fn); | ||
131 | |||
132 | /** | ||
133 | * @brief This method connects to a service by name. | ||
134 | * | ||
135 | * @param name The name of the service to connect to. | ||
136 | * @param chain The constructed chain including the service instance. | ||
137 | * @param context Context for the activation. | ||
138 | * @return An instance of the service for use or NULL on failure. | ||
139 | */ | ||
140 | static LLIOPipe* activate( | ||
141 | const std::string& name, | ||
142 | LLPumpIO::chain_t& chain, | ||
143 | LLSD context); | ||
144 | |||
145 | /** | ||
146 | * @brief | ||
147 | * | ||
148 | * @param name The name of the service to discard. | ||
149 | * @return true if service creator was found and discarded. | ||
150 | */ | ||
151 | static bool discard(const std::string& name); | ||
152 | |||
153 | protected: | ||
154 | // The creation factory static data. | ||
155 | typedef std::map<std::string, creator_t> creators_t; | ||
156 | static creators_t sCreatorFunctors; | ||
157 | |||
158 | protected: | ||
159 | // construction & destruction. since this class is an abstract | ||
160 | // base class, it is up to Service implementations to actually | ||
161 | // deal with construction and not a public method. How that | ||
162 | // construction takes place will be handled by the service | ||
163 | // creators. | ||
164 | LLService(); | ||
165 | virtual ~LLService(); | ||
166 | |||
167 | protected: | ||
168 | // This frame timer records how long this service has | ||
169 | // existed. Useful for derived services to give themselves a | ||
170 | // lifetime and expiration. | ||
171 | // *NOTE: Phoenix - This functionaity has been moved to the | ||
172 | // pump. 2005-12-13 | ||
173 | //LLFrameTimer mTimer; | ||
174 | |||
175 | // Since services are designed in an 'ask now, respond later' | ||
176 | // idiom which probably crosses thread boundaries, almost all | ||
177 | // services will need a handle to a response pipe. It will usually | ||
178 | // be the job of the service author to derive a useful | ||
179 | // implementation of response, and up to the service subscriber to | ||
180 | // further derive that class to do something useful when the | ||
181 | // response comes in. | ||
182 | LLIOPipe::ptr_t mResponse; | ||
183 | }; | ||
184 | |||
185 | |||
186 | #endif // LL_LLSERVICE_H | ||