00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * George ElKoura 00008 * Side Effects 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: Lightweight group definition for GB_Edge types (C++) 00015 * 00016 * COMMENTS: 00017 * 00018 */ 00019 00020 #ifndef __GB_EdgeGroup_h__ 00021 #define __GB_EdgeGroup_h__ 00022 00023 #include "GB_API.h" 00024 #include <UT/UT_HashTable.h> 00025 #include <UT/UT_LinkList.h> 00026 #include <UT/UT_Notifier.h> 00027 00028 #include "GB_Detail.h" 00029 #include "GB_Edge.h" 00030 #include "GB_BaseGroup.h" 00031 00032 class GB_API GB_EdgeGroup : public GB_BaseGroup 00033 { 00034 public: 00035 GB_EdgeGroup(const GB_Detail &gdp, const char *name, int hidden = 1, 00036 unsigned short type = GBEDGEGROUP); 00037 ~GB_EdgeGroup(); 00038 00039 GB_Edge *find(const GB_Edge *it) const; 00040 GB_Edge *find(const GB_Edge &it) const 00041 { return find(&it); } 00042 int contains(const GB_Edge *it) const; 00043 00044 int contains(const GB_Edge &it) const 00045 { return contains(&it); } 00046 00047 00048 // Adds return 1 if successful and 0 otherwise 00049 int add(GB_Edge *it); 00050 00051 int add(GB_Edge &it) 00052 {return add(&it);} 00053 00054 int add(GB_Element *p0, GB_Element *p1, GB_Element *prim = 0); 00055 00056 // The append options on the toggle methods is used to specify whether 00057 // or not the edge that is passed in should be used or should a private 00058 // copy be used instead. An append value of 1 will not create a new edge. 00059 int toggle(GB_Edge *it); 00060 00061 int toggle(GB_Edge &it) 00062 {return toggle(&it);} 00063 00064 int toggle(unsigned int num) 00065 {return toggle((GB_Edge *)myEdgeList.find((int)num));} 00066 00067 int remove(GB_Edge *it); 00068 00069 int remove(GB_Edge &it) 00070 {return remove(&it);} 00071 00072 int remove(unsigned int num) 00073 {return remove( (GB_Edge *)myEdgeList.find((int)num) );} 00074 00075 UT_LinkList &list() { return myEdgeList; } 00076 const UT_LinkList &list() const { return myEdgeList; } 00077 00078 void elementRemoved(GB_Element *); 00079 00080 // TODO: resolve: entries() is returning unsigned but length() returns 00081 // int. Base class uses unsigned. Should UT_LinkList::length 00082 // really return signed? 00083 // Yep. UT_LinkList should be changed, or we should abandon this whole 00084 // signed/unsigned distinction. For now, I'm just putting in casts 00085 // everywhere :< 00086 virtual unsigned entries() const {return (unsigned)myEdgeList.length();} 00087 virtual int isEmpty() const { return myEdgeList.isEmpty(); } 00088 virtual void clearEntries(void); 00089 00090 virtual int save(ostream &os, int binary) const; 00091 virtual bool load(UT_IStream &is); 00092 00093 private: 00094 00095 UT_LinkList myEdgeList; // list of edges in the group 00096 UT_HashTable myEdgeTable; 00097 00098 const GB_Detail &myGdp; 00099 UT_NotifierList myNotifierList; 00100 }; 00101 #endif
1.5.9