~ubuntu-branches/ubuntu/trusty/liblas/trusty-proposed

« back to all changes in this revision

Viewing changes to csharp/dotnetLibLAS/LASGuid.cs

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2014-01-05 17:00:29 UTC
  • mfrom: (7.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140105170029-ddtp0j63x5jvck2u
Tags: 1.7.0+dfsg-2
Fixed missing linking of system boost component.
(closes: #733282)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * $Id$
 
3
 *
 
4
 * Project:  libLAS - http://liblas.org - A BSD library for LAS format data.
 
5
 * Purpose:  
 
6
 * Author:   Martin Vales, martin_gnu@mundo-r.com
 
7
 *
 
8
 ******************************************************************************
 
9
 * Copyright (c) 2008, Martin Vales
 
10
 *
 
11
 * All rights reserved.
 
12
 * 
 
13
 * Redistribution and use in source and binary forms, with or without 
 
14
 * modification, are permitted provided that the following 
 
15
 * conditions are met:
 
16
 * 
 
17
 *     * Redistributions of source code must retain the above copyright 
 
18
 *       notice, this list of conditions and the following disclaimer.
 
19
 *     * Redistributions in binary form must reproduce the above copyright 
 
20
 *       notice, this list of conditions and the following disclaimer in 
 
21
 *       the documentation and/or other materials provided 
 
22
 *       with the distribution.
 
23
 *     * Neither the name of the Martin Isenburg or Iowa Department 
 
24
 *       of Natural Resources nor the names of its contributors may be 
 
25
 *       used to endorse or promote products derived from this software 
 
26
 *       without specific prior written permission.
 
27
 * 
 
28
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 
29
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 
30
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 
31
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 
32
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
 
33
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 
34
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
 
35
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 
36
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
 
37
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
 
38
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
 
39
 * OF SUCH DAMAGE.
 
40
 ****************************************************************************/
 
41
 
 
42
using System;
 
43
using System.Collections.Generic;
 
44
using System.Text;
 
45
using LASError = System.Int32;
 
46
using LASWriterH = System.IntPtr;
 
47
using LASReaderH = System.IntPtr;
 
48
using LASPointH = System.IntPtr;
 
49
using LASGuidH = System.IntPtr;
 
50
using LASVLRH = System.IntPtr;
 
51
using LASHeaderH = System.IntPtr;
 
52
 
 
53
namespace LibLAS
 
54
{
 
55
    /// <summary>
 
56
    /// LASGuid class
 
57
    /// </summary>
 
58
    public class LASGuid : IDisposable
 
59
    {
 
60
        private LASGuidH hguid;
 
61
 
 
62
        /// <summary>
 
63
        /// The object user should call this method when they finished with the object.
 
64
        /// </summary>
 
65
        /// 
 
66
        public void Dispose()
 
67
        {
 
68
            CAPI.LASGuid_Destroy(hguid);
 
69
            // Clean up unmanaged resources here.
 
70
            // Dispose other contained disposable objects.
 
71
        }
 
72
 
 
73
        /// <summary>
 
74
        /// Create a new random GUID.
 
75
        /// </summary>
 
76
        public LASGuid()
 
77
        {
 
78
            hguid = CAPI.LASGuid_Create();
 
79
        }
 
80
 
 
81
        /// <summary>
 
82
        ///  Creates a new GUID using a opaque pointer.  
 
83
        /// </summary>
 
84
        /// <param name="hGuid">LASGuidH opaque pointer</param>
 
85
        public LASGuid(LASGuidH hGuid)
 
86
        {
 
87
            hguid = hGuid;
 
88
        }
 
89
 
 
90
        /// <summary>
 
91
        /// Creates a new GUID opaque pointer using the given string.  
 
92
        /// </summary>
 
93
        /// <remarks>An example GUID might be something like '8388F1B8-AA1B-4108-BCA3-6BC68E7B062E'</remarks>
 
94
        /// <param name="guidString">string A GUID string in the form "00000000-0000-0000-0000-000000000000"</param>
 
95
        public LASGuid(String guidString)
 
96
        {
 
97
            hguid = CAPI.LASGuid_CreateFromString(guidString);
 
98
        }
 
99
 
 
100
        /// <summary>
 
101
        /// Gets the String value of the Guid
 
102
        /// </summary>
 
103
        /// <returns>the String value of the Guid</returns>
 
104
        public override string ToString()
 
105
        {
 
106
            return CAPI.LASGuid_AsString(hguid);
 
107
        }
 
108
 
 
109
        /// <summary>
 
110
        /// Gets the GUID opaque pointer
 
111
        /// </summary>
 
112
        /// <returns>the GUID opaque pointer</returns>
 
113
        internal LASGuidH GetPointer()
 
114
        {
 
115
            return hguid;
 
116
        }
 
117
 
 
118
        /// <summary>
 
119
        /// test if is equal to other object.
 
120
        /// </summary>
 
121
        /// <param name="obj">object to compare</param>
 
122
        /// <returns>true if both are equal</returns>
 
123
        public override bool Equals(object obj)
 
124
        {
 
125
            //if parameter is null return false
 
126
            if (obj == null)
 
127
            {
 
128
                return false;
 
129
            }
 
130
 
 
131
            //if parameter cannot be cast to Guid return false
 
132
            LASGuid guidd = obj as LASGuid;
 
133
            if ((object)guidd == null)
 
134
            {
 
135
                return false;
 
136
            }
 
137
 
 
138
            if (CAPI.LASGuid_Equals(hguid, guidd.GetPointer()) == 1)
 
139
            {
 
140
                return true;
 
141
            }
 
142
            else
 
143
            {
 
144
                return false;
 
145
            }
 
146
        }
 
147
 
 
148
        /// <summary>
 
149
        /// 
 
150
        /// </summary>
 
151
        /// <returns></returns>
 
152
        public override int GetHashCode()
 
153
        {
 
154
            return base.GetHashCode();
 
155
        }
 
156
 
 
157
        /// <summary>
 
158
        /// test if is equal to other LASGuid.
 
159
        /// </summary>
 
160
        /// <param name="obj">LASGuid to compare</param>
 
161
        /// <returns>true if both are equal</returns>
 
162
        public bool Equals(LASGuid obj)
 
163
        {
 
164
            //if parameter cannot be cast to Guid return false
 
165
 
 
166
            if ((object)obj == null)
 
167
            {
 
168
                return false;
 
169
            }
 
170
 
 
171
            if (CAPI.LASGuid_Equals(hguid, obj.GetPointer()) == 1)
 
172
            {
 
173
                return true;
 
174
            }
 
175
            else
 
176
            {
 
177
                return false;
 
178
            }
 
179
        }
 
180
    }
 
181
}