Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

vos/corelibs/vos/metafactory.hh

Go to the documentation of this file.
00001 /*
00002     This file is part of the Virtual Object System of
00003     the Interreality project (http://interreality.org).
00004 
00005     Copyright (C) 2001, 2002 Peter Amstutz
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020 
00021     Peter Amstutz <tetron@interreality.org>
00022 */
00023 #ifndef _METAFACTORY_HH_
00024 #define _METAFACTORY_HH_
00025 
00026 #ifndef _VOS_HH_
00027 #error Please only include "vos.hh"!
00028 #endif
00029 
00030 #error MetaFactory has been replaced by equivalent functionality in LocalSite and RemoteSite. Use the object creation methods there instead.
00031 
00032 
00033 
00034 #if 0
00035 
00036  DEPRECATED use Site instead.
00037 
00038 /** A macro for lazy and/or forgetful people. (like me)   -rh */
00039 #define CLASSNAME(c)    (typeid(c).name())
00040 
00041 typedef MetaObject* (*metaobject_extender_t)(MetaObject* superobject, const string& type);
00042 
00043 /** The MetaFactory builds and extends MetaObjects.  Generally
00044     speaking you should be using this class whenever you create a new
00045     MetaObject to add into the Vobject tree rather than instantiating
00046     LocalVobject or LocalMetaObject directly.
00047 */
00048 class VOS_API MetaFactory
00049 {
00050 public:
00051     static string generateUniqueName(LocalSite& localsite);
00052 
00053     /** Create a new local object.
00054         @param name Name of the new object on the site. Note that every object on a site must have a different name.
00055         @param localsite the site to bind the object to
00056         @param ac the access control policy this object starts with (or NULL to use localsite's access control)
00057         @param typelist a deque of string type names to extend this new object with
00058         @return the requested new local metaobject.   NOTE YOU MUST CALL release() WHEN DONE OR USE A pREF() BLOCK
00059     */
00060     static LocalMetaObject* createLocalObject(const string& name, LocalSite* localsite, VobjectAccessControl* ac, deque<string> &typelist);
00061 
00062     /** Create a new local object.
00063         @param name Object's name on the site. Note that every object on a site must have a different name.
00064         @param localsite the site to bind the object to
00065         @param ac the access control policy this object starts with (or 0 to use localsite's AC and use no extenders)
00066         @param ... a 0-terminated list of char* type names to extend this new object with,
00067         see extendLocalObject() for an example of how this is used.
00068         @return the requested new local metaobject.   NOTE YOU MUST CALL release() WHEN DONE OR USE A pREF() BLOCK
00069     */
00070     static LocalMetaObject* createLocalObject(const string& name, LocalSite* localsite,
00071                                               VobjectAccessControl* ac, ...);
00072 
00073     /** Create a new local object.  The site name will be a site-unique, randomly generated string of digits.
00074         @param localsite the site to bind the object to
00075         @param ac the access control policy this object starts with (or 0 to use localsite's AC and use no extenders)
00076         @param ... a 0-terminated list of char* type names to extend this new object with,
00077         see extendLocalObject() for an example of how this is used.
00078         @return the requested new local metaobject.   NOTE YOU MUST CALL release() WHEN DONE OR USE A pREF() BLOCK
00079     */
00080     static LocalMetaObject* createLocalObject(LocalSite* localsite, VobjectAccessControl* ac, ...);
00081 
00082     /** Create a new local object.  The
00083         access control policy will be same (ie pointing to the same
00084         object instance) as the site it is bound to.
00085         @param name the name on the site
00086         @param localsite the site to bind the object to
00087         @param ... a 0-terminated list of char* type names to extend this new object with,
00088         see extendLocalObject() for an example of how this is used.
00089         @return the requested new local metaobject.   NOTE YOU MUST CALL release() WHEN DONE OR USE A pREF() BLOCK
00090     */
00091     static LocalMetaObject* createLocalObject(const string& name, LocalSite* localsite, ...);
00092 
00093     /** Create a new local object.  The site name will be a
00094         site-unique, randomly generated string of digits, and the
00095         access control policy will be same (eg a pointing to the same
00096         object instance) as the site it is bound to.
00097         @param localsite the site to bind the object to
00098         @param ... a 0-terminated list of char* type names to extend this new object with,
00099         see extendLocalObject() for an example of how this is used.
00100         @return the requested new local metaobject.   NOTE YOU MUST CALL release() WHEN DONE OR USE A pREF() BLOCK
00101     */
00102     static LocalMetaObject* createLocalObject(LocalSite* localsite, ...);
00103 
00104     /** Extend an existing local metaobject.  @note The 0-terminated
00105         list should be a list of char* type names.  This should look
00106         like:
00107         @code
00108         extendLocalObject(foo, "property", typeid(World).name(), 0);
00109         @endcode
00110         This will extend the object "foo" to support the "property"
00111         and World types.  Note the use of the native C++ type; you can
00112         simply ask for a particular interface without needing to know
00113         the MOS type name and it will be found for you, if the
00114         appropriate plugin exists.  See also
00115         MetaObject::meta_cast(MetaObject*,bool) for
00116         another example.
00117         @param obj the object to be extended
00118         @param ... a 0-terminated list of char* type names to extend
00119         this new object with @return the requested new local
00120         metaobject.
00121         @returns the object passed as the first parameter
00122     */
00123     static LocalMetaObject* extendLocalObject(LocalMetaObject* obj, ...);
00124 
00125     /** Extend and existing remote metaobject.
00126         @param obj the object
00127         @param ... a 0-terminated list of char* type names to extend this new object with,
00128         see extendLocalObject() for an example of how this is used.
00129         @returns the object passed as the first parameter
00130     */
00131     static RemoteMetaObject* extendRemoteObject(RemoteMetaObject* obj, ...);
00132 
00133     /** Register a new object extension that will be available with
00134         createLocalObject() and extendLocalObject().
00135         @param type a type string that matches this extension
00136         @param newmethod the method that will be called to perform the
00137         extension operation on an object
00138     */
00139     static void addLocalObjectExtension(const char* type, metaobject_extender_t newmethod);
00140 
00141     /** Register a new object extension that will be available with
00142         extendRemoteObject().
00143         @param type a type string that matches this extension
00144         @param newmethod the method that will be called to perform the
00145         extension operation on an object
00146     */
00147     static void addRemoteObjectExtension(const char* type, metaobject_extender_t newmethod);
00148 
00149     /** Remove an existing local object extension
00150         @param type a type string that matches this extension
00151         @param oldmethod the specific extension method to remove
00152     */
00153     static void removeLocalObjectExtension(const char* type, metaobject_extender_t oldmethod);
00154 
00155     /** Remove an existing remote object extension
00156         @param type a type string that matches this extension
00157         @param oldmethod the specific extension method to remove
00158     */
00159     static void removeRemoteObjectExtension(const char* type, metaobject_extender_t oldmethod);
00160 };
00161 
00162 #endif 
00163 
00164 #endif

Generated on Tue Aug 12 03:55:40 2003 for Interreality Project - VOS by doxygen 1.3.2