]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - include/imap.h
radiant/tools: use RADIANT_NAME instead of hardcoding NetRadiant or Radiant
[xonotic/netradiant.git] / include / imap.h
index 230d5dd19789edda5b4507b17ba52c3e7e21cb86..4661a794768fb349f2bf3247aee9567dfbedfec9 100644 (file)
@@ -1,82 +1,83 @@
-/*\r
-Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
-For a list of contributors, see the accompanying CONTRIBUTORS file.\r
-\r
-This file is part of GtkRadiant.\r
-\r
-GtkRadiant is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-GtkRadiant is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with GtkRadiant; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
-*/\r
-\r
-//----------------------------------------------------------------------------\r
-//\r
-// DESCRIPTION:\r
-// map format interface (.map and .xmap, Q3 and other games)\r
-//\r
-\r
-#ifndef __IMAP_H__\r
-#define __IMAP_H__\r
-\r
-/*! IMap depends on IDataStream, including the header there for now */\r
-#include "idatastream.h"\r
-\r
-/*! header for CPtrArray */\r
-#include "missing.h"\r
-\r
-#define MAP_MAJOR "map"\r
-/*!\r
-define a GUID for this interface so everyone can acces and reference it\r
-{75076973-3414-49c9-be5b-2378ec5601af}\r
-*/\r
-static const GUID QERPlugMapTable_GUID =\r
-{ 0x75076973, 0x3414, 0x49c9, { 0xbe, 0x5b, 0x23, 0x78, 0xec, 0x56, 0x01, 0xaf } };\r
-\r
-/*!\r
-read from a stream into a list of entities\r
-\param in the input stream. For regular map file parsing it's possible to copy the content in a text buffer\r
-and use the old school parser\r
-\param ents the list of entities read from the stream. They are not linked to the world, and their brushes\r
-are not either.\r
-*/\r
-typedef void (* PFN_MAP_READ) (IDataStream *in, CPtrArray *ents); ///< read from a stream into a list of entities\r
-typedef void (* PFN_MAP_WRITE) (CPtrArray *ents, IDataStream *out); ///< save a list of entities into a stream\r
-\r
-struct _QERPlugMapTable\r
-{\r
-  int m_nSize;\r
-  PFN_MAP_READ m_pfnMap_Read;\r
-  PFN_MAP_WRITE m_pfnMap_Write;\r
-};\r
-\r
-/*!\r
-this set of macros will define the functions to map on a given table\r
-  it should be used in the headers (see modules source, plugin.h)\r
-we don't want those defines in the part where WE implement the Map_LoadFile\r
-  so we're using a define to disable .. should find a standard define name\r
-  (for instance QCOM_CLIENT / QCOM_SERVER ?)\r
-  or the name should be specific to any interface .. it's not a client/server thing here anyway\r
-*/\r
-#ifdef USE_MAPTABLE_DEFINE\r
-#ifndef __MAPTABLENAME\r
-/*! \r
-TTimo NOTE: this is the default table name we map to\r
-  if you are using a different table name, just define __MAPTABLENAME before you include the imap.h header\r
-*/\r
-#define __MAPTABLENAME g_MapTable\r
-#endif\r
-#define Map_Read __MAPTABLENAME.m_pfnMap_Read\r
-#define Map_Write __MAPTABLENAME.m_pfnMap_Write\r
-#endif\r
-\r
-#endif\r
+/*
+   Copyright (C) 2001-2006, William Joseph.
+   All Rights Reserved.
+
+   This file is part of GtkRadiant.
+
+   GtkRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   GtkRadiant is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GtkRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#if !defined( INCLUDED_IMAP_H )
+#define INCLUDED_IMAP_H
+
+#include "generic/constant.h"
+
+class Tokeniser;
+class TokenWriter;
+
+/// \brief A node whose state can be imported from a token stream.
+class MapImporter
+{
+public:
+STRING_CONSTANT( Name, "MapImporter" );
+
+virtual bool importTokens( Tokeniser& tokeniser ) = 0;
+};
+
+/// \brief A node whose state can be exported to a token stream.
+class MapExporter
+{
+public:
+STRING_CONSTANT( Name, "MapExporter" );
+
+virtual void exportTokens( TokenWriter& writer ) const = 0;
+};
+
+#include "iscenegraph.h"
+
+class EntityCreator;
+
+class TextInputStream;
+class TextOutputStream;
+
+
+typedef void ( *GraphTraversalFunc )( scene::Node& root, const scene::Traversable::Walker& walker );
+
+/// \brief A module that reads and writes a map in a specific format.
+class MapFormat
+{
+public:
+virtual ~MapFormat() = default;
+INTEGER_CONSTANT( Version, 2 );
+STRING_CONSTANT( Name, "map" );
+mutable bool wrongFormat;
+
+/// \brief Read a map graph into \p root from \p outputStream, using \p entityTable to create entities.
+virtual void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable ) const = 0;
+/// \brief Write the map graph obtained by applying \p traverse to \p root into \p outputStream.
+virtual void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream, bool writeComments ) const = 0;
+};
+
+
+template<typename Type>
+class Modules;
+typedef Modules<MapFormat> MapModules;
+
+template<typename Type>
+class ModulesRef;
+typedef ModulesRef<MapFormat> MapModulesRef;
+
+
+#endif