extra: import at 3.0.1 beta 1
[mozilla-extra.git] / extensions / webservices / soap / src / nsSOAPEncoding.h
blob6bca8571fd15c04c3029bceb2942d631b8650e7e
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2001
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsSOAPEncoding_h__
39 #define nsSOAPEncoding_h__
41 #include "nsString.h"
42 #include "nsIDOMElement.h"
43 #include "nsISOAPEncoding.h" // contains nsISOAPEncodingRegistry too
44 #include "nsISOAPEncoder.h"
45 #include "nsISOAPDecoder.h"
46 #include "nsCOMPtr.h"
47 #include "nsHashtable.h"
48 #include "nsISchema.h"
50 // Notes regarding the ownership model between the nsSOAPEncoding (encoding)
51 // and the nsSOAPEncodingRegsitry (registry). To avoid cyclic referencing
52 // and thereby leaking encodings and the registry holding them the registry
53 // was given ownership of the encodings. In the encoding specialized
54 // AddRef() and Release() functions were written to pass the refcounting
55 // to the registry. Instead of ref couting the encodings all refs are
56 // accumulated in the registry. When the registry is the only thing holding
57 // on to the encodings it's own refcount will hit zero causing it to
58 // go away and take with it any encodings stored in its hashtable. To make
59 // this work the registry had to be a weak reference (*-style pointer)
60 // in each encoding and the storage of the encodings had to be weak as
61 // well (*-style pointers in the nsObjectHashtable).
63 class nsSOAPEncodingRegistry : public nsISOAPEncodingRegistry
66 public:
67 NS_DECL_ISUPPORTS
68 NS_DECL_NSISOAPENCODINGREGISTRY
70 nsSOAPEncodingRegistry(nsISOAPEncoding *aEncoding);
72 // the nsObjectHashtable has a callback to delete all the encodings
73 // the callback is defined in nsSOAPEncoding.cpp
74 virtual ~nsSOAPEncodingRegistry() {}
76 protected:
77 nsObjectHashtable mEncodings;
78 nsCOMPtr<nsISchemaCollection> mSchemaCollection;
83 class nsSOAPEncoding : public nsISOAPEncoding
86 public:
87 NS_DECL_ISUPPORTS
88 NS_DECL_NSISOAPENCODING
90 nsSOAPEncoding();
91 nsSOAPEncoding(const nsAString &aStyleURI,
92 nsSOAPEncodingRegistry *aRegistry,
93 nsISOAPEncoding *aDefaultEncoding);
94 virtual ~nsSOAPEncoding() {}
96 protected:
97 nsString mStyleURI;
98 nsSupportsHashtable mEncoders;
99 nsSupportsHashtable mDecoders;
101 // Weak Reference to avoid cyclic refs and leaks. See notes above.
102 nsISOAPEncodingRegistry *mRegistry;
104 nsCOMPtr<nsISOAPEncoding> mDefaultEncoding;
105 nsCOMPtr<nsISOAPEncoder> mDefaultEncoder;
106 nsCOMPtr<nsISOAPDecoder> mDefaultDecoder;
107 nsSupportsHashtable mMappedInternal;
108 nsSupportsHashtable mMappedExternal;
111 #endif