Salome HOME
PR: manual correction while merge PAL_OCC to HEAD
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttReal_i.cxx
1 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOMEDS_AttReal_i.cxx
25 //  Author : Estelle Deville
26 //  Module : SALOME
27 //  $Header$
28
29 using namespace std;
30 #include "SALOMEDS_AttReal_i.hxx"
31 #include "utilities.h"
32 #include <TDF_Tool.hxx>
33 #include <stdio.h>
34 #include <cstring>
35
36 //============================================================================
37 /*! Function : Set
38  *  Purpose  : Affect a value to the basic attribute
39  */
40 //============================================================================
41 void SALOMEDS_AttReal_i::Set(CORBA::Double r)
42 {
43   CheckLocked();
44   TDataStd_Real::Set (_Lab,r);
45 }
46
47 //============================================================================
48 /*! Function : Get
49  *  Purpose  : Get basic attribute's value
50  */
51 //============================================================================
52 CORBA::Double SALOMEDS_AttReal_i::Get()
53 {
54   Handle(TDataStd_Real) Att;
55   CORBA::Double x;
56   if (_Lab.FindAttribute(TDataStd_Real::GetID(),Att))
57     x = Att->Get ();
58   return x;
59 }
60
61 //============================================================================
62 /*! Function : Save
63  *  Purpose  : 
64  */
65 //============================================================================
66 char* SALOMEDS_AttReal_i::Save()
67 {
68   BEGIN_OF("SALOMEDS_AttReal_i::Save");
69   CORBA::Double x = this->Get();
70   char* out= new char[12];
71   sprintf(out,"%g",x);
72   return out; 
73 }
74
75 //============================================================================
76 /*! Function : Load
77  *  Purpose  : 
78  */
79 //============================================================================
80 void SALOMEDS_AttReal_i::Load()
81 {
82   BEGIN_OF("SALOMEDS_AttReal_i::Load");
83 }
84
85 //============================================================================
86 /*! Function : GetPtr
87  *  Purpose  : return sobject associated to the basic attribute (if exist)
88  */
89 //============================================================================
90 CORBA::Boolean SALOMEDS_AttReal_i::GetPtr(SALOMEDS::SObject_ptr anObject)
91 {
92   Handle(TDataStd_Real) Att;
93   return _Lab.FindAttribute(TDataStd_Real::GetID(),Att);
94 }
95
96 //============================================================================
97 /*! Function : GetType
98  *  Purpose  : 
99  */
100 //============================================================================
101 char* SALOMEDS_AttReal_i::GetType()
102 {
103   return CORBA::string_dup(_type);
104 }