Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:30

0001 // Created on: 1992-06-22
0002 // Created by: Gilles DEBARBOUILLE
0003 // Copyright (c) 1992-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Units_Token_HeaderFile
0018 #define _Units_Token_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <TCollection_AsciiString.hxx>
0024 #include <Standard_Transient.hxx>
0025 #include <Standard_Integer.hxx>
0026 class Units_Dimensions;
0027 
0028 
0029 class Units_Token;
0030 DEFINE_STANDARD_HANDLE(Units_Token, Standard_Transient)
0031 
0032 //! This class defines an elementary word contained in
0033 //! a Sentence object.
0034 class Units_Token : public Standard_Transient
0035 {
0036 
0037 public:
0038 
0039   
0040   //! Creates and returns a empty token.
0041   Standard_EXPORT Units_Token();
0042   
0043   //! Creates  and returns  a token.   <aword>  is  a string
0044   //! containing the available word.
0045   Standard_EXPORT Units_Token(const Standard_CString aword);
0046   
0047   //! Creates and returns a  token.  <atoken> is  copied  in
0048   //! the returned token.
0049   Standard_EXPORT Units_Token(const Handle(Units_Token)& atoken);
0050   
0051   //! Creates  and  returns a  token.   <aword> is  a string
0052   //! containing the  available word and  <amean>  gives the
0053   //! signification of the token.
0054   Standard_EXPORT Units_Token(const Standard_CString aword, const Standard_CString amean);
0055   
0056   //! Creates   and  returns a  token.   <aword> is a string
0057   //! containing   the available  word,  <amean> gives   the
0058   //! signification of the token and <avalue> is the numeric
0059   //! value of the dimension.
0060   Standard_EXPORT Units_Token(const Standard_CString aword, const Standard_CString amean, const Standard_Real avalue);
0061   
0062   //! Creates and returns  a  token.  <aword> is   a  string
0063   //! containing the   available   word, <amean>   gives the
0064   //! signification of  the  token, <avalue> is  the numeric
0065   //! value  of the dimension,  and <adimensions>   is   the
0066   //! dimension of the given word <aword>.
0067   Standard_EXPORT Units_Token(const Standard_CString aword, const Standard_CString amean, const Standard_Real avalue, const Handle(Units_Dimensions)& adimension);
0068   
0069   //! Creates and returns a  token, which is a ShiftedToken.
0070   Standard_EXPORT virtual Handle(Units_Token) Creates() const;
0071   
0072   //! Returns the length of the word.
0073   Standard_EXPORT Standard_Integer Length() const;
0074   
0075   //! Returns the string <theword>
0076     TCollection_AsciiString Word() const;
0077   
0078   //! Sets the field <theword> to <aword>.
0079     void Word (const Standard_CString aword);
0080   
0081   //! Returns the significance of the word  <theword>, which
0082   //! is in the field <themean>.
0083     TCollection_AsciiString Mean() const;
0084   
0085   //! Sets the field <themean> to <amean>.
0086     void Mean (const Standard_CString amean);
0087   
0088   //! Returns the value stored in the field <thevalue>.
0089     Standard_Real Value() const;
0090   
0091   //! Sets the field <thevalue> to <avalue>.
0092     void Value (const Standard_Real avalue);
0093   
0094   //! Returns the dimensions of the token <thedimensions>.
0095     Handle(Units_Dimensions) Dimensions() const;
0096   
0097   //! Sets the field <thedimensions> to <adimensions>.
0098   Standard_EXPORT void Dimensions (const Handle(Units_Dimensions)& adimensions);
0099   
0100   //! Updates     the  token  <me>    with  the   additional
0101   //! signification  <amean> by  concatenation   of the  two
0102   //! strings   <themean>    and   <amean>.   If    the  two
0103   //! significations are  the same  , an information message
0104   //! is written in the output device.
0105   Standard_EXPORT void Update (const Standard_CString amean);
0106   
0107   Standard_EXPORT Handle(Units_Token) Add (const Standard_Integer aninteger) const;
0108   
0109   //! Returns a  token which is  the addition  of  <me>  and
0110   //! another token <atoken>. The  addition  is  possible if
0111   //! and only if the dimensions are the same.
0112   Standard_EXPORT Handle(Units_Token) Add (const Handle(Units_Token)& atoken) const;
0113   
0114   //! Returns a token  which is the  subtraction of <me> and
0115   //! another token <atoken>. The subtraction is possible if
0116   //! and only if the dimensions are the same.
0117   Standard_EXPORT Handle(Units_Token) Subtract (const Handle(Units_Token)& atoken) const;
0118   
0119   //! Returns a  token  which  is the  product of   <me> and
0120   //! another token <atoken>.
0121   Standard_EXPORT Handle(Units_Token) Multiply (const Handle(Units_Token)& atoken) const;
0122   
0123   //! This   virtual method is   called  by  the Measurement
0124   //! methods,  to  compute    the   measurement   during  a
0125   //! conversion.
0126   Standard_NODISCARD Standard_EXPORT virtual Standard_Real Multiplied (const Standard_Real avalue) const;
0127   
0128   //! Returns a token which is the division of <me> by another
0129   //! token <atoken>.
0130   Standard_EXPORT Handle(Units_Token) Divide (const Handle(Units_Token)& atoken) const;
0131   
0132   //! This  virtual  method  is  called by  the  Measurement
0133   //! methods,   to   compute   the measurement  during    a
0134   //! conversion.
0135   Standard_NODISCARD Standard_EXPORT virtual Standard_Real Divided (const Standard_Real avalue) const;
0136   
0137   //! Returns a token which is <me> to the power  of another
0138   //! token <atoken>.  The computation  is possible  only if
0139   //! <atoken> is a dimensionless constant.
0140   Standard_EXPORT Handle(Units_Token) Power (const Handle(Units_Token)& atoken) const;
0141   
0142   //! Returns a token which is <me> to the power  of <anexponent>.
0143   Standard_EXPORT Handle(Units_Token) Power (const Standard_Real anexponent) const;
0144   
0145   //! Returns true if  the  field <theword> and  the  string
0146   //! <astring> are the same, false otherwise.
0147   Standard_EXPORT Standard_Boolean IsEqual (const Standard_CString astring) const;
0148   
0149   //! Returns true  if the  field  <theword> and  the string
0150   //! <theword> contained  in  the  token <atoken>  are  the
0151   //! same, false otherwise.
0152   Standard_EXPORT Standard_Boolean IsEqual (const Handle(Units_Token)& atoken) const;
0153   
0154   //! Returns false if  the field <theword>  and the  string
0155   //! <astring> are the same, true otherwise.
0156     Standard_Boolean IsNotEqual (const Standard_CString astring) const;
0157   
0158   //! Returns false if  the field <theword>  and the  string
0159   //! <theword> contained  in the  token  <atoken>  are  the
0160   //! same, true otherwise.
0161     Standard_Boolean IsNotEqual (const Handle(Units_Token)& atoken) const;
0162   
0163   //! Returns   true  if the   field <theword>  is  strictly
0164   //! contained at  the beginning  of the string  <astring>,
0165   //! false otherwise.
0166     Standard_Boolean IsLessOrEqual (const Standard_CString astring) const;
0167   
0168   //! Returns false  if   the field   <theword> is  strictly
0169   //! contained at  the  beginning  of the string <astring>,
0170   //! true otherwise.
0171     Standard_Boolean IsGreater (const Standard_CString astring) const;
0172   
0173   //! Returns false  if   the field   <theword> is  strictly
0174   //! contained at  the  beginning  of the string <astring>,
0175   //! true otherwise.
0176     Standard_Boolean IsGreater (const Handle(Units_Token)& atoken) const;
0177   
0178   //! Returns true  if  the string <astring>   is   strictly
0179   //! contained   at the  beginning  of  the field <theword>
0180   //! false otherwise.
0181     Standard_Boolean IsGreaterOrEqual (const Handle(Units_Token)& atoken) const;
0182   
0183   //! Useful for debugging
0184   Standard_EXPORT virtual void Dump (const Standard_Integer ashift, const Standard_Integer alevel) const;
0185 
0186 
0187 
0188   DEFINE_STANDARD_RTTIEXT(Units_Token,Standard_Transient)
0189 
0190 protected:
0191 
0192 
0193 
0194 
0195 private:
0196 
0197 
0198   TCollection_AsciiString theword;
0199   TCollection_AsciiString themean;
0200   Standard_Real thevalue;
0201   Handle(Units_Dimensions) thedimensions;
0202 
0203 
0204 };
0205 
0206 
0207 #include <Units_Token.lxx>
0208 
0209 
0210 
0211 
0212 
0213 #endif // _Units_Token_HeaderFile