00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <clipsmm/activation.h>
00020
00021 extern "C" {
00022 #include <clips/clips.h>
00023 };
00024
00025 #include <clipsmm/environment.h>
00026
00027 #include <limits.h>
00028
00029 namespace DACLIPS {
00030
00031 Activation::Activation( Environment& environment, void* cobj ) :
00032 EnvironmentObject( environment, cobj ) {}
00033
00034 Activation::pointer Activation::create( Environment & environment, void * cobj ) {
00035 return Activation::pointer( new Activation( environment, cobj ) );
00036 }
00037
00038
00039 Activation::~Activation() {}
00040
00041 std::string Activation::name( )
00042 {
00043 if ( m_cobj )
00044 return EnvGetActivationName( m_environment.cobj(), m_cobj );
00045 else
00046 return std::string();
00047 }
00048
00049 std::string Activation::formatted( )
00050 {
00051 char temp[2001];
00052 if ( m_cobj ) {
00053 EnvGetActivationPPForm( m_environment.cobj(), temp, 2000, m_cobj );
00054 return temp;
00055 }
00056 else
00057 return std::string();
00058 }
00059
00060 bool Activation::deactivate( )
00061 {
00062 if ( m_cobj )
00063 return EnvDeleteActivation( m_environment.cobj(), m_cobj );
00064 else
00065 return false;
00066 }
00067
00068 int Activation::salience( )
00069 {
00070 if ( m_cobj )
00071 return EnvGetActivationSalience( m_environment.cobj(), m_cobj );
00072 else
00073 return INT_MIN;
00074 }
00075
00076 int Activation::set_salience( int sal )
00077 {
00078 if ( m_cobj )
00079 return EnvSetActivationSalience( m_environment.cobj(), m_cobj, sal );
00080 else
00081 return INT_MIN;
00082 }
00083
00084 Activation::pointer Activation::next( )
00085 {
00086 void* nxt = NULL;
00087 if ( m_cobj ) {
00088 nxt = EnvGetNextActivation( m_environment.cobj(), m_cobj );
00089 if ( nxt )
00090 return Activation::create( m_environment, nxt );
00091 }
00092
00093 return Activation::pointer();
00094 }
00095
00096 }
00097