michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsSample_h michael@0: #define nsSample_h michael@0: michael@0: /** michael@0: * A sample of XPConnect. This file is the header of an implementation michael@0: * nsSample of the nsISample interface. michael@0: * michael@0: */ michael@0: michael@0: #include "nsISample.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: /** michael@0: * SampleImpl is an implementation of the nsISample interface. In XPCOM, michael@0: * there can be more than one implementation of an given interface. Class michael@0: * IDs (CIDs) uniquely identify a particular implementation of an interface. michael@0: * Interface IDs (IIDs) uniquely identify an interface. michael@0: * michael@0: * The CID is also a unique number that looks just like an IID michael@0: * and uniquely identifies an implementation michael@0: * {7CB5B7A0-07D7-11d3-BDE2-000064657374} michael@0: */ michael@0: michael@0: #define NS_SAMPLE_CID \ michael@0: { 0x7cb5b7a0, 0x7d7, 0x11d3, { 0xbd, 0xe2, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } } michael@0: michael@0: #define NS_SAMPLE_CONTRACTID "@mozilla.org/sample;1" michael@0: michael@0: michael@0: class nsSampleImpl MOZ_FINAL : public nsISample michael@0: { michael@0: public: michael@0: nsSampleImpl(); michael@0: michael@0: /** michael@0: * This macro expands into a declaration of the nsISupports interface. michael@0: * Every XPCOM component needs to implement nsISupports, as it acts michael@0: * as the gateway to other interfaces this component implements. You michael@0: * could manually declare QueryInterface, AddRef, and Release instead michael@0: * of using this macro, but why? michael@0: */ michael@0: // nsISupports interface michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: /** michael@0: * This macro is defined in the nsISample.h file, and is generated michael@0: * automatically by the xpidl compiler. It expands to michael@0: * declarations of all of the methods required to implement the michael@0: * interface. xpidl will generate a NS_DECL_[INTERFACENAME] macro michael@0: * for each interface that it processes. michael@0: * michael@0: * The methods of nsISample are discussed individually below, but michael@0: * commented out (because this macro already defines them.) michael@0: */ michael@0: NS_DECL_NSISAMPLE michael@0: michael@0: /** michael@0: * The following is an explanation of how the interface header michael@0: * file expands to for a c++ implementation. NS_DELC_NSISAMPLE michael@0: * takes care of defining the right c++ implementation. michael@0: * michael@0: * The following if provided for more understanding. michael@0: * michael@0: * NS_IMETHOD expands to the standard XPCOM return type. XPCOM methods michael@0: * should never return any other type. The return value is used michael@0: * behind the scenes by the XPConnect runtime to figure out if the call michael@0: * failed in any way. michael@0: * These methods were generated by "attribute string Value" in michael@0: * nsISample.idl. When reflected into JavaScript, XPCOM will use these michael@0: * calls as Getter/Setter ops, so that they can be called transparently michael@0: * as "sample.Value='foo';" and "var val = sample.Value" michael@0: */ michael@0: /* NS_IMETHOD GetValue(char * *aValue); */ michael@0: /* NS_IMETHOD SetValue(char * aValue); */ michael@0: michael@0: /** michael@0: * The const came from the "in" specifier in nsISample.idl. "in" michael@0: * specifies that the value of this parameter is used only for input, michael@0: * this method is not allowed to modify the contents of the buffer. michael@0: */ michael@0: /* NS_IMETHOD WriteValue(const char *aPrefix); */ michael@0: michael@0: /** michael@0: * nsISample.idl specifies all of its string types as string, instead michael@0: * of wstring (wide string), the Unicode type. If the world were a michael@0: * perfect place, all normal strings in XPCOM interfaces would be unicode. michael@0: * If this type had been specified as wstring, it would appear as michael@0: * char16_t * in C++, which is the NSPR type for unicode characters. michael@0: */ michael@0: /* NS_IMETHOD Poke(const char* aValue); */ michael@0: michael@0: private: michael@0: ~nsSampleImpl(); michael@0: michael@0: char* mValue; michael@0: }; michael@0: michael@0: #endif