00001 /* Copyright 2010 Jukka Jylänki 00002 00003 Licensed under the Apache License, Version 2.0 (the "License"); 00004 you may not use this file except in compliance with the License. 00005 You may obtain a copy of the License at 00006 00007 http://www.apache.org/licenses/LICENSE-2.0 00008 00009 Unless required by applicable law or agreed to in writing, software 00010 distributed under the License is distributed on an "AS IS" BASIS, 00011 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 See the License for the specific language governing permissions and 00013 limitations under the License. */ 00014 #pragma once 00015 00019 #include <vector> 00020 00021 #include "BasicSerializedDataTypes.h" 00022 00023 // TinyXML fwd 00024 class TiXmlElement; 00025 00026 namespace kNet 00027 { 00028 00034 struct SerializedElementDesc 00035 { 00037 BasicSerializedDataType type; 00038 00040 bool varyingCount; 00041 00044 int count; 00045 00047 std::string name; 00048 00050 std::vector<SerializedElementDesc*> elements; 00051 00053 SerializedElementDesc *parent; 00054 }; 00055 00057 struct SerializedMessageDesc 00058 { 00061 SerializedElementDesc *data; 00062 std::string name; 00063 u32 id; 00064 bool reliable; 00065 bool inOrder; 00066 u32 priority; 00067 }; 00068 00070 class SerializedMessageList 00071 { 00072 public: 00074 void LoadMessagesFromFile(const char *filename); 00075 00077 const SerializedMessageDesc *FindMessageByID(u32 id); 00079 const SerializedMessageDesc *FindMessageByName(const char *name); 00080 00082 const std::list<SerializedMessageDesc> &GetMessages() const { return messages; } 00083 00085 const std::list<SerializedElementDesc> &GetElements() const { return elements; } 00086 00087 private: 00088 std::list<SerializedElementDesc> elements; 00089 std::list<SerializedMessageDesc> messages; 00090 00091 SerializedElementDesc *ParseNode(TiXmlElement *node, SerializedElementDesc *parentNode); 00092 00093 void ParseMessages(TiXmlElement *root); 00094 void ParseStructs(TiXmlElement *root); 00095 }; 00096 00097 } // ~kNet
1.7.1