1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 * Author : Ivan DUTKA-MALEN - EDF R&D
26 * Date : September 2003
33 #include "Batch_Defines.hxx"
38 #include "Batch_GenericType.hxx"
39 #include "Batch_BoolType.hxx"
40 #include "Batch_CharType.hxx"
41 #include "Batch_LongType.hxx"
42 #include "Batch_StringType.hxx"
43 #include "Batch_CoupleType.hxx"
44 #include "Batch_TypeMismatchException.hxx"
45 #include "Batch_ListIsFullException.hxx"
46 #include "Batch_RunTimeException.hxx"
51 enum DiscriminatorType { BOOL, LONG, STRING, COUPLE };
53 class BATCH_EXPORT Versatile : public std::list< GenericType * >
58 Versatile(DiscriminatorType discriminator, size_type maxsize, std::string name);
59 Versatile(const Versatile & V);
61 // Use of default constructor is forbidden but we cannot declare it private because
62 // compilation fails with VC8 on Windows
63 Versatile() { throw RunTimeException("Forbidden constructor"); }
68 // Affectation and concatenation operators from base types
69 Versatile & operator = (const long l) throw(TypeMismatchException);
70 Versatile & operator = (const std::string & ch) throw(TypeMismatchException);
71 Versatile & operator +=(const std::string & ch) throw(TypeMismatchException,ListIsFullException);
72 Versatile & operator , (const std::string & ch) throw(TypeMismatchException,ListIsFullException);
73 Versatile & operator = (const char * ch) throw(TypeMismatchException);
74 Versatile & operator +=(const char * ch) throw(TypeMismatchException,ListIsFullException);
75 Versatile & operator , (const char * ch) throw(TypeMismatchException,ListIsFullException);
76 Versatile & operator = (const Couple & cp) throw(TypeMismatchException);
77 Versatile & operator +=(const Couple & cp) throw(TypeMismatchException,ListIsFullException);
78 Versatile & operator , (const Couple & cp) throw(TypeMismatchException,ListIsFullException);
79 Versatile & operator = (const int i) throw(TypeMismatchException);
80 Versatile & operator = (const bool b) throw(TypeMismatchException);
82 // Type conversion to base types
83 operator long() const throw(TypeMismatchException);
84 operator std::string() const throw(TypeMismatchException);
85 operator Couple() const throw(TypeMismatchException);
86 std::string str() const throw(TypeMismatchException);
87 operator bool() const throw(TypeMismatchException);
88 operator int() const throw(TypeMismatchException);
90 // Display on a stream
91 BATCH_EXPORT friend std::ostream & operator << (std::ostream & os, const Versatile & );
94 void checkType(DiscriminatorType t) const throw (TypeMismatchException);
97 DiscriminatorType getType() const;
98 size_type getMaxSize() const;
99 const std::string & getName() const;
101 // Erase all internal elements
106 DiscriminatorType _discriminator; // Internal element type
107 size_type _maxsize; // Maximum number of internal elements
108 std::string _name; // Object name (used for exceptions)
112 // Forbid the use of affectation operator
113 void operator= (const Versatile & V) {}