Back to index

lightning-sunbird  0.9+nobinonly
ipcMessagePrimitives.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is Mozilla IPC.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 2002
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Darin Fisher <darin@netscape.com>
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef ipcMessagePrimitives_h__
00039 #define ipcMessagePrimitives_h__
00040 
00041 #include "ipcMessage.h"
00042 
00043 class ipcMessage_DWORD : public ipcMessage
00044 {
00045 public:
00046     ipcMessage_DWORD(const nsID &target, PRUint32 first)
00047     {
00048         Init(target, (char *) &first, sizeof(first));
00049     }
00050 
00051     PRUint32 First() const
00052     {
00053         return ((PRUint32 *) Data())[0];
00054     }
00055 };
00056 
00057 class ipcMessage_DWORD_DWORD : public ipcMessage
00058 {
00059 public:
00060     ipcMessage_DWORD_DWORD(const nsID &target, PRUint32 first, PRUint32 second)
00061     {
00062         PRUint32 data[2] = { first, second };
00063         Init(target, (char *) data, sizeof(data));
00064     }
00065 
00066     PRUint32 First() const
00067     {
00068         return ((PRUint32 *) Data())[0];
00069     }
00070 
00071     PRUint32 Second() const
00072     {
00073         return ((PRUint32 *) Data())[1];
00074     }
00075 };
00076 
00077 class ipcMessage_DWORD_DWORD_DWORD : public ipcMessage
00078 {
00079 public:
00080     ipcMessage_DWORD_DWORD_DWORD(const nsID &target, PRUint32 first, PRUint32 second, PRUint32 third)
00081     {
00082         PRUint32 data[3] = { first, second, third };
00083         Init(target, (char *) data, sizeof(data));
00084     }
00085 
00086     PRUint32 First() const
00087     {
00088         return ((PRUint32 *) Data())[0];
00089     }
00090 
00091     PRUint32 Second() const
00092     {
00093         return ((PRUint32 *) Data())[1];
00094     }
00095 
00096     PRUint32 Third() const
00097     {
00098         return ((PRUint32 *) Data())[2];
00099     }
00100 };
00101 
00102 class ipcMessage_DWORD_DWORD_DWORD_DWORD : public ipcMessage
00103 {
00104 public:
00105     ipcMessage_DWORD_DWORD_DWORD_DWORD(const nsID &target, PRUint32 first, PRUint32 second, PRUint32 third, PRUint32 fourth)
00106     {
00107         PRUint32 data[4] = { first, second, third, fourth };
00108         Init(target, (char *) data, sizeof(data));
00109     }
00110 
00111     PRUint32 First() const
00112     {
00113         return ((PRUint32 *) Data())[0];
00114     }
00115 
00116     PRUint32 Second() const
00117     {
00118         return ((PRUint32 *) Data())[1];
00119     }
00120 
00121     PRUint32 Third() const
00122     {
00123         return ((PRUint32 *) Data())[2];
00124     }
00125 
00126     PRUint32 Fourth() const
00127     {
00128         return ((PRUint32 *) Data())[3];
00129     }
00130 };
00131 
00132 class ipcMessage_DWORD_STR : public ipcMessage
00133 {
00134 public:
00135     ipcMessage_DWORD_STR(const nsID &target, PRUint32 first, const char *second) NS_HIDDEN;
00136 
00137     PRUint32 First() const
00138     {
00139         return ((PRUint32 *) Data())[0];
00140     }
00141 
00142     const char *Second() const
00143     {
00144         return Data() + sizeof(PRUint32);
00145     }
00146 };
00147 
00148 class ipcMessage_DWORD_DWORD_STR : public ipcMessage
00149 {
00150 public:
00151     ipcMessage_DWORD_DWORD_STR(const nsID &target, PRUint32 first, PRUint32 second, const char *third) NS_HIDDEN;
00152 
00153     PRUint32 First() const
00154     {
00155         return ((PRUint32 *) Data())[0];
00156     }
00157 
00158     PRUint32 Second() const
00159     {
00160         return ((PRUint32 *) Data())[1];
00161     }
00162 
00163     const char *Third() const
00164     {
00165         return Data() + 2 * sizeof(PRUint32);
00166     }
00167 };
00168 
00169 class ipcMessage_DWORD_ID : public ipcMessage
00170 {
00171 public:
00172     ipcMessage_DWORD_ID(const nsID &target, PRUint32 first, const nsID &second) NS_HIDDEN;
00173 
00174     PRUint32 First() const
00175     {
00176         return ((PRUint32 *) Data())[0];
00177     }
00178 
00179     const nsID &Second() const
00180     {
00181         return * (const nsID *) (Data() + sizeof(PRUint32));
00182     }
00183 };
00184 
00185 class ipcMessage_DWORD_DWORD_ID : public ipcMessage
00186 {
00187 public:
00188     ipcMessage_DWORD_DWORD_ID(const nsID &target, PRUint32 first, PRUint32 second, const nsID &third) NS_HIDDEN;
00189 
00190     PRUint32 First() const
00191     {
00192         return ((PRUint32 *) Data())[0];
00193     }
00194 
00195     PRUint32 Second() const
00196     {
00197         return ((PRUint32 *) Data())[1];
00198     }
00199 
00200     const nsID &Third() const
00201     {
00202         return * (const nsID *) (Data() + 2 * sizeof(PRUint32));
00203     }
00204 };
00205 
00206 #endif // !ipcMessagePrimitives_h__