Field.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/dataaccess/query/Field.h
22 
23  \brief The Field class can be used to model an expression that takes part of the output items of a SELECT.
24 */
25 
26 #ifndef __TERRALIB_DATAACCESS_INTERNAL_FIELD_H
27 #define __TERRALIB_DATAACCESS_INTERNAL_FIELD_H
28 
29 // TerraLib
30 #include "../Config.h"
31 
32 // STL
33 #include <memory>
34 #include <string>
35 
36 namespace te
37 {
38  namespace da
39  {
40 // Forward declarations
41  class Expression;
42 
43  /*!
44  \class Field
45 
46  \brief The Field class can be used to model an expression that takes part of the output items of a SELECT.
47 
48  \sa Fields
49  */
51  {
52  public:
53 
54  /*!
55  \brief Constructor.
56 
57  \param e The output expression to be used in a Select clause.
58  \param alias An alias to the output expression.
59  */
60  Field(const Expression& e, const std::string& alias = std::string(""));
61 
62  /*!
63  \brief Constructor.
64 
65  \param e The output expression to be used in a Select clause.
66  \param alias An alias to the output expression.
67 
68  \note The Field will take the ownership of Expression and alias.
69  */
70  Field(Expression* e, std::string* alias = 0);
71 
72  /*!
73  \brief Constructor.
74 
75  \param propertyName The property name.
76  \param alias The property alias.
77  */
78  Field(const std::string& propertyName, const std::string& alias = std::string(""));
79 
80  /*! \brief Copy constructor. */
81  Field(const Field& rhs);
82 
83  /*! \brief Destructor. */
84  ~Field();
85 
86  /*! Assignment operator. */
87  Field& operator=(const Field& rhs);
88 
89  /*!
90  \brief It sets the an expression that can be used in a Select query.
91 
92  \param e An expression that can be used in a Select query.
93 
94  \note The Field will take the ownership of the given expression.
95  */
96  void setExpression(Expression* e);
97 
98  /*!
99  \brief It returns the expression set for an output select query.
100 
101  \return The expression set for an output select query.
102  */
103  Expression* getExpression() const;
104 
105  /*!
106  \brief As you know, sometimes is better to give an alias to an output expression.
107 
108  \param alias An aliast fo the output expression.
109 
110  \note The Field object will take the ownership of the alias.
111  */
112  void setAlias(std::string* alias);
113 
114  /*!
115  \brief It returns the alias for the outout expression.
116 
117  \return The alias for the outout expression.
118  */
119  std::string* getAlias() const;
120 
121  private:
122 
123  std::auto_ptr<Expression> m_field; //!< A valid expression.
124  std::auto_ptr<std::string> m_alias; //!< An alias for the output name.
125  };
126 
127  } // end namespace da
128 } // end namespace te
129 
130 #endif // __TERRALIB_DATAACCESS_INTERNAL_FIELD_H
131 
The Field class can be used to model an expression that takes part of the output items of a SELECT...
Definition: Field.h:50
This is an abstract class that models a query expression.
Definition: Expression.h:47
URI C++ Library.
std::auto_ptr< Expression > m_field
A valid expression.
Definition: Field.h:123
std::auto_ptr< std::string > m_alias
An alias for the output name.
Definition: Field.h:124
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97