Resource.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // Resource.cs
  6. //
  7. // Copyright 2015 Xamarin Inc. All rights reserved.
  8. using System;
  9. using System.Runtime.InteropServices;
  10. using System.Collections.Generic;
  11. using Urho.Urho2D;
  12. using Urho.Gui;
  13. using Urho.Resources;
  14. using Urho.IO;
  15. using Urho.Navigation;
  16. using Urho.Network;
  17. namespace Urho.Resources
  18. {
  19. /// <summary>
  20. /// Base class for resources.
  21. /// </summary>
  22. public unsafe partial class Resource : UrhoObject
  23. {
  24. unsafe partial void OnResourceCreated ();
  25. [Preserve]
  26. public Resource (IntPtr handle) : base (handle)
  27. {
  28. OnResourceCreated ();
  29. }
  30. [Preserve]
  31. protected Resource (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnResourceCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int Resource_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (Resource_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr Resource_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (Resource_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int Resource_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(Resource));
  54. return new StringHash (Resource_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr Resource_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(Resource));
  61. return Marshal.PtrToStringAnsi (Resource_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public Resource () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr Resource_Resource (IntPtr context);
  69. [Preserve]
  70. public Resource (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(Resource));
  73. handle = Resource_Resource ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnResourceCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern bool Resource_Load_File (IntPtr handle, IntPtr source);
  79. /// <summary>
  80. /// Load resource synchronously. Call both BeginLoad()
  81. /// &
  82. /// EndLoad() and return true if both succeeded.
  83. /// </summary>
  84. public bool Load (File source)
  85. {
  86. Runtime.ValidateRefCounted (this);
  87. return Resource_Load_File (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  88. }
  89. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  90. internal static extern bool Resource_Load_MemoryBuffer (IntPtr handle, IntPtr source);
  91. /// <summary>
  92. /// Load resource synchronously. Call both BeginLoad()
  93. /// &
  94. /// EndLoad() and return true if both succeeded.
  95. /// </summary>
  96. public bool Load (MemoryBuffer source)
  97. {
  98. Runtime.ValidateRefCounted (this);
  99. return Resource_Load_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  100. }
  101. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  102. internal static extern bool Resource_BeginLoad_File (IntPtr handle, IntPtr source);
  103. /// <summary>
  104. /// Load resource from stream. May be called from a worker thread. Return true if successful.
  105. /// </summary>
  106. public virtual bool BeginLoad (File source)
  107. {
  108. Runtime.ValidateRefCounted (this);
  109. return Resource_BeginLoad_File (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  110. }
  111. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  112. internal static extern bool Resource_BeginLoad_MemoryBuffer (IntPtr handle, IntPtr source);
  113. /// <summary>
  114. /// Load resource from stream. May be called from a worker thread. Return true if successful.
  115. /// </summary>
  116. public virtual bool BeginLoad (MemoryBuffer source)
  117. {
  118. Runtime.ValidateRefCounted (this);
  119. return Resource_BeginLoad_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  120. }
  121. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  122. internal static extern bool Resource_EndLoad (IntPtr handle);
  123. /// <summary>
  124. /// Finish resource loading. Always called from the main thread. Return true if successful.
  125. /// </summary>
  126. public virtual bool EndLoad ()
  127. {
  128. Runtime.ValidateRefCounted (this);
  129. return Resource_EndLoad (handle);
  130. }
  131. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  132. internal static extern bool Resource_Save_File (IntPtr handle, IntPtr dest);
  133. /// <summary>
  134. /// Save resource. Return true if successful.
  135. /// </summary>
  136. public virtual bool Save (File dest)
  137. {
  138. Runtime.ValidateRefCounted (this);
  139. return Resource_Save_File (handle, (object)dest == null ? IntPtr.Zero : dest.Handle);
  140. }
  141. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  142. internal static extern bool Resource_Save_MemoryBuffer (IntPtr handle, IntPtr dest);
  143. /// <summary>
  144. /// Save resource. Return true if successful.
  145. /// </summary>
  146. public virtual bool Save (MemoryBuffer dest)
  147. {
  148. Runtime.ValidateRefCounted (this);
  149. return Resource_Save_MemoryBuffer (handle, (object)dest == null ? IntPtr.Zero : dest.Handle);
  150. }
  151. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  152. internal static extern bool Resource_LoadFile (IntPtr handle, string fileName);
  153. /// <summary>
  154. /// Load resource from file.
  155. /// </summary>
  156. public bool LoadFile (string fileName)
  157. {
  158. Runtime.ValidateRefCounted (this);
  159. return Resource_LoadFile (handle, fileName);
  160. }
  161. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  162. internal static extern bool Resource_SaveFile (IntPtr handle, string fileName);
  163. /// <summary>
  164. /// Save resource to file.
  165. /// </summary>
  166. public virtual bool SaveFile (string fileName)
  167. {
  168. Runtime.ValidateRefCounted (this);
  169. return Resource_SaveFile (handle, fileName);
  170. }
  171. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  172. internal static extern void Resource_SetName (IntPtr handle, string name);
  173. /// <summary>
  174. /// Set name.
  175. /// </summary>
  176. private void SetName (string name)
  177. {
  178. Runtime.ValidateRefCounted (this);
  179. Resource_SetName (handle, name);
  180. }
  181. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  182. internal static extern void Resource_SetMemoryUse (IntPtr handle, uint size);
  183. /// <summary>
  184. /// Set memory use in bytes, possibly approximate.
  185. /// </summary>
  186. private void SetMemoryUse (uint size)
  187. {
  188. Runtime.ValidateRefCounted (this);
  189. Resource_SetMemoryUse (handle, size);
  190. }
  191. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  192. internal static extern void Resource_ResetUseTimer (IntPtr handle);
  193. /// <summary>
  194. /// Reset last used timer.
  195. /// </summary>
  196. public void ResetUseTimer ()
  197. {
  198. Runtime.ValidateRefCounted (this);
  199. Resource_ResetUseTimer (handle);
  200. }
  201. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  202. internal static extern void Resource_SetAsyncLoadState (IntPtr handle, AsyncLoadState newState);
  203. /// <summary>
  204. /// Set the asynchronous loading state. Called by ResourceCache. Resources in the middle of asynchronous loading are not normally returned to user.
  205. /// </summary>
  206. private void SetAsyncLoadState (AsyncLoadState newState)
  207. {
  208. Runtime.ValidateRefCounted (this);
  209. Resource_SetAsyncLoadState (handle, newState);
  210. }
  211. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  212. internal static extern IntPtr Resource_GetName (IntPtr handle);
  213. /// <summary>
  214. /// Return name.
  215. /// </summary>
  216. private string GetName ()
  217. {
  218. Runtime.ValidateRefCounted (this);
  219. return Marshal.PtrToStringAnsi (Resource_GetName (handle));
  220. }
  221. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  222. internal static extern int Resource_GetNameHash (IntPtr handle);
  223. /// <summary>
  224. /// Return name hash.
  225. /// </summary>
  226. private StringHash GetNameHash ()
  227. {
  228. Runtime.ValidateRefCounted (this);
  229. return new StringHash (Resource_GetNameHash (handle));
  230. }
  231. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  232. internal static extern uint Resource_GetMemoryUse (IntPtr handle);
  233. /// <summary>
  234. /// Return memory use in bytes, possibly approximate.
  235. /// </summary>
  236. private uint GetMemoryUse ()
  237. {
  238. Runtime.ValidateRefCounted (this);
  239. return Resource_GetMemoryUse (handle);
  240. }
  241. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  242. internal static extern uint Resource_GetUseTimer (IntPtr handle);
  243. /// <summary>
  244. /// Return time since last use in milliseconds. If referred to elsewhere than in the resource cache, returns always zero.
  245. /// </summary>
  246. private uint GetUseTimer ()
  247. {
  248. Runtime.ValidateRefCounted (this);
  249. return Resource_GetUseTimer (handle);
  250. }
  251. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  252. internal static extern AsyncLoadState Resource_GetAsyncLoadState (IntPtr handle);
  253. /// <summary>
  254. /// Return the asynchronous loading state.
  255. /// </summary>
  256. private AsyncLoadState GetAsyncLoadState ()
  257. {
  258. Runtime.ValidateRefCounted (this);
  259. return Resource_GetAsyncLoadState (handle);
  260. }
  261. public override StringHash Type {
  262. get {
  263. return UrhoGetType ();
  264. }
  265. }
  266. public override string TypeName {
  267. get {
  268. return GetTypeName ();
  269. }
  270. }
  271. [Preserve]
  272. public static StringHash TypeStatic {
  273. get {
  274. return GetTypeStatic ();
  275. }
  276. }
  277. public static string TypeNameStatic {
  278. get {
  279. return GetTypeNameStatic ();
  280. }
  281. }
  282. /// <summary>
  283. /// Return name.
  284. /// Or
  285. /// Set name.
  286. /// </summary>
  287. public string Name {
  288. get {
  289. return GetName ();
  290. }
  291. set {
  292. SetName (value);
  293. }
  294. }
  295. /// <summary>
  296. /// Return memory use in bytes, possibly approximate.
  297. /// Or
  298. /// Set memory use in bytes, possibly approximate.
  299. /// </summary>
  300. public uint MemoryUse {
  301. get {
  302. return GetMemoryUse ();
  303. }
  304. set {
  305. SetMemoryUse (value);
  306. }
  307. }
  308. /// <summary>
  309. /// Return the asynchronous loading state.
  310. /// Or
  311. /// Set the asynchronous loading state. Called by ResourceCache. Resources in the middle of asynchronous loading are not normally returned to user.
  312. /// </summary>
  313. public AsyncLoadState AsyncLoadState {
  314. get {
  315. return GetAsyncLoadState ();
  316. }
  317. set {
  318. SetAsyncLoadState (value);
  319. }
  320. }
  321. /// <summary>
  322. /// Return name hash.
  323. /// </summary>
  324. public StringHash NameHash {
  325. get {
  326. return GetNameHash ();
  327. }
  328. }
  329. /// <summary>
  330. /// Return time since last use in milliseconds. If referred to elsewhere than in the resource cache, returns always zero.
  331. /// </summary>
  332. public uint UseTimer {
  333. get {
  334. return GetUseTimer ();
  335. }
  336. }
  337. }
  338. }