yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// slang-artifact-helper.h 2#ifndef SLANG_ARTIFACT_HELPER_H 3#define SLANG_ARTIFACT_HELPER_H 4 5#include "../core/slang-com-object.h" 6#include "slang-artifact-representation.h" 7#include "slang-artifact.h" 8 9namespace Slang 10{ 11 12class IArtifactHelper :public ICastable 13{ 14SLANG_COM_INTERFACE (0x882b25d7 ,0xe300 ,0x4b20 , {0xbe ,0xb ,0x26 ,0xd2 ,0x52 ,0x3e ,0x70 ,0x20 }) 15 16/// Create an artifact 17virtual SLANG_NO_THROW SlangResult SLANG_MCALL 18createArtifact (const ArtifactDesc & desc ,const char * name ,IArtifact ** outArtifact )= 0 ; 19 20/// Get the parent to a kind 21virtual SLANG_NO_THROW ArtifactKind SLANG_MCALL getKindParent (ArtifactKind kind )= 0 ; 22/// Get the name of a kind 23virtual SLANG_NO_THROW UnownedStringSlice SLANG_MCALL getKindName (ArtifactKind kind )= 0 ; 24/// Returns true if kind is derived from base 25virtual SLANG_NO_THROW bool SLANG_MCALL 26isKindDerivedFrom (ArtifactKind kind ,ArtifactKind base )= 0 ; 27 28/// Get the parent payload for payload 29virtual SLANG_NO_THROW ArtifactPayload SLANG_MCALL 30getPayloadParent (ArtifactPayload payload )= 0 ; 31/// Get the payload name text 32virtual SLANG_NO_THROW UnownedStringSlice SLANG_MCALL 33getPayloadName (ArtifactPayload payload )= 0 ; 34/// Returns true if payload is derived from base 35virtual SLANG_NO_THROW bool SLANG_MCALL 36isPayloadDerivedFrom (ArtifactPayload payload ,ArtifactPayload base )= 0 ; 37 38/// Get the parent type of a style 39virtual SLANG_NO_THROW ArtifactStyle SLANG_MCALL getStyleParent (ArtifactStyle style )= 0 ; 40/// Get text name for a style 41virtual SLANG_NO_THROW UnownedStringSlice SLANG_MCALL getStyleName (ArtifactStyle style )= 0 ; 42/// Returns true if style is derived from base 43virtual SLANG_NO_THROW bool SLANG_MCALL 44isStyleDerivedFrom (ArtifactStyle style ,ArtifactStyle base )= 0 ; 45 46/// Create a lock file, the path of which can be used to generate other temporary files 47virtual SLANG_NO_THROW SlangResult SLANG_MCALL 48createLockFile (const CharSlice & nameBase ,IOSFileArtifactRepresentation ** outLockFile )= 0 ; 49 50/// Given a desc and a basePath returns a suitable name 51virtual SLANG_NO_THROW SlangResult SLANG_MCALL 52calcArtifactDescPath (const ArtifactDesc & desc ,const char * basePath ,ISlangBlob ** outPath )= 0 ; 53 54/// Given an artifact and a basePath returns a suitable name 55virtual SLANG_NO_THROW SlangResult SLANG_MCALL 56calcArtifactPath (IArtifact * ,const char * basePath ,ISlangBlob ** outPath )= 0 ; 57 58/// Given a compile target return the equivalent desc 59virtual SLANG_NO_THROW ArtifactDesc SLANG_MCALL 60makeDescForCompileTarget (SlangCompileTarget target )= 0 ; 61 62/// Given an interface returns as a castable interface. This might just cast unk into ICastable, 63/// or wrap it such that it uses the castable interface 64virtual SLANG_NO_THROW void SLANG_MCALL 65getCastable (ISlangUnknown * unk ,ICastable ** outCastable )= 0 ; 66 67/// Create a file rep 68virtual SLANG_NO_THROW SlangResult SLANG_MCALL createOSFileArtifactRepresentation ( 69IOSFileArtifactRepresentation ::Kind kind , 70const CharSlice & path , 71IOSFileArtifactRepresentation * lockFile , 72IOSFileArtifactRepresentation ** outRep )= 0 ; 73 74virtual SLANG_NO_THROW SlangResult SLANG_MCALL createExtFileArtifactRepresentation ( 75const CharSlice & path , 76ISlangFileSystemExt * system , 77IExtFileArtifactRepresentation ** outRep )= 0 ; 78 79virtual SLANG_NO_THROW SlangResult SLANG_MCALL createOSFileArtifact ( 80const ArtifactDesc & desc , 81const CharSlice & slice , 82IArtifact ** outArtifact )= 0 ; 83}; 84 85class DefaultArtifactHelper :public IArtifactHelper 86{ 87public : 88// ISlangUnknown 89SLANG_NO_THROW uint32_t SLANG_MCALL addRef ()SLANG_OVERRIDE {return 1 ; } 90SLANG_NO_THROW uint32_t SLANG_MCALL release ()SLANG_OVERRIDE {return 1 ; } 91SLANG_NO_THROW SlangResult SLANG_MCALL queryInterface (SlangUUID const & uuid ,void ** outObject ) 92SLANG_OVERRIDE ; 93 94// ICastable 95SLANG_NO_THROW void * SLANG_MCALL castAs (const Guid & guid )SLANG_OVERRIDE ; 96 97// IArtifactHelper 98virtual SLANG_NO_THROW SlangResult SLANG_MCALL createArtifact ( 99const ArtifactDesc & desc , 100const char * name , 101IArtifact ** outArtifact )SLANG_OVERRIDE ; 102 103virtual SLANG_NO_THROW ArtifactKind SLANG_MCALL getKindParent (ArtifactKind kind )SLANG_OVERRIDE ; 104virtual SLANG_NO_THROW UnownedStringSlice SLANG_MCALL getKindName (ArtifactKind kind ) 105SLANG_OVERRIDE ; 106virtual SLANG_NO_THROW bool SLANG_MCALL isKindDerivedFrom (ArtifactKind kind ,ArtifactKind base ) 107SLANG_OVERRIDE ; 108 109virtual SLANG_NO_THROW ArtifactPayload SLANG_MCALL getPayloadParent (ArtifactPayload payload ) 110SLANG_OVERRIDE ; 111virtual SLANG_NO_THROW UnownedStringSlice SLANG_MCALL getPayloadName (ArtifactPayload payload ) 112SLANG_OVERRIDE ; 113virtual SLANG_NO_THROW bool SLANG_MCALL 114isPayloadDerivedFrom (ArtifactPayload payload ,ArtifactPayload base )SLANG_OVERRIDE ; 115 116virtual SLANG_NO_THROW ArtifactStyle SLANG_MCALL getStyleParent (ArtifactStyle style ) 117SLANG_OVERRIDE ; 118virtual SLANG_NO_THROW UnownedStringSlice SLANG_MCALL getStyleName (ArtifactStyle style ) 119SLANG_OVERRIDE ; 120virtual SLANG_NO_THROW bool SLANG_MCALL 121isStyleDerivedFrom (ArtifactStyle style ,ArtifactStyle base )SLANG_OVERRIDE ; 122 123virtual SLANG_NO_THROW SlangResult SLANG_MCALL createLockFile ( 124const CharSlice & nameBase , 125IOSFileArtifactRepresentation ** outLockFile )SLANG_OVERRIDE ; 126 127virtual SLANG_NO_THROW SlangResult SLANG_MCALL calcArtifactDescPath ( 128const ArtifactDesc & desc , 129const char * basePath , 130ISlangBlob ** outPath )SLANG_OVERRIDE ; 131 132virtual SLANG_NO_THROW SlangResult SLANG_MCALL 133calcArtifactPath (IArtifact * ,const char * basePath ,ISlangBlob ** outPath )SLANG_OVERRIDE ; 134 135virtual SLANG_NO_THROW ArtifactDesc SLANG_MCALL 136makeDescForCompileTarget (SlangCompileTarget target )SLANG_OVERRIDE ; 137 138virtual SLANG_NO_THROW void SLANG_MCALL getCastable (ISlangUnknown * unk ,ICastable ** outCastable ) 139SLANG_OVERRIDE ; 140 141virtual SLANG_NO_THROW SlangResult SLANG_MCALL createOSFileArtifactRepresentation ( 142IOSFileArtifactRepresentation ::Kind kind , 143const CharSlice & path , 144IOSFileArtifactRepresentation * lockFile , 145IOSFileArtifactRepresentation ** outRep )SLANG_OVERRIDE ; 146 147virtual SLANG_NO_THROW SlangResult SLANG_MCALL createExtFileArtifactRepresentation ( 148const CharSlice & path , 149ISlangFileSystemExt * system , 150IExtFileArtifactRepresentation ** outRep )SLANG_OVERRIDE ; 151 152virtual SLANG_NO_THROW SlangResult SLANG_MCALL createOSFileArtifact ( 153const ArtifactDesc & desc , 154const CharSlice & slice , 155IArtifact ** outArtifact )SLANG_OVERRIDE ; 156 157static IArtifactHelper * getSingleton () {return & g_singleton ; } 158 159protected : 160void * getInterface (const Guid & guid ); 161void * getObject (const Guid & guid ); 162 163static DefaultArtifactHelper g_singleton ; 164}; 165 166}// namespace Slang 167 168#endif