📄 portion.h
字号:
//// $Source: /home/gambit/CVS/gambit/sources/gcl/portion.h,v $// $Date: 2002/08/27 18:57:19 $// $Revision: 1.7 $//// DESCRIPTION:// Declaration of GCL types//// This file is part of Gambit// Copyright (c) 2002, The Gambit Project//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//#ifndef PORTION_H#define PORTION_H#include "base/base.h"#include "math/gnumber.h"#include "game/efg.h"#include "gsmincl.h"//-------------// Portion//-------------class Nfg;class Portion{private: static int _NumObj; Portion* _Original; void* _Game; bool _GameIsEfg;protected: Portion(void); static gNumber _WriteWidth; static gNumber _WritePrecis; static gTriState _WriteExpmode; static gTriState _WriteQuoted; static gTriState _WriteListBraces; static gTriState _WriteListCommas; static gNumber _WriteListLF; static gNumber _WriteListIndent; static gTriState _WriteSolutionInfo; static gTriState _WriteSolutionLabels; void SetGame(const efgGame *game); void SetGame(const Nfg *game);public: static void _SetWriteWidth(long); static void _SetWritePrecis(long); static void _SetWriteExpmode(bool); static void _SetWriteQuoted(bool); static void _SetWriteListBraces(bool); static void _SetWriteListCommas(bool); static void _SetWriteListLF(long); static void _SetWriteListIndent(long); static void _SetWriteSolutionInfo(bool); static void _SetWriteSolutionLabels(bool); virtual ~Portion(); void SetOriginal(const Portion* p); Portion* Original(void) const; virtual PortionSpec Spec(void) const = 0; virtual void Output(gOutput& s) const; virtual gText OutputString(void) const = 0; virtual Portion* ValCopy(void) const = 0; virtual Portion* RefCopy(void) const = 0; virtual bool IsReference(void) const = 0; void* Game(void) const; bool GameIsEfg(void) const;};//---------// Null//---------class NullPortion : public Portion {protected: unsigned long _DataType; static gPool pool;public: NullPortion(const unsigned long datatype); virtual ~NullPortion(); PortionSpec Spec(void) const; unsigned long DataType(void) const; void Output(gOutput& s) const; gText OutputString(void) const; Portion* ValCopy(void) const; Portion* RefCopy(void) const; bool IsReference(void) const; void *operator new(size_t) { return pool.Alloc(); } void operator delete(void *p) { pool.Free(p); } };//------------// Reference//------------class ReferencePortion : public Portion {protected: gText _Value; static gPool pool;public: ReferencePortion(const gText& value); virtual ~ReferencePortion(); gText Value(void); PortionSpec Spec(void) const; void Output(gOutput& s) const; gText OutputString(void) const; Portion* ValCopy(void) const; Portion* RefCopy(void) const; bool IsReference(void) const; void *operator new(size_t) { return pool.Alloc(); } void operator delete(void *p) { pool.Free(p); }};//-------------// Precision//-------------class PrecisionPortion : public Portion {protected: gPrecision* _Value; bool _ref; static gPool pool; PrecisionPortion(gPrecision &, bool);public: PrecisionPortion(gPrecision); virtual ~PrecisionPortion(); gPrecision Value(void) const; void SetValue(gPrecision); PortionSpec Spec(void) const; void Output(gOutput& s) const; gText OutputString(void) const; Portion* ValCopy(void) const; Portion* RefCopy(void) const; bool IsReference(void) const; void *operator new(size_t) { return pool.Alloc(); } void operator delete(void *p) { pool.Free(p); }};inline gPrecision AsPrecision(Portion *portion) { return ((PrecisionPortion *) portion)->Value(); }//----------// Number//----------class NumberPortion : public Portion {protected: gNumber* _Value; bool _ref; static gPool pool; NumberPortion(gNumber &, bool);public: NumberPortion(const gNumber &); virtual ~NumberPortion(); const gNumber &Value(void) const; void SetValue(const gNumber &); PortionSpec Spec(void) const; void Output(gOutput& s) const; gText OutputString(void) const; Portion* ValCopy(void) const; Portion* RefCopy(void) const; bool IsReference(void) const; void *operator new(size_t) { return pool.Alloc(); } void operator delete(void *p) { pool.Free(p); }};inline const gNumber &AsNumber(Portion *portion){ return ((NumberPortion *) portion)->Value(); }//--------// Text//--------class TextPortion : public Portion {protected: gText* _Value; bool _ref; static gPool pool; TextPortion(gText &, bool);public: TextPortion(const gText &); virtual ~TextPortion(); const gText &Value(void) const; void SetValue(const gText &); PortionSpec Spec(void) const; void Output(gOutput& s) const; gText OutputString(void) const; Portion* ValCopy(void) const; Portion* RefCopy(void) const; bool IsReference(void) const; void *operator new(size_t) { return pool.Alloc(); } void operator delete(void *p) { pool.Free(p); }};//--------// Bool//--------class BoolPortion : public Portion {protected: gTriState *_Value; bool _ref; static gPool pool; BoolPortion(gTriState &, bool);public: BoolPortion(bool); BoolPortion(gTriState); virtual ~BoolPortion(); gTriState Value(void) const; void SetValue(gTriState); PortionSpec Spec(void) const; void Output(gOutput& s) const; gText OutputString(void) const; Portion* ValCopy(void) const; Portion* RefCopy(void) const; bool IsReference(void) const; void *operator new(size_t) { return pool.Alloc(); } void operator delete(void *p) { pool.Free(p); } };inline bool AsBool(Portion *portion){ return ((BoolPortion *) portion)->Value(); }//-------------// EFOutcome//-------------class efgOutcome;class EfOutcomePortion : public Portion {protected: efgOutcome **m_value; bool m_ref; static gPool pool; EfOutcomePortion(efgOutcome *&, bool);public: EfOutcomePortion(efgOutcome *); virtual ~EfOutcomePortion(); efgOutcome *Value(void) const; void SetValue(efgOutcome *); PortionSpec Spec(void) const; void Output(gOutput& s) const; gText OutputString(void) const; Portion* ValCopy(void) const; Portion* RefCopy(void) const; bool IsReference(void) const; void *operator new(size_t) { return pool.Alloc(); } void operator delete(void *p) { pool.Free(p); }};//------------// NfPlayer//------------class NFPlayer;class NfPlayerPortion : public Portion {protected: NFPlayer** _Value; bool _ref; static gPool pool; NfPlayerPortion(NFPlayer *&, bool);public: NfPlayerPortion(NFPlayer *); virtual ~NfPlayerPortion(); NFPlayer *Value(void) const; void SetValue(NFPlayer *); PortionSpec Spec(void) const; void Output(gOutput& s) const; gText OutputString(void) const; Portion* ValCopy(void) const; Portion* RefCopy(void) const; bool IsReference(void) const; void *operator new(size_t) { return pool.Alloc(); } void operator delete(void *p) { pool.Free(p); }};//-----------// Strategy//-----------class Strategy;class StrategyPortion : public Portion {protected: Strategy** _Value; bool _ref; static gPool pool; StrategyPortion(Strategy *&, bool);public: StrategyPortion(Strategy *); virtual ~StrategyPortion(); Strategy *Value(void) const; void SetValue(Strategy *); PortionSpec Spec(void) const; void Output(gOutput& s) const; gText OutputString(void) const; Portion* ValCopy(void) const; Portion* RefCopy(void) const; bool IsReference(void) const; void *operator new(size_t) { return pool.Alloc(); } void operator delete(void *p) { pool.Free(p); }};//------------// NfOutcome//------------class NFOutcome;class NfOutcomePortion : public Portion {protected: NFOutcome** _Value; bool _ref; static gPool pool; NfOutcomePortion(NFOutcome *&, bool);public: NfOutcomePortion(NFOutcome *); virtual ~NfOutcomePortion(); NFOutcome *Value(void) const; void SetValue(NFOutcome *); PortionSpec Spec(void) const; void Output(gOutput& s) const; gText OutputString(void) const; Portion* ValCopy(void) const; Portion* RefCopy(void) const; bool IsReference(void) const; void *operator new(size_t) { return pool.Alloc(); } void operator delete(void *p) { pool.Free(p); }};//-------------// NfSupport//-------------class NFSupport;class NfSupportPortion : public Portion {protected: struct rep { NFSupport *value; int nref; rep(NFSupport *v) : value(v), nref(1) { } ~rep(); }; struct rep *m_rep; bool m_ref; static gPool pool; NfSupportPortion(const NfSupportPortion *, bool);public: NfSupportPortion(NFSupport *); NfSupportPortion(NFSupport &); virtual ~NfSupportPortion(); NFSupport *Value(void) const; void SetValue(NFSupport *); PortionSpec Spec(void) const; void Output(gOutput& s) const; gText OutputString(void) const; Portion* ValCopy(void) const; Portion* RefCopy(void) const; bool IsReference(void) const; void *operator new(size_t) { return pool.Alloc(); } void operator delete(void *p) { pool.Free(p); }};inline const NFSupport &AsNfgSupport(Portion *portion){ return *((NfSupportPortion *) portion)->Value(); }//-------------// EfSupport//-------------class EFSupport;class EfSupportPortion : public Portion {protected: struct rep { EFSupport *value; int nref; rep(EFSupport *v) : value(v), nref(1) { } ~rep(); }; struct rep *m_rep; bool m_ref; static gPool pool; EfSupportPortion(const EfSupportPortion *, bool);public: EfSupportPortion(EFSupport *); EfSupportPortion(EFSupport &); virtual ~EfSupportPortion(); EFSupport *Value(void) const; void SetValue(EFSupport *); PortionSpec Spec(void) const; void Output(gOutput& s) const; gText OutputString(void) const; Portion* ValCopy(void) const; Portion* RefCopy(void) const; bool IsReference(void) const; void *operator new(size_t) { return pool.Alloc(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -