00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 extern "C" {
00020 #include <clips/clips.h>
00021 };
00022
00023 #include <clipsmm/template.h>
00024 #include <clipsmm/environment.h>
00025 #include <clipsmm/utility.h>
00026
00027 namespace DACLIPS {
00028
00029 Template::Template( Environment& environment, void* cobj ) :
00030 EnvironmentObject( environment, cobj ) {}
00031
00032 Template::pointer Template::create( Environment& environment, void* cobj ) {
00033 return Template::pointer( new Template( environment, cobj ) );
00034 }
00035
00036 Template::~Template() {}
00037
00038 std::string Template::name() {
00039 if ( m_cobj )
00040 return EnvGetDeftemplateName( m_environment.cobj(), m_cobj );
00041 else
00042 return std::string();
00043 }
00044
00045 std::string Template::module_name( ) {
00046 if ( m_cobj )
00047 return EnvDeftemplateModule( m_environment.cobj(), m_cobj );
00048 else
00049 return std::string();
00050 }
00051
00052 std::string Template::formatted( ) {
00053 if ( m_cobj )
00054 return EnvGetDeftemplatePPForm( m_environment.cobj(), m_cobj );
00055 else
00056 return std::string();
00057 }
00058
00059 Values Template::slot_allowed_values( const std::string& slot_name ) {
00060 DATA_OBJECT clipsdo;
00061 if ( m_cobj ) {
00062 EnvDeftemplateSlotAllowedValues( m_environment.cobj(),
00063 m_cobj,
00064 const_cast<char*>( slot_name.c_str() ),
00065 &clipsdo );
00066 return data_object_to_values( clipsdo );
00067 } else
00068 return Values();
00069 }
00070
00071 Values Template::slot_cardinality( const std::string & slot_name ) {
00072 DATA_OBJECT clipsdo;
00073 if ( m_cobj ) {
00074 EnvDeftemplateSlotCardinality( m_environment.cobj(),
00075 m_cobj,
00076 const_cast<char*>( slot_name.c_str() ),
00077 &clipsdo );
00078 return data_object_to_values( clipsdo );
00079 } else
00080 return Values();
00081 }
00082
00083 bool Template::slot_exists( const std::string & slot_name ) {
00084 if ( m_cobj )
00085 return EnvDeftemplateSlotExistP( m_environment.cobj(),
00086 m_cobj,
00087 const_cast<char*>( slot_name.c_str() ) );
00088 else
00089 return false;
00090 }
00091
00092 bool Template::is_multifield_slot( const std::string & slot_name ) {
00093 if ( m_cobj )
00094 return EnvDeftemplateSlotMultiP( m_environment.cobj(),
00095 m_cobj,
00096 const_cast<char*>( slot_name.c_str() ) );
00097 else
00098 return false;
00099 }
00100
00101 bool Template::is_single_field_slot( const std::string & slot_name ) {
00102 if ( m_cobj )
00103 return EnvDeftemplateSlotSingleP( m_environment.cobj(),
00104 m_cobj,
00105 const_cast<char*>( slot_name.c_str() ) );
00106 else
00107 return false;
00108 }
00109
00110 std::vector<std::string> Template::slot_names() {
00111 DATA_OBJECT clipsdo;
00112
00113 if ( !m_cobj )
00114 return std::vector<std::string>();
00115
00116 EnvDeftemplateSlotNames( m_environment.cobj(), m_cobj, &clipsdo );
00117 return data_object_to_strings( clipsdo );
00118 }
00119
00120 DefaultType Template::slot_default_type( const std::string & slot_name ) {
00121 if ( !m_cobj )
00122 return NO_DEFAULT;
00123 return ( DefaultType ) EnvDeftemplateSlotDefaultP( m_environment.cobj(), m_cobj, const_cast<char*>( slot_name.c_str() ) );
00124 }
00125
00126 Values Template::slot_default_value( const std::string & slot_name ) {
00127 DATA_OBJECT clipsdo;
00128 if ( !m_cobj )
00129 return Values();
00130 EnvDeftemplateSlotDefaultValue( m_environment.cobj(),
00131 m_cobj,
00132 const_cast<char*>( slot_name.c_str() ),
00133 &clipsdo );
00134 return data_object_to_values( clipsdo );
00135 }
00136
00137 Values Template::slot_range( const std::string & slot_name ) {
00138 DATA_OBJECT clipsdo;
00139 if ( !m_cobj )
00140 return Values();
00141 EnvDeftemplateSlotRange( m_environment.cobj(),
00142 m_cobj,
00143 const_cast<char*>( slot_name.c_str() ),
00144 &clipsdo );
00145 return data_object_to_values( clipsdo );
00146 }
00147
00148 bool Template::is_watched( ) {
00149 if ( !m_cobj )
00150 return false;
00151 return EnvGetDeftemplateWatch( m_environment.cobj(), m_cobj );
00152 }
00153
00154 Template::pointer Template::next( ) {
00155 void * nxt;
00156 if ( !m_cobj )
00157 return Template::pointer();
00158 nxt = EnvGetNextDeftemplate( m_environment.cobj(), m_cobj );
00159 if ( nxt )
00160 return Template::create( m_environment, nxt );
00161 else
00162 return Template::pointer();
00163 }
00164
00165 bool Template::is_deletable( ) {
00166 if ( !m_cobj )
00167 return false;
00168 return EnvIsDeftemplateDeletable( m_environment.cobj(), m_cobj );
00169 }
00170
00171 void Template::set_watch( unsigned state ) {
00172 if ( m_cobj )
00173 EnvSetDeftemplateWatch( m_environment.cobj(), state, m_cobj );
00174 }
00175
00176 bool Template::retract( ) {
00177 if ( !m_cobj )
00178 return false;
00179 return EnvUndeftemplate( m_environment.cobj(), m_cobj );
00180 }
00181
00182 }
00183