Back to index

lightning-sunbird  0.9+nobinonly
nsPropertyTable.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  * vim:cindent:ts=2:et:sw=2:
00003  *
00004  * ***** BEGIN LICENSE BLOCK *****
00005  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00006  *
00007  * The contents of this file are subject to the Mozilla Public License Version
00008  * 1.1 (the "License"); you may not use this file except in compliance with
00009  * the License. You may obtain a copy of the License at
00010  * http://www.mozilla.org/MPL/
00011  *
00012  * Software distributed under the License is distributed on an "AS IS" basis,
00013  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00014  * for the specific language governing rights and limitations under the
00015  * License.
00016  *
00017  * The Original Code is mozilla.org code.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 1998
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK *****
00039  *
00040  * This Original Code has been modified by IBM Corporation. Modifications made by IBM 
00041  * described herein are Copyright (c) International Business Machines Corporation, 2000.
00042  * Modifications to Mozilla code or documentation identified per MPL Section 3.3
00043  *
00044  * Date             Modified by     Description of modification
00045  * 04/20/2000       IBM Corp.      OS/2 VisualAge build.
00046  */
00047 
00055 #ifndef nsPropertyTable_h_
00056 #define nsPropertyTable_h_
00057 
00058 #include "nscore.h"
00059 
00060 class nsIAtom;
00061 
00068 typedef void
00069 (*NSPropertyDtorFunc)(void           *aObject,
00070                       nsIAtom        *aPropertyName,
00071                       void           *aPropertyValue,
00072                       void           *aData);
00073 
00074 class nsPropertyTable
00075 {
00076  public:
00081   void* GetProperty(const void *aObject,
00082                     nsIAtom    *aPropertyName,
00083                     nsresult   *aResult = nsnull)
00084   { return GetPropertyInternal(aObject, aPropertyName, PR_FALSE, aResult); }
00085 
00096   NS_HIDDEN_(nsresult) SetProperty(const void         *aObject,
00097                                    nsIAtom            *aPropertyName,
00098                                    void               *aPropertyValue,
00099                                    NSPropertyDtorFunc  aDtor,
00100                                    void               *aDtorData);
00101 
00106   NS_HIDDEN_(nsresult) DeleteProperty(const void *aObject,
00107                                       nsIAtom    *aPropertyName);
00108 
00113   void* UnsetProperty(const void *aObject,
00114                       nsIAtom    *aPropertyName,
00115                       nsresult   *aStatus = nsnull)
00116   { return GetPropertyInternal(aObject, aPropertyName, PR_TRUE, aStatus); }
00117 
00122   NS_HIDDEN_(void) DeleteAllPropertiesFor(const void *aObject);
00123 
00128   NS_HIDDEN_(void) DeleteAllProperties();
00129   
00130   ~nsPropertyTable() {
00131     DeleteAllProperties();
00132   }
00133 
00134   struct PropertyList;
00135 
00136  private:
00137   NS_HIDDEN_(void) DestroyPropertyList();
00138   NS_HIDDEN_(PropertyList*) GetPropertyListFor(nsIAtom *aPropertyName) const;
00139   NS_HIDDEN_(void*) GetPropertyInternal(const void *aObject,
00140                                         nsIAtom    *aPropertyName,
00141                                         PRBool      aRemove,
00142                                         nsresult   *aStatus);
00143 
00144   PropertyList *mPropertyList;
00145 };
00146 #endif