Tag Class Reference

The abstract AIML XML Tag class that all other AIML XML tags should inherit from. More...

#include <Tag.h>

Inheritance diagram for Tag:

AIML InnerAIML InnerTopic Topic Category InnerCategory InnerTemplate Pattern PatternSideThat Template Bot Condition Date Get Id InnerTemplateListImpl Input PlainWord Random Size Star TemplateSideThat ThatStar TopicStar Version List of all members.

Public Member Functions

virtual void addCharacters (const StringPimpl &characters) throw (InternalProgrammerErrorException &)
 Characters inbetween AIML XML begin tags and end tags are added through this method.
virtual void handleInnerTag (const shared_ptr< Tag > &tag) throw (InternalProgrammerErrorException &)
 Whenever a AIML XML end tag is reached, it will be sent as an argument to its parent or outermost AIML XML tag.
bool instanceOf (const char *const instance) throw (InternalProgrammerErrorException &)
 Determines if the AIML XML tag object inherits from another AIML XML tag class somewhere in the hierarchy.
virtual void setAttribute (const StringPimpl &name, const StringPimpl &value) throw (InternalProgrammerErrorException &)
 Attributes of the AIML XML tags will be sent through this method.
 Tag () throw (InternalProgrammerErrorException &)
 Default constructor to initalize the private implementation (m_pimpl) data.
virtual ~Tag ()
 Default virtual destructor.

Protected Member Functions

void addInstanceOf (const char *const instance) throw (InternalProgrammerErrorException &)
 Whenever a AIML XML tag inherits from any AIML XML tag it should absolutely use this method in its constructor to add its class name.

Private Member Functions

Tagoperator= (const Tag &tag)
 The assignment operator.
 Tag (const Tag &tag)
 The copy constructor.

Private Attributes

shared_ptr< TagImpl > m_pimpl
 The private implementation in which you cannot get access to.

Detailed Description

The abstract AIML XML Tag class that all other AIML XML tags should inherit from.

This class contains the methods in which every AIML XML could have. It also cotains utility methods in which every XML AIML tag could use.


Constructor & Destructor Documentation

Tag  )  throw (InternalProgrammerErrorException &)
 

Default constructor to initalize the private implementation (m_pimpl) data.

Exceptions:
InternalProgrammerErrorException is thrown only if the error is so grave that the entire AIML engine has to be shut down.

virtual ~Tag  )  [virtual]
 

Default virtual destructor.

Destroys the private implementation (m_pimpl) data.

Tag const Tag tag  )  [private]
 

The copy constructor.

For now, I am not allowing this to be invoked. The tags shouldn't be allowed to be copied amongst themselves.

Parameters:
tag The standard second reference


Member Function Documentation

virtual void addCharacters const StringPimpl characters  )  throw (InternalProgrammerErrorException &) [virtual]
 

Characters inbetween AIML XML begin tags and end tags are added through this method.

Whenver a xml tag has characters inbetween them such as <srai>blah</srai> the words such as blah will be sent to this method. There's no guarantee that all the characters inbetween the tags will be sent all at once. It could be the case that one word at a time will be sent, or two at a time, or all at a time. But they will be sent in correct order from left to right.

Not all AIML XML tags have character data inbetwen the begin and end tags. Those classes will not implement this method. When not implemented this method is a no-operations method. It does nothing when not implemented.

Parameters:
characters One or more characters that are inbetween the AIML XML tag.
Exceptions:
InternalProgrammerErrorException is thrown only if the error is so grave that the entire AIML engine has to be shut down.

Reimplemented in Condition, Gender, InnerTemplateListImpl, Pattern, PatternSideThat, Person, Person2, and Template.

void addInstanceOf const char *const   instance  )  throw (InternalProgrammerErrorException &) [protected]
 

Whenever a AIML XML tag inherits from any AIML XML tag it should absolutely use this method in its constructor to add its class name.

For example since Srai inherits from another AIML XML tag it inherits this method. It calls this method in its constructor to add its name as in addInstanceOf("Srai").

The method Tag::instanceOf will not operate correctly if you do not call this method within your constructors of AIML Tags.

Parameters:
instance The name of your class
Exceptions:
InternalProgrammerErrorException is thrown only if the error is so grave that the entire AIML engine has to be shut down.

virtual void handleInnerTag const shared_ptr< Tag > &  tag  )  throw (InternalProgrammerErrorException &) [virtual]
 

Whenever a AIML XML end tag is reached, it will be sent as an argument to its parent or outermost AIML XML tag.

As an example look at this InnerTemplate, <think><srai>blah</srai></think>. When the Srai end tag is reached, </srai>, the entire Srai tag object will be sent as an argument to handlerInnerTag on the Think object.

This gives the outermost tag/parent tag an opportunity to handle each inner tag/child tag. Not all AIML XML tags need to handle inner AIML XML tags. When not implemented this method is a no-operations method. It does nothing when not implemented.

Parameters:
tag The AIML XML tag that is nested inside of this AIML XML tag.
Exceptions:
InternalProgrammerErrorException is thrown only if the error is so grave that the entire AIML engine has to be shut down.

Reimplemented in AIML, Category, InnerTemplate, Template, and Topic.

bool instanceOf const char *const   instance  )  throw (InternalProgrammerErrorException &)
 

Determines if the AIML XML tag object inherits from another AIML XML tag class somewhere in the hierarchy.

Use this in conjuction with static_cast<> to downcast AIML XML tags safetly as well as to determine if the AIML XML tag is an instance of another AIML XML tag. This only works if the object registered its self with Tag::addInstanceOf. All AIML XML tags in the framework should use Tag::addInstanceOf to guarantee this.

Sometimes you get an AIML XML tag object in an argument in a method such as Tag::handleInnerTag in which you need to downcast it. Instead of blindly downcasting to what the AIML XML tag you think you should have recieved you can use this method first to determine if it is indeed an instance of that AIML XML tag. If it is, then you can safetly downcast it using static_cast<>.

I use this method in conjunction with static_cast as a replacement for dynamic_cast<>. dynamic_cast<> is not guaranteed to work across dll boundaries and thus it cannot be used with custom framework dll's. You SHOULD NEVER USE dynamic_cast<> with RebeccaAIML since it is a dll. You should always use this method in conjunction with static_cast<> for all your downcasting needs.

Parameters:
instance Name of the AIML XML tag class that this AIML XML tag object might have inherited from.
Returns:
Returns true if this object is an instance of the AIML XML tag and false if it is not.
Exceptions:
InternalProgrammerErrorException is thrown only if the error is so grave that the entire AIML engine has to be shut down.

Tag& operator= const Tag tag  )  [private]
 

The assignment operator.

For now, I am not allowing a copy to be made. The tags shouldn't be copied amongst themselves.

Parameters:
tag The standard second reference.

virtual void setAttribute const StringPimpl name,
const StringPimpl value
throw (InternalProgrammerErrorException &) [virtual]
 

Attributes of the AIML XML tags will be sent through this method.

As an example, <get name="blah"> will set name to "name" and value to "blah". Not all AIML XML tags have attributes. When not implemented this method is a no-operations method. It does nothing when not implemented.

Parameters:
name The name of the AIML XML attribute
value The value of the AIML XML attribute
Exceptions:
InternalProgrammerErrorException is thrown only if the error is so grave that the entire AIML engine has to be shut down.

Reimplemented in AIML, Bot, Condition, Get, Input, Li, Set, Star, TemplateSideThat, ThatStar, Topic, and TopicStar.


Member Data Documentation

shared_ptr<TagImpl> m_pimpl [private]
 

The private implementation in which you cannot get access to.

This shared_ptr holds the private methods and private member variables of this class. This makes ABI (Application Binary Interface) more resilient to change. See the private implementation idiom on the internet for more information about this.

Reimplemented in AIML, Bot, Category, Condition, Date, Formal, Gender, Get, Gossip, Id, InnerAIML, InnerCategory, InnerTemplate, InnerTemplateListImpl, InnerTopic, Input, Learn, Li, LowerCase, NonImplemented, Pattern, PatternSideThat, Person, Person2, PlainWord, Random, Sentence, Set, Size, Srai, Star, System, Template, TemplateSideThat, ThatStar, Think, Topic, TopicStar, UpperCase, and Version.


The documentation for this class was generated from the following file:
Generated on Thu Sep 7 22:05:46 2006 for RebeccaAIML by  doxygen 1.4.5