fcml  1.2.2
fcml_dialect.hpp
Go to the documentation of this file.
1 /*
2  * FCML - Free Code Manipulation Library.
3  * Copyright (C) 2010-2020 Slawomir Wojtasiak
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
27 #ifndef FCML_DIALECT_HPP_
28 #define FCML_DIALECT_HPP_
29 
30 #include "fcml_common.hpp"
31 
32 #include "fcml_dialect.h"
33 
34 namespace fcml {
35 
41 class Dialect: public NonCopyable {
42 protected:
43 
48  Dialect() {
49  _dialect = NULL;
50  }
51 
56  virtual ~Dialect() {
57  if (_dialect) {
58  ::fcml_fn_dialect_free(_dialect);
59  _dialect = NULL;
60  }
61  }
62 
63 protected:
64 
65  friend class DialectAware;
66 
74  return _dialect;
75  }
76 
83  void setDialect(fcml_st_dialect *dialect) {
84  this->_dialect = dialect;
85  }
86 
87 private:
88 
90  fcml_st_dialect *_dialect;
91 
92 };
93 
98 class DialectAware {
99 public:
100 
106  }
107 
112  virtual ~DialectAware() {
113  }
114 
122  fcml_st_dialect* extractDialect(const Dialect &dialect) const {
123  return dialect.getDialect();
124  }
125 };
126 
127 }
128 
129 #endif /* FCML_DIALECT_HPP_ */
void setDialect(fcml_st_dialect *dialect)
Sets a new dialect for the wrapper.
Definition: fcml_dialect.hpp:83
Dialect()
Default constructor.
Definition: fcml_dialect.hpp:48
C++ wrappers common classes.
LIB_EXPORT void LIB_CALL fcml_fn_dialect_free(fcml_st_dialect *dialect)
Frees dialect instance.
virtual ~DialectAware()
Virtual destructor.
Definition: fcml_dialect.hpp:112
fcml_st_dialect * getDialect() const
Gets the wrapped FCML dialect.
Definition: fcml_dialect.hpp:73
struct fcml_st_dialect fcml_st_dialect
Assembler dialect.
Definition: fcml_dialect.h:36
fcml_st_dialect * extractDialect(const Dialect &dialect) const
Extracts the native FCML dialect from the dialect object.
Definition: fcml_dialect.hpp:122
DialectAware()
Default constructor.
Definition: fcml_dialect.hpp:105
Definition: fcml_assembler.hpp:39
virtual ~Dialect()
Virtual destructor.
Definition: fcml_dialect.hpp:56
Inherit from this class in order to get access to the native FCML dialect structure.
Definition: fcml_dialect.hpp:98
An abstract dialect.
Definition: fcml_dialect.hpp:41
Structures and functions related to dialects.
Object which shouldn't be copied can inherit from this class.
Definition: fcml_common.hpp:288