Mercurial > hg > what-is-octave
comparison FEMTEC2013/examples/myobject.h @ 6:60233b0075a9
femtec presentation
author | Carlo de Falco <cdf@users.sourceforge.net> |
---|---|
date | Sun, 23 Jun 2013 23:37:41 +0200 |
parents | PoliMI2012/examples/myobject.h@0a1567794b40 |
children |
comparison
equal
deleted
inserted
replaced
5:f8c352d9af2d | 6:60233b0075a9 |
---|---|
1 // Copyright (C) 2012 Carlo de Falco <carlo.defalco@gmail.com> | |
2 // | |
3 // This program is free software; you can redistribute it and/or modify it under | |
4 // the terms of the GNU General Public License as published by the Free Software | |
5 // Foundation; either version 3 of the License, or (at your option) any later | |
6 // version. | |
7 // | |
8 // This program is distributed in the hope that it will be useful, but WITHOUT | |
9 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
11 // details. | |
12 // | |
13 // You should have received a copy of the GNU General Public License along with | |
14 // this program; if not, see <http://www.gnu.org/licenses/>. | |
15 | |
16 #include <octave/oct.h> | |
17 | |
18 class myobject : public octave_base_value | |
19 { | |
20 | |
21 public: | |
22 | |
23 // Constructor | |
24 myobject (const std::string _str = "", const int _intgr = 0, const double _dbl = 0.0) | |
25 : octave_base_value (), str (_str), intgr (_intgr), dbl (_dbl) { p_str = &str; } | |
26 | |
27 void print (std::ostream& os, bool pr_as_read_syntax = false) const | |
28 { os << "str : " << str << std::endl | |
29 << "intgr : " << intgr << std::endl | |
30 << "dbl : " << dbl << std::endl; } | |
31 | |
32 ~myobject(void) { }; | |
33 | |
34 bool is_defined (void) const { return true; } | |
35 | |
36 const std::string & get_str (void) const; | |
37 const int & get_intgr (void) const; | |
38 const double & get_dbl (void) const; | |
39 | |
40 std::string * p_str; | |
41 | |
42 void set_str (std::string & str); | |
43 void set_intgr (int & intgr); | |
44 void set_dbl (double & dbl); | |
45 | |
46 private: | |
47 | |
48 std::string str; | |
49 int intgr; | |
50 double dbl; | |
51 DECLARE_OCTAVE_ALLOCATOR; | |
52 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA; | |
53 | |
54 }; | |
55 | |
56 DEFINE_OCTAVE_ALLOCATOR (myobject); | |
57 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (myobject, "myobject", "myobject"); | |
58 | |
59 static bool myobject_type_loaded = false; |