This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/CXX/yapa.hh

99 lines
3.2 KiB
C++
Raw Normal View History

2015-02-09 01:52:10 +00:00
#ifndef YAPA_HH
#define YAPA_HH 1
/**
Prolog operates over constants, called atoms
YAP, like lisp, associates properties with atoms.
*/
enum PropTag {
/// predicate
PRED_TAG = PEProp, // 0x0000,
/// db key, may be associated with a functor
DB_TAG = DBProperty, // 0x8000,
/// generic functor, may include sub-properties
FUNCTOR_TAG = FunctorProperty, // 0xBB00,
// SPARSE_FUNCTOR_TAG = 0xFFDF,
/// arithmetic function
2015-02-10 09:14:55 +00:00
ARITHMETIC_PROPERTY_TAG = ExpProperty, // 0xFFE0,
2015-02-09 01:52:10 +00:00
/// map the atom to an integer
TRANSLATION_TAG = TranslationProperty, // 0xFFF4,
2015-02-10 09:14:55 +00:00
/// ensure the atom may not be garbafe colected
HOLD_TAG = HoldProperty, // 0xFFF6
/// named mutEX
2015-02-09 01:52:10 +00:00
MUTEX_TAG = MutexProperty, // 0xFFF6,
/// A typed array, may be in-db or in-stack deped
ARRAY_TAG = ArrayProperty, // 0xFFF7,
/// module
MODULE_TAG = ModProperty, // 0xFFFA,
/// the original SICStus blackboard
BLACKBOARD_TAG = BBProperty, // 0xFFFB,
2015-02-10 09:14:55 +00:00
/// associate an atomic value with the atom
2015-02-09 01:52:10 +00:00
VALUE_TAG = ValProperty, // 0xFFFC,
/// Demoen's proposal for gkobal variables
GLOBAL_VAR_TAG = GlobalProperty, // 0xFFFD
2015-02-10 09:14:55 +00:00
/// SWI-STYLE ATOM Extension
BLOB_TAG = BlobProperty, // 0xFFFE,
2015-02-09 01:52:10 +00:00
/// Prolog operator,
OPERATOR_TAG = OpProperty, // 0xFFFF,
};
/**
* @brief Atom
* A YAP data-base is a collection of atoms, where each atom has a name
* and a set of Properties. Examples of properties include functors,
* predicates, operators, modules, almost everything.
*
*/
class YAPAtom {
2016-07-31 16:22:24 +01:00
friend class YAPEngine;
2015-02-09 01:52:10 +00:00
friend class YAPModuleProp;
friend class YAPPredicate;
friend class YAPFunctor;
friend class YAPAtomTerm;
friend class YAProp;
friend class YAPModule;
2016-07-31 16:22:24 +01:00
friend class YAPQuery;
2015-02-09 01:52:10 +00:00
Atom a;
/// construct new YAPAtom from Atom
YAPAtom( Atom at ) { a = at; }
public:
2016-11-08 07:37:36 +00:00
/// construct new YAPAtom from UTF-8 string
YAPAtom( const char * s) { a = Yap_LookupAtom( s ); }
/// construct new YAPAtom from UTF-8 string
YAPAtom( const wchar_t * s) { CACHE_REGS a = UTF32ToAtom( s PASS_REGS ); }
2015-02-09 01:52:10 +00:00
/// construct new YAPAtom from wide string
//YAPAtom( const wchar_t * s) { a = Yap_LookupMaybeWideAtom( s ); }
2015-02-09 01:52:10 +00:00
/// construct new YAPAtom from max-length string
YAPAtom( const char * s, size_t len) { a = Yap_LookupAtomWithLength( s, len ); }
/// get name of atom
2016-07-31 16:22:24 +01:00
const char *getName(void);
/// get name of (other way)
inline const char *text(void) { return getName(); } ;
/// get prop of type
2015-02-09 01:52:10 +00:00
Prop getProp( PropTag tag ) { return Yap_GetAProp( a , (PropFlags)tag ); }
};
/**
* @brief Prop
* A YAP Propery is ameta-class for everything one can in a atom.
* Examples of properties include functors,
* predicates, operators, modules, almost everything.
*
*/
class YAPProp {
friend class YAPModuleProp;
friend class YAPFunctor;
/// does nothing, p is defined by the subclass
YAPProp() { }
/// get type of prop
PropTag tag( Prop p ) { return (PropTag)(p->KindOfPE); }
public:
/// get name of property
virtual YAPAtom name() = 0;
virtual ~YAPProp() {};
};
#endif /* YAPA_HH */