OVR_Profile.h
Go to the documentation of this file.
00001 /************************************************************************************
00002 
00003 PublicHeader:   OVR.h
00004 Filename    :   OVR_Profile.h
00005 Content     :   Structs and functions for loading and storing device profile settings
00006 Created     :   February 14, 2013
00007 Notes       :
00008    Profiles are used to store per-user settings that can be transferred and used
00009    across multiple applications.  For example, player IPD can be configured once 
00010    and reused for a unified experience across games.  Configuration and saving of profiles
00011    can be accomplished in game via the Profile API or by the official Oculus Configuration
00012    Utility.
00013 
00014 Copyright   :   Copyright 2013 Oculus VR, Inc. All Rights reserved.
00015 
00016 Use of this software is subject to the terms of the Oculus license
00017 agreement provided at the time of installation or download, or which
00018 otherwise accompanies this software in either electronic or hard copy form.
00019 
00020 ************************************************************************************/
00021 
00022 #ifndef OVR_Profile_h
00023 #define OVR_Profile_h
00024 
00025 #include "Kernel/OVR_String.h"
00026 #include "Kernel/OVR_RefCount.h"
00027 #include "Kernel/OVR_Array.h"
00028 
00029 namespace OVR {
00030 
00031 // Defines the profile object for each device type
00032 enum ProfileType
00033 {
00034     Profile_Unknown       = 0,
00035     Profile_RiftDK1       = 1,
00036     Profile_RiftDKHD      = 2,
00037 };
00038 
00039 class Profile;
00040 
00041 // -----------------------------------------------------------------------------
00042 // ***** ProfileManager
00043 
00044 // Profiles are interfaced through a ProfileManager object.  Applications should
00045 // create a ProfileManager each time they intend to read or write user profile data.
00046 // The scope of the ProfileManager object defines when disk I/O is performed.  Disk
00047 // reads are performed on the first profile access and disk writes are performed when
00048 // the ProfileManager goes out of scope.  All profile interactions between these times
00049 // are performed in local memory and are fast.  A typical profile interaction might
00050 // look like this:
00051 //
00052 // {
00053 //     Ptr<ProfileManager> pm      = *ProfileManager::Create();
00054 //     Ptr<Profile>        profile = pm->LoadProfile(Profile_RiftDK1,
00055 //                                                   pm->GetDefaultProfileName(Profile_RiftDK1));
00056 //     if (profile)
00057 //     {   // Retrieve the current profile settings
00058 //     }
00059 // }   // Profile will be destroyed and any disk I/O completed when going out of scope
00060 
00061 class ProfileManager : public RefCountBase<ProfileManager>
00062 {
00063 protected:
00064     // Synchronize ProfileManager access since it may be accessed from multiple threads,
00065     // as it's shared through DeviceManager.
00066     Lock                    ProfileLock;
00067     Array<Ptr<Profile> >    ProfileCache;
00068     ProfileType             CacheDevice;
00069     String                  DefaultProfile;
00070     bool                    Changed;
00071     char                    NameBuff[32];
00072     
00073 public:
00074     static ProfileManager* Create();
00075 
00076     // Static interface functions
00077     int                 GetProfileCount(ProfileType device);
00078     const char*         GetProfileName(ProfileType device, unsigned int index);
00079     bool                HasProfile(ProfileType device, const char* name);
00080     Profile*            LoadProfile(ProfileType device, unsigned int index);
00081     Profile*            LoadProfile(ProfileType device, const char* name);
00082     Profile*            GetDeviceDefaultProfile(ProfileType device);
00083     const char*         GetDefaultProfileName(ProfileType device);
00084     bool                SetDefaultProfileName(ProfileType device, const char* name);
00085     bool                Save(const Profile* profile);
00086     bool                Delete(const Profile* profile);
00087 
00088 protected:
00089     ProfileManager();
00090     ~ProfileManager();
00091     void                LoadCache(ProfileType device);
00092     void                SaveCache();
00093     void                ClearCache();
00094     Profile*            CreateProfileObject(const char* user,
00095                                             ProfileType device,
00096                                             const char** device_name);
00097 };
00098 
00099 //-------------------------------------------------------------------
00100 // ***** Profile
00101 
00102 // The base profile for all HMD devices.  This object is never created directly.
00103 // Instead derived objects provide specific data implementations.  Some settings
00104 // such as IPD will be tied to a specific user and be consistent between ,
00105 // implementations but other settings like optical distortion may vary between devices.
00106 
00107 class Profile : public RefCountBase<Profile>
00108 {
00109 public:
00110     enum { MaxNameLen    = 32 };
00111 
00112     enum GenderType
00113     {
00114         Gender_Unspecified  = 0,
00115         Gender_Male         = 1,
00116         Gender_Female       = 2
00117     };
00118 
00119     ProfileType Type;              // The type of device profile
00120     char        Name[MaxNameLen];  // The name given to this profile
00121 
00122 protected:
00123     GenderType  Gender;            // The gender of the user
00124     float       PlayerHeight;      // The height of the user in meters
00125     float       IPD;               // Distance between eyes in meters
00126 
00127 public:
00128     // These are properties which are intrinsic to the user and affect scene setup
00129     GenderType      GetGender()                     { return Gender; };
00130     float           GetPlayerHeight()               { return PlayerHeight; };
00131     float           GetIPD()                        { return IPD; };
00132     float           GetEyeHeight();    
00133     
00134     void            SetGender(GenderType gender)    { Gender = gender; };
00135     void            SetPlayerHeight(float height)   { PlayerHeight = height; };
00136     void            SetIPD(float ipd)               { IPD = ipd; };
00137 
00138 
00139 protected:
00140     Profile(ProfileType type, const char* name);
00141 
00142     virtual Profile*     Clone() const = 0;
00143     virtual bool         ParseProperty(const char* prop, const char* sval);
00144     
00145     friend class ProfileManager;
00146 };
00147 
00148 
00149 //-----------------------------------------------------------------------------
00150 // ***** RiftDK1Profile
00151 
00152 // This profile is specific to the Rift Dev Kit 1 and contains overrides specific 
00153 // to that device and lens cup settings.
00154 class RiftDK1Profile : public Profile
00155 {
00156 public:
00157     enum EyeCupType
00158     {
00159         EyeCup_A = 0,
00160         EyeCup_B = 1,
00161         EyeCup_C = 2
00162     };
00163 
00164 protected:
00165     EyeCupType  EyeCups;            // Which eye cup does the player use
00166     int         LL;                 // Configuration Utility IPD setting
00167     int         LR;                 // Configuration Utility IPD setting
00168     int         RL;                 // Configuration Utility IPD setting
00169     int         RR;                 // Configuration Utility IPD setting
00170 
00171 public:
00172     EyeCupType          GetEyeCup() { return EyeCups; };
00173     void                SetEyeCup(EyeCupType cup) { EyeCups = cup; };
00174 
00175 protected:
00176     RiftDK1Profile(const char* name);
00177 
00178     virtual Profile*    Clone() const;
00179     virtual bool        ParseProperty(const char* prop, const char* sval);
00180 
00181     friend class ProfileManager;
00182 };
00183 
00184 }
00185 
00186 #endif // OVR_Profile_h


oculus_sdk
Author(s): Tully Foote
autogenerated on Thu Jun 6 2019 20:13:48