Model.h

00001 /**************************************************************************\
00002  * 
00003  *  FILE: Model.h
00004  *
00005  *  This source file is part of DIME.
00006  *  Copyright (C) 1998-1999 by Systems In Motion.  All rights reserved.
00007  *
00008  *  This library is free software; you can redistribute it and/or modify it
00009  *  under the terms of the GNU General Public License, version 2, as
00010  *  published by the Free Software Foundation.
00011  *
00012  *  This library is distributed in the hope that it will be useful, but
00013  *  WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *  General Public License (the accompanying file named COPYING) for more
00016  *  details.
00017  *
00018  **************************************************************************
00019  *
00020  *  If you need DIME for a non-GPL project, contact Systems In Motion
00021  *  to acquire a Professional Edition License:
00022  *
00023  *  Systems In Motion                                   http://www.sim.no/
00024  *  Prof. Brochs gate 6                                       sales@sim.no
00025  *  N-7030 Trondheim                                   Voice: +47 22114160
00026  *  NORWAY                                               Fax: +47 67172912
00027  *
00028 \**************************************************************************/
00029 
00030 #ifndef DIME_MODEL_H
00031 #define DIME_MODEL_H
00032 
00033 #include <dime/Basic.h>
00034 #include <dime/util/Array.h>
00035 #include <dime/util/Linear.h>
00036 #include <dime/Base.h>
00037 #include <dime/Layer.h>
00038 #include <stdlib.h>
00039 
00040 class dimeInput;
00041 class dimeOutput;
00042 class dimeDict;
00043 class dimeMemHandler;
00044 class dimeSection;
00045 class dimeEntitiesSection;
00046 class dimeBlocksSection;
00047 class dimeBlock;
00048 class dimeEntity;
00049 class dimeRecord;
00050 
00051 class DIME_DLL_API dimeModel
00052 {
00053 public:
00054   dimeModel(const bool usememhandler = false);
00055   ~dimeModel();
00056   
00057   dimeModel *copy() const;
00058 
00059   bool init();
00060   bool read(dimeInput * const in);
00061   bool write(dimeOutput * const out);
00062 
00063   int countRecords() const;
00064 
00065   bool traverseEntities(dimeCallback callback, 
00066                         void *userdata = NULL,
00067                         bool traverseBlocksSection = false,
00068                         bool explodeInserts = true,
00069                         bool traversePolylineVertices = false);
00070   
00071   const char *addReference(const char * const name, void *id);
00072   void *findReference(const char * const name) const;
00073   const char *findRefStringPtr(const char * const name) const;
00074   void removeReference(const char * const name);
00075   class dimeMemHandler *getMemHandler();
00076   
00077   int getNumLayers() const;
00078   const class dimeLayer *getLayer(const int idx) const;
00079   const class dimeLayer *getLayer(const char * const layername) const;
00080   const class dimeLayer *addLayer(const char * const layername, 
00081                                   const int16 colnum = 7,
00082                                   const int16 flags = 0); 
00083   
00084   const char * getDxfVersion() const;
00085   
00086   static const char *getVersionString();
00087   static void getVersion(int &major, int &minor);
00088   const char *addBlock(const char * const blockname, dimeBlock * const block);
00089   class dimeBlock *findBlock(const char * const blockname);
00090 
00091   class dimeSection *findSection(const char * const sectionname);
00092   const class dimeSection *findSection(const char * const sectionname) const;
00093 
00094   int getNumSections() const;
00095   class dimeSection *getSection(const int idx);
00096   void insertSection(dimeSection * const section, const int idx = -1);
00097   void removeSection(const int idx);
00098 
00099   void registerHandle(const int handle);
00100   void registerHandle(const char * const handle);
00101   int getUniqueHandle();
00102   const char *getUniqueHandle(char *buf, const int bufsize);
00103   void addEntity(dimeEntity *entity);
00104 
00105 private:
00106   class dimeDict *refDict;
00107   class dimeDict *layerDict;
00108   class dimeMemHandler *memoryHandler;
00109   dimeArray <class dimeSection*> sections;
00110   dimeArray <class dimeLayer*> layers;
00111   dimeArray <dimeRecord*> headerComments;
00112 
00113   int largestHandle;
00114   bool usememhandler;
00115 }; // class dimeModel
00116 
00117 #endif // ! DIME_MODEL_H
00118 

Copyright © 1998-1999, Systems In Motion <sales@sim.no>. All rights reserved.
System documentation was generated using doxygen.