/[gr2lib]/trunk/gr2lib/core/coreapi/coreapi.cs
ViewVC logotype

Diff of /trunk/gr2lib/core/coreapi/coreapi.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/gr2lib/core/coreapi/coreapi.cs	2010/07/24 05:43:04	190
+++ trunk/gr2lib/core/coreapi/coreapi.cs	2010/07/24 06:31:50	191
@@ -15,215 +15,338 @@
     {
         #region INTEROP SUPPORT
         /// <summary>
-        /// GetProcAddress(IntPtr hModule, string procName);
+        /// ExternalSupport class
         /// </summary>
-        /// <param name="hModule">pointer to module</param>
-        /// <param name="procName">procedure name</param>
-        /// <returns></returns>
-        [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
-        public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
-        /// <summary>
-        /// LoadLibrary(string lpFileName);
-        /// </summary>
-        /// <param name="lpFileName">filename</param>
-        /// <returns></returns>
-        [DllImport("kernel32", SetLastError = true)]
-        public static extern IntPtr LoadLibrary(string lpFileName);
+        public class ExternalSupport
+        {
+            /// <summary>
+            /// GetProcAddress(IntPtr hModule, string procName);
+            /// </summary>
+            /// <param name="hModule">pointer to module</param>
+            /// <param name="procName">procedure name</param>
+            /// <returns></returns>
+            [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
+            public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
+            /// <summary>
+            /// LoadLibrary(string lpFileName);
+            /// </summary>
+            /// <param name="lpFileName">filename</param>
+            /// <returns></returns>
+            [DllImport("kernel32", SetLastError = true)]
+            public static extern IntPtr LoadLibrary(string lpFileName);
+        }
         #endregion
 
         #region Granny2 API Version Support
         /// <summary>
-        /// GrannyVersionsMatch(major,minor,customization,build)
+        /// VersionSupport class
         /// </summary>
-        /// <param name="MajorVersion">an integer, representing the major</param>
-        /// <param name="MinorVersion">an integer, representing the minor</param>
-        /// <param name="Customization">an integer, representing the customization</param>
-        /// <param name="BuildNumber">an integer, representing the build</param>
-        /// <returns>boolean indicating if the supplied version matches what the granny2.dll's intenal version</returns>
-        [DllImport("granny2.dll", EntryPoint = "GrannyVersionsMatch_", CallingConvention = CallingConvention.StdCall)]
-        internal static extern bool GrannyVersionsMatch(granny_int32x MajorVersion, granny_int32x MinorVersion, granny_int32x Customization, granny_int32x BuildNumber);
-        /// <summary>
-        /// GrannyGetVersion(&amp;major,&amp;minor,&amp;customization,&amp;build)
-        /// </summary>
-        /// <param name="MajorVersion">an integer, to store the major</param>
-        /// <param name="MinorVersion">an integer, to store the minor</param>
-        /// <param name="Customization">an integer, to store the customization</param>
-        /// <param name="BuildNumber">an integer, to store the build</param>
-        [DllImport("granny2.dll", EntryPoint = "GrannyGetVersion", CallingConvention = CallingConvention.StdCall)]
-        internal static extern void GrannyGetVersion(ref granny_int32x MajorVersion, ref granny_int32x MinorVersion, ref granny_int32x Customization, ref granny_int32x BuildNumber);
-        /// <summary>
-        /// GrannyGetVersionString()
-        /// </summary>
-        /// <returns>a string representing the granny2.dll's internal library version</returns>
-        [DllImport("granny2.dll", EntryPoint = "GrannyGetVersionString", CallingConvention = CallingConvention.StdCall)]
-        internal static extern string GrannyGetVersionString();
+        public class VersionSupport
+        {
+            /// <summary>
+            /// GrannyVersionsMatch(major,minor,customization,build)
+            /// </summary>
+            /// <param name="MajorVersion">an integer, representing the major</param>
+            /// <param name="MinorVersion">an integer, representing the minor</param>
+            /// <param name="Customization">an integer, representing the customization</param>
+            /// <param name="BuildNumber">an integer, representing the build</param>
+            /// <returns>boolean indicating if the supplied version matches what the granny2.dll's intenal version</returns>
+            [DllImport("granny2.dll", EntryPoint = "GrannyVersionsMatch_", CallingConvention = CallingConvention.StdCall)]
+            internal static extern bool GrannyVersionsMatch(granny_int32x MajorVersion, granny_int32x MinorVersion, granny_int32x Customization, granny_int32x BuildNumber);
+            /// <summary>
+            /// GrannyGetVersion(&amp;major,&amp;minor,&amp;customization,&amp;build)
+            /// </summary>
+            /// <param name="MajorVersion">an integer, to store the major</param>
+            /// <param name="MinorVersion">an integer, to store the minor</param>
+            /// <param name="Customization">an integer, to store the customization</param>
+            /// <param name="BuildNumber">an integer, to store the build</param>
+            [DllImport("granny2.dll", EntryPoint = "GrannyGetVersion", CallingConvention = CallingConvention.StdCall)]
+            internal static extern void GrannyGetVersion(ref granny_int32x MajorVersion, ref granny_int32x MinorVersion, ref granny_int32x Customization, ref granny_int32x BuildNumber);
+            /// <summary>
+            /// GrannyGetVersionString()
+            /// </summary>
+            /// <returns>a string representing the granny2.dll's internal library version</returns>
+            [DllImport("granny2.dll", EntryPoint = "GrannyGetVersionString", CallingConvention = CallingConvention.StdCall)]
+            internal static extern string GrannyGetVersionString();
+        }
         #endregion
 
         #region Granny2 API File Loading Support
         /// <summary>
-        /// GrannyReadEntireFile(string fileName)
-        /// </summary>
-        /// <param name="fileName">the filename to load</param>
-        /// <returns>a pointer to the file</returns>
-        [DllImport("granny2.dll", EntryPoint = "GrannyReadEntireFile", CallingConvention = CallingConvention.StdCall)]
-        public static extern IntPtr GrannyReadEntireFile(string fileName);
-        /// <summary>
-        /// GetFileInfo(IntPtr file)
+        /// FileLoadingSupport class
         /// </summary>
-        /// <param name="file">pointer to the file: <see cref="GrannyReadEntireFile"/></param>
-        /// <returns>a pointer to the file info</returns>
-        [DllImport("granny2.dll", EntryPoint = "GrannyGetFileInfo", CallingConvention = CallingConvention.StdCall)]
-        public static extern IntPtr GetFileInfo(IntPtr file);
-        /// <summary>
-        /// FreeFile(IntPtr pointer)
-        /// </summary>
-        /// <param name="file">pointer to the file: <see cref="GrannyReadEntireFile"/></param>
-        [DllImport("granny2.dll", EntryPoint = "GrannyFreeFile", CallingConvention = CallingConvention.StdCall)]
-        public static extern void FreeFile(IntPtr file);
+        public class FileLoadingSupport
+        {
+            /// <summary>
+            /// GrannyReadEntireFile(string fileName)
+            /// </summary>
+            /// <param name="fileName">the filename to load</param>
+            /// <returns>a pointer to the file</returns>
+            [DllImport("granny2.dll", EntryPoint = "GrannyReadEntireFile", CallingConvention = CallingConvention.StdCall)]
+            public static extern IntPtr GrannyReadEntireFile(string fileName);
+            /// <summary>
+            /// GetFileInfo(IntPtr file)
+            /// </summary>
+            /// <param name="file">pointer to the file: <see cref="GrannyReadEntireFile"/></param>
+            /// <returns>a pointer to the file info</returns>
+            [DllImport("granny2.dll", EntryPoint = "GrannyGetFileInfo", CallingConvention = CallingConvention.StdCall)]
+            public static extern IntPtr GetFileInfo(IntPtr file);
+            /// <summary>
+            /// FreeFile(IntPtr pointer)
+            /// </summary>
+            /// <param name="file">pointer to the file: <see cref="GrannyReadEntireFile"/></param>
+            [DllImport("granny2.dll", EntryPoint = "GrannyFreeFile", CallingConvention = CallingConvention.StdCall)]
+            public static extern void FreeFile(IntPtr file);
+        }
         #endregion
 
         #region Granny2 API Header Support
         /// <summary>
-        /// GrannyGetFileTypeTag(IntPtr File)
+        /// HeaderSupport class
         /// </summary>
-        /// <param name="File">pointer to the file: <see cref="GrannyReadEntireFile"/></param>
-        /// <returns>an integer representing the TypeTag</returns>
-        [DllImport("granny2.dll", EntryPoint = "GrannyGetFileTypeTag", CallingConvention = CallingConvention.StdCall)]
-        public static extern int GrannyGetFileTypeTag(IntPtr File);
+        public class HeaderSupport
+        {
+            /// <summary>
+            /// GrannyGetFileTypeTag(IntPtr File)
+            /// </summary>
+            /// <param name="File">pointer to the file: <see cref="coreapi.FileLoadingSupport.GrannyReadEntireFile"/></param>
+            /// <returns>an integer representing the TypeTag</returns>
+            [DllImport("granny2.dll", EntryPoint = "GrannyGetFileTypeTag", CallingConvention = CallingConvention.StdCall)]
+            public static extern int GrannyGetFileTypeTag(IntPtr File);
+        }
         #endregion
 
         #region Granny2 API Granny Texture Format Support
         /// <summary>
-        /// GrannyCopyTextureImage(IntPtr Texture, int ImageIndex, int MIPIndex, IntPtr Layout, int DestWidth, int DestHeight, int DestStride, IntPtr Pixels);
+        /// TextureSupport class
         /// </summary>
-        /// <param name="Texture">pointer to the texture to copy (use the nativepointer, of the texture class)</param>
-        /// <param name="ImageIndex">index in the images list</param>
-        /// <param name="MIPIndex">index of the miplevel in the images list at ImageIndex</param>
-        /// <param name="Layout">pointer to the pixel layout (use the nativepointer, of the layout class)</param>
-        /// <param name="DestWidth">the target width</param>
-        /// <param name="DestHeight">the target height</param>
-        /// <param name="DestStride">width*bytesperpixel</param>
-        /// <param name="Pixels">pointer to the pixels (this will hold the copied pixels)</param>
-        /// <returns>a boolean value indicating that the copy operation succeeded</returns>
-        [DllImport("granny2.dll", EntryPoint = "_GrannyCopyTextureImage@32", CallingConvention = CallingConvention.StdCall)]
-        public static extern bool GrannyCopyTextureImage(IntPtr Texture, int ImageIndex, int MIPIndex, IntPtr Layout, int DestWidth, int DestHeight, int DestStride, IntPtr Pixels);
-        /// <summary>
-        /// GrannySwapRGBAToBGRA(granny_pixel_layout SourceLayoutFromEnum, out Layout SourcePixelLayout)
-        /// </summary>
-        /// <param name="SourceLayoutFromEnum">the source layout to swap: <see cref="granny_pixel_layout"/></param>
-        /// <param name="SwappedPixelLayout">returns the swapped pixel layout</param>
-        public static void GrannySwapRGBAToBGRA(granny_pixel_layout SourceLayoutFromEnum, out Layout SwappedPixelLayout)
+        public class TextureSupport
         {
-            SwappedPixelLayout = granny_pixel_layouts.GrannyDefaultPixelLayout;
-            switch (SourceLayoutFromEnum)
+            /// <summary>
+            /// GrannyCopyTextureImage(IntPtr Texture, int ImageIndex, int MIPIndex, IntPtr Layout, int DestWidth, int DestHeight, int DestStride, IntPtr Pixels);
+            /// </summary>
+            /// <param name="Texture">pointer to the texture to copy (use the nativepointer, of the texture class)</param>
+            /// <param name="ImageIndex">index in the images list</param>
+            /// <param name="MIPIndex">index of the miplevel in the images list at ImageIndex</param>
+            /// <param name="Layout">pointer to the pixel layout (use the nativepointer, of the layout class)</param>
+            /// <param name="DestWidth">the target width</param>
+            /// <param name="DestHeight">the target height</param>
+            /// <param name="DestStride">width*bytesperpixel</param>
+            /// <param name="Pixels">pointer to the pixels (this will hold the copied pixels)</param>
+            /// <returns>a boolean value indicating that the copy operation succeeded</returns>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyCopyTextureImage@32", CallingConvention = CallingConvention.StdCall)]
+            public static extern bool GrannyCopyTextureImage(IntPtr Texture, int ImageIndex, int MIPIndex, IntPtr Layout, int DestWidth, int DestHeight, int DestStride, IntPtr Pixels);
+            /// <summary>
+            /// GrannySwapRGBAToBGRA(granny_pixel_layout SourceLayoutFromEnum, out Layout SourcePixelLayout)
+            /// </summary>
+            /// <param name="SourceLayoutFromEnum">the source layout to swap: <see cref="granny_pixel_layout"/></param>
+            /// <param name="SwappedPixelLayout">returns the swapped pixel layout</param>
+            public static void GrannySwapRGBAToBGRA(granny_pixel_layout SourceLayoutFromEnum, out Layout SwappedPixelLayout)
             {
-                case granny_pixel_layout.GrannyBGR555PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyRGB555PixelFormat; break;
-                case granny_pixel_layout.GrannyBGR565PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyRGB565PixelFormat; break;
-                case granny_pixel_layout.GrannyBGR888PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyRGB888PixelFormat; break;
-                case granny_pixel_layout.GrannyBGRA4444PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyRGBA4444PixelFormat; break;
-                case granny_pixel_layout.GrannyBGRA5551PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyRGBA5551PixelFormat; break;
-                case granny_pixel_layout.GrannyBGRA8888PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyRGBA8888PixelFormat; break;
-                case granny_pixel_layout.GrannyRGB555PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyBGR555PixelFormat; break;
-                case granny_pixel_layout.GrannyRGB565PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyBGR565PixelFormat; break;
-                case granny_pixel_layout.GrannyRGB888PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyBGR888PixelFormat; break;
-                case granny_pixel_layout.GrannyRGBA4444PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyBGRA4444PixelFormat; break;
-                case granny_pixel_layout.GrannyRGBA5551PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyBGRA5551PixelFormat; break;
-                case granny_pixel_layout.GrannyRGBA8888PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyBGRA8888PixelFormat; break;
-                case granny_pixel_layout.GrannyARGB8888PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyABGR8888PixelFormat; break;
-                case granny_pixel_layout.GrannyABGR8888PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyARGB8888PixelFormat; break;
-                default: SwappedPixelLayout = granny_pixel_layouts.GrannyDefaultPixelLayout; break;
+                SwappedPixelLayout = granny_pixel_layouts.GrannyDefaultPixelLayout;
+                switch (SourceLayoutFromEnum)
+                {
+                    case granny_pixel_layout.GrannyBGR555PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyRGB555PixelFormat; break;
+                    case granny_pixel_layout.GrannyBGR565PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyRGB565PixelFormat; break;
+                    case granny_pixel_layout.GrannyBGR888PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyRGB888PixelFormat; break;
+                    case granny_pixel_layout.GrannyBGRA4444PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyRGBA4444PixelFormat; break;
+                    case granny_pixel_layout.GrannyBGRA5551PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyRGBA5551PixelFormat; break;
+                    case granny_pixel_layout.GrannyBGRA8888PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyRGBA8888PixelFormat; break;
+                    case granny_pixel_layout.GrannyRGB555PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyBGR555PixelFormat; break;
+                    case granny_pixel_layout.GrannyRGB565PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyBGR565PixelFormat; break;
+                    case granny_pixel_layout.GrannyRGB888PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyBGR888PixelFormat; break;
+                    case granny_pixel_layout.GrannyRGBA4444PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyBGRA4444PixelFormat; break;
+                    case granny_pixel_layout.GrannyRGBA5551PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyBGRA5551PixelFormat; break;
+                    case granny_pixel_layout.GrannyRGBA8888PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyBGRA8888PixelFormat; break;
+                    case granny_pixel_layout.GrannyARGB8888PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyABGR8888PixelFormat; break;
+                    case granny_pixel_layout.GrannyABGR8888PixelFormat: SwappedPixelLayout = granny_pixel_layouts.GrannyARGB8888PixelFormat; break;
+                    default: SwappedPixelLayout = granny_pixel_layouts.GrannyDefaultPixelLayout; break;
+                }
             }
+            /// <summary>
+            /// 
+            /// </summary>
+            /// <param name="Width"></param>
+            /// <param name="Height"></param>
+            /// <param name="ResultingLayout"></param>
+            /// <param name="StrideAlignment"></param>
+            /// <returns></returns>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyBeginRawTexture@16", CallingConvention = CallingConvention.StdCall)]
+            public static extern IntPtr GrannyBeginRawTexture(granny_int32x Width, granny_int32x Height, IntPtr ResultingLayout, granny_int32x StrideAlignment);
+            /// <summary>
+            /// 
+            /// </summary>
+            /// <param name="Width"></param>
+            /// <param name="Height"></param>
+            /// <param name="Format"></param>
+            /// <returns></returns>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyBeginS3TCTexture@12", CallingConvention = CallingConvention.StdCall)]
+            public static extern IntPtr GrannyBeginS3TCTexture(granny_int32x Width, granny_int32x Height, granny_s3tc_texture_format Format);
+            /// <summary>
+            /// 
+            /// </summary>
+            /// <param name="Width"></param>
+            /// <param name="Height"></param>
+            /// <returns></returns>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyBeginBestMatchS3TCTexture@8", CallingConvention = CallingConvention.StdCall)]
+            public static extern IntPtr GrannyBeginBestMatchS3TCTexture(granny_int32x Width, granny_int32x Height);
+            /// <summary>
+            /// 
+            /// </summary>
+            /// <param name="Width"></param>
+            /// <param name="Height"></param>
+            /// <param name="Compression"></param>
+            /// <param name="Flags"></param>
+            /// <returns></returns>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyBeginBinkTexture@16", CallingConvention = CallingConvention.StdCall)]
+            public static extern IntPtr GrannyBeginBinkTexture(granny_int32x Width, granny_int32x Height, granny_int32x Compression, granny_uint32x Flags);
+            /// <summary>
+            /// 
+            /// </summary>
+            /// <param name="Builder"></param>
+            /// <returns></returns>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyEndTexture@4", CallingConvention = CallingConvention.StdCall)]
+            public static extern IntPtr GrannyEndTexture(IntPtr Builder);
+            /// <summary>
+            /// 
+            /// </summary>
+            /// <param name="Builder"></param>
+            /// <returns></returns>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyGetResultingTextureSize@4", CallingConvention = CallingConvention.StdCall)]
+            public static extern granny_int32x GrannyGetResultingTextureSize(gr2lib.core.coretypes.native.granny_texture_builder Builder);
+            /// <summary>
+            /// 
+            /// </summary>
+            /// <param name="Builder"></param>
+            /// <param name="Memory"></param>
+            /// <returns></returns>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyEndTextureInPlace@8", CallingConvention = CallingConvention.StdCall)]
+            public static extern IntPtr GrannyEndTextureInPlace(IntPtr Builder, IntPtr Memory);
+            /// <summary>
+            /// 
+            /// </summary>
+            /// <param name="Builder"></param>
+            /// <param name="UpsamplingFilter"></param>
+            /// <param name="DownsamplingFilter"></param>
+            [DllImport("granny2.dll", EntryPoint = "_GrannySetImageScalingFilter@12", CallingConvention = CallingConvention.StdCall)]
+            public static extern void GrannySetImageScalingFilter(IntPtr Builder, granny_pixel_filter_type UpsamplingFilter, granny_pixel_filter_type DownsamplingFilter);
+            /// <summary>
+            /// 
+            /// </summary>
+            /// <param name="Builder"></param>
+            /// <param name="Width"></param>
+            /// <param name="Height"></param>
+            /// <param name="Stride"></param>
+            /// <param name="MIPLevelCount"></param>
+            /// <param name="RGBAData"></param>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyEncodeImage@24", CallingConvention = CallingConvention.StdCall)]
+            public static extern void GrannyEncodeImage(IntPtr Builder, granny_int32x Width, granny_int32x Height, granny_int32x Stride, granny_int32x MIPLevelCount, IntPtr RGBAData);
         }
+
+
+
         #endregion
 
         #region Granny2 API Logging Support
         /// <summary>
-        /// Delegate for the LogCallBack
-        /// </summary>
-        /// <param name="Type">The Log Type <see cref="granny_log_message_type"/></param>
-        /// <param name="Origin">The Log Origin <see cref="granny_log_message_origin"/></param>
-        /// <param name="Message">the message</param>
-        /// <param name="UserData">pointer to userdata [will always be IntPtr.Zero, in gr2lib]</param>
-        [DllImport("granny2.dll", EntryPoint = "granny_log_function", CallingConvention = CallingConvention.StdCall)]
-        public static extern void granny_log_function(granny_log_message_type Type, granny_log_message_origin Origin, string Message, IntPtr UserData);        
-        /// <summary>
-        /// Set the Log Callback
-        /// </summary>
-        /// <param name="LogCallback">the callback <see cref="gr2lib.core.coretypes.implementation.granny_log_callback_builder.granny_log_callback"/></param>
-        [DllImport("granny2.dll", EntryPoint = "_GrannySetLogCallback@4", CallingConvention = CallingConvention.StdCall)]
-        public static extern void GrannySetLogCallback(ref gr2lib.core.coretypes.implementation.granny_log_callback_builder.granny_log_callback LogCallback);
-        /// <summary>
-        /// Get the Log Callback
-        /// </summary>
-        /// <param name="LogCallback">returns the callback <see cref="gr2lib.core.coretypes.implementation.granny_log_callback_builder.granny_log_callback"/></param>
-        [DllImport("granny2.dll", EntryPoint = "_GrannyGetLogCallback@4", CallingConvention = CallingConvention.StdCall)]
-        public static extern void GrannyGetLogCallback(out gr2lib.core.coretypes.implementation.granny_log_callback_builder.granny_log_callback LogCallback);
-        /// <summary>
-        /// Explicitly allow or disallow all logging
+        /// LoggingSupport class
         /// </summary>
-        /// <param name="Enabled">True = allow, False = disallow</param>
-        [DllImport("granny2.dll", EntryPoint = "_GrannyFilterAllMessages@4", CallingConvention = CallingConvention.StdCall)]
-        public static extern void GrannyFilterAllMessages(bool Enabled);
-        /// <summary>
-        /// Explicitly allow or disallow logging from specific Origin
-        /// </summary>
-        /// <param name="Origin">The Log Origin <see cref="granny_log_message_origin"/></param>
-        /// <param name="Enabled">>True = allow, False = disallow</param>
-        [DllImport("granny2.dll", EntryPoint = "_GrannyFilterMessage@8", CallingConvention = CallingConvention.StdCall)]
-        public static extern void GrannyFilterMessage(granny_log_message_origin Origin, bool Enabled);
-        /// <summary>
-        /// Check to see if anything is listening to log events
-        /// </summary>
-        /// <returns>a boolean value indicating if anything is listening to log events</returns>
-        [DllImport("granny2.dll", EntryPoint = "_GrannyLogging@0", CallingConvention = CallingConvention.StdCall)]
-        public static extern bool GrannyLogging();
-        /// <summary>
-        /// Returns the last Message Log Type, that was the most serious
-        /// </summary>
-        /// <returns></returns>
-        [DllImport("granny2.dll", EntryPoint = "_GrannyGetMostSeriousMessageType@0", CallingConvention = CallingConvention.StdCall)]
-        public static extern granny_log_message_type GrannyGetMostSeriousMessageType();
-        /// <summary>
-        /// Get the message from the last most serious message
-        /// </summary>
-        /// <returns></returns>
-        [DllImport("granny2.dll", EntryPoint = "_GrannyGetMostSeriousMessage@0", CallingConvention = CallingConvention.StdCall)]
-        public static extern string GrannyGetMostSeriousMessage();
-        /// <summary>
-        /// Clear the last most serious message, so that new messages can be tracked 
-        /// </summary>
-        [DllImport("granny2.dll", EntryPoint = "_GrannyClearMostSeriousMessage@0", CallingConvention = CallingConvention.StdCall)]
-        public static extern void GrannyClearMostSeriousMessage();
-        /// <summary>
-        /// Enable logging of all Granny reports to a file: 
-        /// </summary>
-        /// <param name="FileName">Filenanme to log to</param>
-        /// <param name="Clear">True = overwrite file, False = append to file</param>
-        /// <returns></returns>
-        [DllImport("granny2.dll", EntryPoint = "_GrannySetLogFileName@8", CallingConvention = CallingConvention.StdCall)]
-        public static extern bool GrannySetLogFileName([MarshalAs(UnmanagedType.LPStr)] string FileName, bool Clear);
+        public class LoggingSupport
+        {
+            /// <summary>
+            /// Delegate for the LogCallBack
+            /// </summary>
+            /// <param name="Type">The Log Type <see cref="granny_log_message_type"/></param>
+            /// <param name="Origin">The Log Origin <see cref="granny_log_message_origin"/></param>
+            /// <param name="Message">the message</param>
+            /// <param name="UserData">pointer to userdata [will always be IntPtr.Zero, in gr2lib]</param>
+            [DllImport("granny2.dll", EntryPoint = "granny_log_function", CallingConvention = CallingConvention.StdCall)]
+            public static extern void granny_log_function(granny_log_message_type Type, granny_log_message_origin Origin, string Message, IntPtr UserData);
+            /// <summary>
+            /// Set the Log Callback
+            /// </summary>
+            /// <param name="LogCallback">the callback <see cref="gr2lib.core.coretypes.implementation.granny_log_callback_builder.granny_log_callback"/></param>
+            [DllImport("granny2.dll", EntryPoint = "_GrannySetLogCallback@4", CallingConvention = CallingConvention.StdCall)]
+            public static extern void GrannySetLogCallback(ref gr2lib.core.coretypes.implementation.granny_log_callback_builder.granny_log_callback LogCallback);
+            /// <summary>
+            /// Get the Log Callback
+            /// </summary>
+            /// <param name="LogCallback">returns the callback <see cref="gr2lib.core.coretypes.implementation.granny_log_callback_builder.granny_log_callback"/></param>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyGetLogCallback@4", CallingConvention = CallingConvention.StdCall)]
+            public static extern void GrannyGetLogCallback(out gr2lib.core.coretypes.implementation.granny_log_callback_builder.granny_log_callback LogCallback);
+            /// <summary>
+            /// Explicitly allow or disallow all logging
+            /// </summary>
+            /// <param name="Enabled">True = allow, False = disallow</param>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyFilterAllMessages@4", CallingConvention = CallingConvention.StdCall)]
+            public static extern void GrannyFilterAllMessages(bool Enabled);
+            /// <summary>
+            /// Explicitly allow or disallow logging from specific Origin
+            /// </summary>
+            /// <param name="Origin">The Log Origin <see cref="granny_log_message_origin"/></param>
+            /// <param name="Enabled">>True = allow, False = disallow</param>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyFilterMessage@8", CallingConvention = CallingConvention.StdCall)]
+            public static extern void GrannyFilterMessage(granny_log_message_origin Origin, bool Enabled);
+            /// <summary>
+            /// Check to see if anything is listening to log events
+            /// </summary>
+            /// <returns>a boolean value indicating if anything is listening to log events</returns>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyLogging@0", CallingConvention = CallingConvention.StdCall)]
+            public static extern bool GrannyLogging();
+            /// <summary>
+            /// Returns the last Message Log Type, that was the most serious
+            /// </summary>
+            /// <returns></returns>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyGetMostSeriousMessageType@0", CallingConvention = CallingConvention.StdCall)]
+            public static extern granny_log_message_type GrannyGetMostSeriousMessageType();
+            /// <summary>
+            /// Get the message from the last most serious message
+            /// </summary>
+            /// <returns></returns>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyGetMostSeriousMessage@0", CallingConvention = CallingConvention.StdCall)]
+            public static extern string GrannyGetMostSeriousMessage();
+            /// <summary>
+            /// Clear the last most serious message, so that new messages can be tracked 
+            /// </summary>
+            [DllImport("granny2.dll", EntryPoint = "_GrannyClearMostSeriousMessage@0", CallingConvention = CallingConvention.StdCall)]
+            public static extern void GrannyClearMostSeriousMessage();
+            /// <summary>
+            /// Enable logging of all Granny reports to a file: 
+            /// </summary>
+            /// <param name="FileName">Filenanme to log to</param>
+            /// <param name="Clear">True = overwrite file, False = append to file</param>
+            /// <returns></returns>
+            [DllImport("granny2.dll", EntryPoint = "_GrannySetLogFileName@8", CallingConvention = CallingConvention.StdCall)]
+            public static extern bool GrannySetLogFileName([MarshalAs(UnmanagedType.LPStr)] string FileName, bool Clear);
+        }
         #endregion
 
         #region Granny2 API Enum Value to String Support
         /// <summary>
-        /// GetGrannyEnumTypeString&lt;T&gt;(T _type)
-        /// </summary>
-        /// <typeparam name="T">The Type of the enum</typeparam>
-        /// <param name="_type">The Enum value</param>
-        /// <returns>The name of the enum member associated with the _type value</returns>
-        public static string GetGrannyEnumTypeString<T>(T _type) { return Enum.GetName(typeof(T), _type); }
-        /// <summary>
-        /// GrannyGetLogMessageTypeString(granny_log_message_type Type)
-        /// </summary>
-        /// <param name="Type">The Log Type <see cref="granny_log_message_type"/></param>
-        /// <returns>The name of the enum member associated with the Type value</returns>
-        public static string GrannyGetLogMessageTypeString(granny_log_message_type Type) { try { return GetGrannyEnumTypeString<granny_log_message_type>(Type); } catch { return GetGrannyEnumTypeString<granny_log_message_type>(granny_log_message_type.GrannyUnknownLogMessage); } }
-        /// <summary>
-        /// rannyGetLogMessageOriginString(granny_log_message_origin Origin)
+        /// EnumToStringSupport class
         /// </summary>
-        /// <param name="Origin">The Log Origin <see cref="granny_log_message_origin"/></param>
-        /// <returns>The name of the enum member associated with the Origin value</returns>
-        public static string GrannyGetLogMessageOriginString(granny_log_message_origin Origin) { try { return GetGrannyEnumTypeString<granny_log_message_origin>(Origin); } catch { return GetGrannyEnumTypeString<granny_log_message_origin>(granny_log_message_origin.GrannyUnknownLogMessage); } }
+        public class EnumToStringSupport
+        {
+            /// <summary>
+            /// GetGrannyEnumTypeString&lt;T&gt;(T _type)
+            /// </summary>
+            /// <typeparam name="T">The Type of the enum</typeparam>
+            /// <param name="_type">The Enum value</param>
+            /// <returns>The name of the enum member associated with the _type value</returns>
+            public static string GetGrannyEnumTypeString<T>(T _type) { return Enum.GetName(typeof(T), _type); }
+            /// <summary>
+            /// GrannyGetLogMessageTypeString(granny_log_message_type Type)
+            /// </summary>
+            /// <param name="Type">The Log Type <see cref="granny_log_message_type"/></param>
+            /// <returns>The name of the enum member associated with the Type value</returns>
+            public static string GrannyGetLogMessageTypeString(granny_log_message_type Type) { try { return GetGrannyEnumTypeString<granny_log_message_type>(Type); } catch { return GetGrannyEnumTypeString<granny_log_message_type>(granny_log_message_type.GrannyUnknownLogMessage); } }
+            /// <summary>
+            /// rannyGetLogMessageOriginString(granny_log_message_origin Origin)
+            /// </summary>
+            /// <param name="Origin">The Log Origin <see cref="granny_log_message_origin"/></param>
+            /// <returns>The name of the enum member associated with the Origin value</returns>
+            public static string GrannyGetLogMessageOriginString(granny_log_message_origin Origin) { try { return GetGrannyEnumTypeString<granny_log_message_origin>(Origin); } catch { return GetGrannyEnumTypeString<granny_log_message_origin>(granny_log_message_origin.GrannyUnknownLogMessage); } }
         #endregion
+        }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22