File indexing completed on 2025-04-19 09:10:06
0001 #ifndef METOOLS_Explicit_C_Object_H
0002 #define METOOLS_Explicit_C_Object_H
0003
0004 #include "ATOOLS/Math/MyComplex.H"
0005 #include <iostream>
0006 #include <vector>
0007
0008 namespace METOOLS {
0009
0010
0011
0012
0013
0014
0015
0016 class CObject {
0017 protected:
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 int m_c[2], m_h, m_s;
0031
0032 public:
0033
0034
0035 inline CObject() {}
0036
0037
0038 virtual ~CObject();
0039
0040
0041 virtual CObject* Copy() const = 0;
0042
0043 virtual void Delete() = 0;
0044
0045 virtual void Add(const CObject *c) = 0;
0046 virtual void Divide(const double &d) = 0;
0047 virtual void Multiply(const Complex &c) = 0;
0048 virtual void Invert() = 0;
0049
0050 virtual bool IsZero() const = 0;
0051
0052
0053
0054
0055
0056
0057 inline int &operator()(const int i) { return m_c[i]; }
0058
0059
0060
0061
0062 inline int operator()(const int i) const { return m_c[i]; }
0063
0064 inline void SetH(const int &h) { m_h=h; }
0065 inline void SetS(const int &s) { m_s=s; }
0066
0067 inline const int &H() const { return m_h; }
0068 inline const int &S() const { return m_s; }
0069
0070
0071
0072
0073
0074 inline bool operator==(const CObject &o) const
0075 { return m_c[0]==o.m_c[0] && m_c[1]==o.m_c[1] && m_s==o.m_s; }
0076
0077
0078
0079
0080
0081 template <typename CType> inline CType *Get()
0082 { return static_cast<CType*>((void*)this); }
0083
0084 };
0085
0086 struct CObject_Vector: public std::vector<CObject*> {
0087
0088 CObject_Vector(const size_t &n=0): std::vector<CObject*>(n) {}
0089
0090 template <typename CType> inline std::vector<CType*> *Get()
0091 { return static_cast<std::vector<CType*>*>((void*)this); }
0092 template <typename CType> inline const std::vector<CType*> *Get() const
0093 { return static_cast<const std::vector<CType*>*>((void*)this); }
0094
0095 };
0096
0097 struct CObject_Matrix: public std::vector<CObject_Vector> {
0098
0099 template <typename CType> inline std::vector<std::vector<CType*> > *Get()
0100 { return static_cast<std::vector<std::vector<CType*> >*>((void*)this); }
0101 template <typename CType> inline const std::vector<std::vector<CType*> > *Get() const
0102 { return static_cast<const std::vector<std::vector<CType*> >*>((void*)this); }
0103
0104 };
0105
0106 std::ostream &operator<<(std::ostream &str,const CObject &s);
0107
0108 }
0109
0110 #endif