LGP Class List
From NexusCrossing
Contents |
[edit] lgp::Class Reference
[edit] lgp::Object
lgp::Object is the parent class for all object classes. It defines the most basic of Object behaviors, as well as the public interface.
Object::Object()
- The default constructor. Not very useful really.
Object::Object(ObjectID id, ObjectData type, ObjectData access, ObjectData voice)
- A basic constructor to assign the needed information for identifying objects.
virtual Object::~Object()
- The destructor.
virtual ObjectID Object::get_id(void)
- Returns the Object ID of the object.
virtual ObjectData Object::get_type(void)
- Returns the Object Type of the object.
virtual Object::accept_message(std::string message)
- Allows the object to accept messages.
virtual Object::cycle(void)=0
- This is the function to make the object do whatever it does every cycle. It is nulled in order to force the developer who is using the class to define the member function himself since there is no way to determine default behavior for an object. Even if I could define simplistic behavior, it is better for the developer who is using the class to do so.
[edit] lgp::Array
A templated array class that incorporates many of the good points of both arrays and linked lists. The rational for creating this class is simple. A linked list excels when it comes to speed and ease of adding an element. Arrays excel in terms of accessing elements. A linked list never needs to be resized, because it has no predefined memory space. Each element is defined as you go and then linked to the previous element. A normal array on the other hand has a preset memory space allocated to it, with no easy way to change it. In order to resize an array, you have to make a new array, copy every element of the old array into the new array, item by item, an then delete the old array. This takes time, and is inefficient, and more importantly takes MORE time every time you have to do it. As a result, people tend to make arrays massively over-sized from the start, and then overcompensate every time they resize the array.
The lgp::Array handles this issue by implementing an Array of Arrays. When the array is initialized, it creates an array of pointers that point to arrays. Much of the memory management handled by the individual is the same as you would expect with a standard array, except that when it comes time to resize the array, instead of doing it all by hand you would make a call to the expand() member function.
The expand member function only has to resize the root array, and as such only needs to recopy the pointers to the sub-arrays, and not every element of the array (so, you would have to recopy less than 1% of the array).
There are still some possible tweaks to be made to the class, but the interface itself should not change much.
[edit] lgp::Message
lgp::Message is the class that will be used to hold and process messages that are transmitted between Objects within the system. When a message is sent from one object to another, it can be sent as an object. When a message is sent out over the wire (i.e. from one process/machine to another) it is converted (packed) to a string at one end, and then unpacked into a Message object at the recieving end.
[edit] The Interface
Message::Message(ObjectData type, ObjectData senderType, std::string sender, ObjectData targetType, std::string target, std::string payload)
- This is the main constructor that will be used to create a message object.
void set_message(ObjectData type, ObjectData senderType, std::string sender, ObjectData targetType, std::string target, std::string payload)
- This method takes the same arguments as the constuctor, and can be used to set the values of a message before sending it. This allows for situations where it is convenient to programatically create messages as they are being sent.
std::string pack_message(void)
- This method returns the contents of the message object as a std::string suitable for sending over the wire.
void unpack_message(std::string message)
- This method accepts a message that has been formatted as a std::string, and turns it back into a message object.
ObjectData get_type(void)
- Returns the Message Type of the Message.
void set_type(ObjectData type)
- sets the Message Type of the message.
ObjectData get_target_type(void); ObjectData get_sender_type(void)
- Returns the Object Type of the message's target/sender.
void set_target_type(ObjectData type); void set_sender_type(ObjectType type)
- Sets the value of the type of target/sender.
std::string get_sender(void); std::string get_target(void)
- return the sender/target's Identification
std::string get_payload(void)
- Return the value of the Message's payload.
void set_payload(std::string payload)
- Set the payload value of the Message.
[edit] +
[edit]
[edit] LGP Project Components (TOC)
- LGP Top Page
- The Project Road Map
- Project News
- LGP Classes and Components
- LibGamePieces Objects <== Stand By for Heavy Rolls
- The Virtual Dicebag
- Project Dependencies (Outside Code you need to get it to compile)
- The Game System <== May be in Flux
- World Design
