tilde~
Puredata Qt-based GUI
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ceammc_atom.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2016 Serge Poltavski. All rights reserved.
3  *
4  * This file may be distributed under the terms of GNU Public License version
5  * 3 (GPL v3) as defined by the Free Software Foundation (FSF). A copy of the
6  * license should have been included with this file, or the project in which
7  * this file belongs to. You may also find the details of GPL v3 at:
8  * http://www.gnu.org/licenses/gpl-3.0.txt
9  *
10  * If you have any questions regarding the use of this file, feel free to
11  * contact the author of this file, or the owner of the project in which
12  * this file belongs to.
13  *****************************************************************************/
14 #ifndef CEAMMC_ATOM_H
15 #define CEAMMC_ATOM_H
16 
17 #include <iostream>
18 #include <m_pd.h>
19 #include <string>
20 
21 namespace ceammc {
22 
23 class Atom : t_atom {
24 public:
28  enum Type {
33  };
34 
35  static const char PROP_PREFIX = '@';
36 
37 public:
38  Atom();
39  Atom(const t_atom& a);
40  Atom(t_float v);
41  Atom(t_symbol* s);
42 
46  bool isFloat() const;
47 
51  bool isNone() const;
52 
56  bool isSymbol() const;
57 
61  bool isProperty() const;
62 
66  bool isInteger() const;
67 
71  bool isNatural() const;
72 
76  Type type() const;
77 
84  bool getFloat(t_float* v) const;
85  bool getSymbol(t_symbol** s) const;
86  bool getString(std::string& str) const;
87 
88  bool setFloat(t_float v, bool force = false);
89  bool setSymbol(t_symbol* s, bool force = false);
90 
91  t_float asFloat(float def = 0.f) const;
92  int asInt(int def = 0) const;
93  size_t asSizeT(size_t def = 0) const;
94  t_symbol* asSymbol() const;
95  std::string asString() const;
96  //
97  // added range check and clipping
98  t_float asFloatInRange(float min, float max) const;
99 
100  bool operator<(const Atom& a) const;
101 
106  void output(t_outlet* x) const;
107 
108  void outputAsAny(t_outlet* x, t_symbol* sel) const;
109 
113  Atom& operator+=(double v);
114  Atom& operator-=(double v);
115  Atom& operator*=(double v);
116  Atom& operator/=(double v);
117 
118  Atom operator+(double v) const;
119  Atom operator-(double v) const;
120  Atom operator*(double v) const;
121  Atom operator/(double v) const;
122 
123 public:
124  friend bool operator==(const Atom& a1, const Atom& a2);
125  friend bool operator!=(const Atom& a1, const Atom& a2);
126 };
127 
128 bool operator==(const Atom& a1, const Atom& a2);
129 bool operator!=(const Atom& a1, const Atom& a2);
130 std::ostream& operator<<(std::ostream& os, const Atom& a);
131 
132 bool to_outlet(t_outlet* x, const Atom& a);
133 
134 static inline bool isFloat(const Atom& a) { return a.isFloat(); }
135 static inline bool isSymbol(const Atom& a) { return a.isSymbol(); }
136 static inline bool isProperty(const Atom& a) { return a.isProperty(); }
137 static inline bool notFloat(const Atom& a) { return !a.isFloat(); }
138 static inline bool notSymbol(const Atom& a) { return !a.isSymbol(); }
139 static inline bool notProperty(const Atom& a) { return !a.isProperty(); }
140 }
141 
142 #endif // CEAMMC_ATOM_H
Atom operator*(double v) const
Definition: ceammc_atom.h:32
Atom operator-(double v) const
bool isFloat() const
friend bool operator!=(const Atom &a1, const Atom &a2)
size_t asSizeT(size_t def=0) const
Atom & operator*=(double v)
Definition: ceammc_atom.h:23
bool operator!=(const Atom &a1, const Atom &a2)
int asInt(int def=0) const
bool setFloat(t_float v, bool force=false)
Definition: m_pd.h:179
bool isNatural() const
Type
logical atom type
Definition: ceammc_atom.h:28
bool getSymbol(t_symbol **s) const
bool isSymbol() const
Atom & operator+=(double v)
bool isNone() const
bool getString(std::string &str) const
Definition: ceammc_atom.h:31
void output(t_outlet *x) const
outputs atom to given outlet
Definition: ceammc_atom.h:29
bool isInteger() const
t_symbol * asSymbol() const
Atom & operator/=(double v)
Atom operator/(double v) const
bool isProperty() const
t_float asFloat(float def=0.f) const
PD_FLOATTYPE t_float
Definition: m_pd.h:107
bool operator<(const Atom &a) const
Type type() const
#define t_outlet
Definition: m_pd.h:189
Definition: m_pd.h:110
bool to_outlet(t_outlet *x, const Atom &a)
Atom operator+(double v) const
bool operator==(const Atom &a1, const Atom &a2)
std::ostream & operator<<(std::ostream &os, const Atom &a)
Atom & operator-=(double v)
static const char PROP_PREFIX
Definition: ceammc_atom.h:35
friend bool operator==(const Atom &a1, const Atom &a2)
void outputAsAny(t_outlet *x, t_symbol *sel) const
bool setSymbol(t_symbol *s, bool force=false)
t_float asFloatInRange(float min, float max) const
bool getFloat(t_float *v) const
std::string asString() const
Definition: ceammc_atom.h:30