RixInterfaces.h

00001 /* $Revision: #58 $  (Pixar - RenderMan Division) $Date: 2010/11/04 $ */
00002 /*
00003 # ------------------------------------------------------------------------------
00004 #
00005 # Copyright (c) 2006-2010 Pixar Animation Studios. All rights reserved.
00006 #
00007 # The information in this file is provided for the exclusive use of the
00008 # software licensees of Pixar.  It is UNPUBLISHED PROPRIETARY SOURCE CODE
00009 # of Pixar Animation Studios; the contents of this file may not be disclosed
00010 # to third parties, copied or duplicated in any form, in whole or in part,
00011 # without the prior written permission of Pixar Animation Studios.
00012 # Use of copyright notice is precautionary and does not imply publication.
00013 #
00014 # PIXAR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
00015 # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
00016 # SHALL PIXAR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
00017 # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00018 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
00019 # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00020 # SOFTWARE.
00021 #
00022 # Pixar
00023 # 1200 Park Ave
00024 # Emeryville CA 94608
00025 #
00026 # ------------------------------------------------------------------------------
00027 */
00028 
00029 #ifndef RIX_INTERFACE_H
00030 #define RIX_INTERFACE_H
00031 
00032 #include "ri.h"
00033 #include <vector>
00034 
00094 #include <stddef.h>             // for size_t
00095 #include <string>
00096 
00098 enum RixInterfaceId {
00099     k_RixThreadUtils = 0,
00100     k_RixMessages,      
00101     k_RixStats,         
00102     k_RixGlobalData,    
00103     k_RixThreadData,    
00104     k_RixLocalData,     
00105     k_RixGlobalTokenData,
00106     // Slot 7 is version 1 of the RixSubdivisionSurfaceEvaluation interface, do not use
00107     k_RixSessionData = 8,   
00108     k_RixXcpt,          
00109     k_RixRIB,           
00110     k_RixDeepTexture,    
00111     k_RixSubdivisionSurfaceEvaluation, 
00112     
00113 };
00114 
00119 class RixInterface {
00120 public:
00123     virtual int GetVersion() const { return m_version; }
00124 
00125 protected:
00127     int m_version;
00128 
00130     RixInterface(int version) : m_version(version) { }
00131 
00133     virtual ~RixInterface() { }
00134 };
00135 
00136 
00141 class RixContext {
00142 public:
00145     virtual RixInterface* GetRixInterface(RixInterfaceId id) const = 0;
00146 
00148     virtual ~RixContext() { }
00149 };
00150 
00158 class RixXcpt : public RixInterface
00159 {
00160 public:
00163     class XcptHandler 
00164     {
00165     public:
00166         virtual void HandleXcpt(int code, int severity, const char *msg) = 0;
00167         virtual void HandleExitRequest(int code) = 0;
00168 
00169     protected:
00170         virtual ~XcptHandler() {}
00171     };
00172 
00176     virtual void Register(XcptHandler *) = 0;
00177 
00179     virtual void Unregister(XcptHandler *) = 0;
00180 
00181 protected:
00182     RixXcpt() : RixInterface(1) { }
00183 };
00184 
00193 class RixMutex {
00194 public:
00196     virtual ~RixMutex() { }
00197 
00199     virtual void Lock() = 0;
00200     
00202     virtual void Unlock() = 0;
00203 };
00204 
00205 
00209 class RixThreadUtils : public RixInterface {
00210 public:
00212     virtual RixMutex* NewMutex() const = 0;
00213 
00214 protected:
00216     RixThreadUtils() : RixInterface(1) { }
00217 };
00218 
00219 
00222 class RixMessages : public RixInterface {
00223 public:
00231     virtual void Error(const char* format, ...) = 0;
00232 
00234     virtual void ErrorAlways(const char* format, ...) = 0;
00235 
00237     virtual void Warning(const char* format, ...) = 0;
00238 
00240     virtual void WarningAlways(const char* format, ...) = 0;
00241 
00243     virtual void Info(const char* format, ...) = 0;
00244 
00246     virtual void InfoAlways(const char* format, ...) = 0;
00247 
00248 protected:
00250     RixMessages() : RixInterface(1) { }
00251 };
00252 
00253 
00268 class RixStats : public RixInterface {
00269 public:
00276     virtual void AddTimerStat(float* seconds, const char* name,
00277                               const char* description) = 0;
00278 
00285     virtual void AddMemoryStat(size_t* bytes, const char* name, 
00286                                const char* description) = 0;
00287 
00290     typedef void (*Reporter)(class RixXmlFile* file);
00291 
00309     virtual void AddReporter(Reporter func) = 0;
00310 
00316     virtual void AddFileLogStat(const char *filename, const char *path) = 0;
00317 
00318 protected:
00320     RixStats() : RixInterface(2) { }
00321 };
00322 
00323 
00326 class RixXmlFile {
00327 public:
00333     virtual void WriteXml(const char* format, ...) = 0;
00334 
00337     virtual void WriteText(const char* format, ...) = 0;
00338 
00340     virtual ~RixXmlFile() { }
00341 };
00342 
00343 
00345 typedef void (*RixCleanupFunc)(RixContext* context, void* data);
00346 
00347 
00405 class RixStorage : public RixInterface {
00406 public:
00408     virtual void* Get(const char* key) = 0;
00409 
00413     virtual void Set(const char* key, void* data, 
00414                      RixCleanupFunc cleanup = NULL) = 0;
00415 
00418     virtual void Clear(const char* key) = 0;
00419 
00421     virtual void Lock() = 0;
00422 
00424     virtual void Unlock() = 0;
00425 
00426 protected:
00428     RixStorage() : RixInterface(1) { }
00429 };
00430 
00431 
00437 class RixTokenStorage : public RixInterface {
00438 public:
00444     virtual const char *GetToken(const char *input) = 0;
00445 
00446 protected:
00448     RixTokenStorage() : RixInterface(1) { }
00449 };
00450 
00451 
00453 extern "C" {
00454     PRMANAPI class RixSubdivisionSurfaceEvaluation *RixGetSubdivInterface(int version);
00455     PRMANAPI class RixContext *RixGetContext();
00456 }
00457 
00458 #endif  // RIX_INTERFACE_H

Generated on Mon Nov 15 10:14:34 2010 for PRManHeaders by  doxygen 1.4.6