00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CH_Group_h__
00021 #define __CH_Group_h__
00022
00023 #include "CH_API.h"
00024 #include <iostream.h>
00025 #include <UT/UT_String.h>
00026 #include <UT/UT_PtrArray.h>
00027 #include "CH_Collection.h"
00028 #include "CH_ChannelRefHashTable.h"
00029
00030 class UT_StringArray;
00031 class CH_GroupEntry;
00032 class CH_Channel;
00033 class CH_ChannelRef;
00034 class CH_Collection;
00035 class CH_Manager;
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 class CH_API CH_Group
00071 {
00072 friend class CH_Manager;
00073 friend class CH_UndoGroupAddRemoveChannel;
00074
00075 public:
00076 static char getGroupChar() { return '@'; }
00077 static int cmp( const CH_Group *a, const CH_Group *b );
00078
00079 private:
00080
00081 CH_Group();
00082 ~CH_Group();
00083
00084
00085 void setName(const char *name);
00086 CH_Group *clone();
00087
00088 public:
00089
00090 const UT_String &getName() const { return myName; }
00091 void getFullPath(UT_String &str) const;
00092 bool isInTree() const { return myIsInTree; }
00093 bool isRoot() const { return myIsInTree && myParent==NULL; }
00094 bool isEmpty() const;
00095 int getTotalEntries() const;
00096
00097 void clear();
00098 void displayInfo( int indent=0 );
00099
00100
00101 void makeLast();
00102 void changeIndex( int new_index );
00103 void sortGroups( bool recursive );
00104
00105
00106 CH_Group *getParentGroup() { return myParent; }
00107 int getSubGroupEntries() { return myGroups.entries(); }
00108 const UT_PtrArray<CH_Group*> &getSubGroups() { return myGroups; }
00109 bool isEventualParentOf( CH_Group *other );
00110 int findIndex( CH_Group *subgroup );
00111
00112
00113 int getEntries() const { return myChannels.entries(); }
00114 bool strictContains( const CH_Channel *chp) const;
00115 bool strictContains( const CH_ChannelRef &chref) const;
00116 bool contains(const CH_Channel *chp) const;
00117 bool contains(const CH_ChannelRef &chref) const;
00118 int strictGetChannels(CH_ChannelList &channels) const;
00119 int strictGetChanRefs(CH_ChannelRefList &chanrefs) const;
00120 int getChannels(CH_ChannelList &channels) const;
00121 int getChanRefs(CH_ChannelRefList &chanrefs) const;
00122 int getFullChannelPaths(UT_StringArray &channel_paths,
00123 bool use_alias=false) const;
00124
00125
00126
00127 int addChannel(const CH_Channel *chp);
00128 int addChannel( const CH_ChannelRef &chref );
00129
00130 int removeChannel( const CH_Channel *chp);
00131 int removeChannel( const CH_ChannelRef &chref );
00132
00133 int addChannels(const CH_ChannelList &channels);
00134 int addChannels(const CH_ChannelRefList &chanrefs);
00135
00136 int removeChannels(const CH_ChannelList &channels);
00137 int removeChannels(const CH_ChannelRefList &chanrefs);
00138 void changeReferencesToNodeId(int old_id, int new_id);
00139 void removeChannelsWithNodeId(int node_id);
00140
00141
00142
00143
00144
00145
00146 unsigned getScopeFlags( unsigned flags );
00147 void dirtyScopeFlags( unsigned flags );
00148 void dirtySubtreeScopeFlags( unsigned flags );
00149 void setScopeStatus( unsigned flags, bool on_off );
00150
00151
00152 bool updateScopeFlags( unsigned flags );
00153 void dirtyAllScopeFlags();
00154
00155 private:
00156
00157 void getChanRefsInternal(UT_HashTable &chan_hash) const;
00158 int addChannelInternal(const CH_ChannelRef &chref);
00159 int removeChannelInternal(const CH_ChannelRef &chref);
00160 void removeMeFromMyParent();
00161 CH_Group *createGroupInternal(const char *name);
00162 bool removeGroupInternal(CH_Group *sub_group);
00163 void removeChanRefFromParents(const CH_ChannelRef &chref);
00164
00165
00166 void channelDeleted( const CH_Channel *chp );
00167 void channelCreated( const CH_Channel *chp );
00168
00169
00170 void findValidGroupName( UT_String &name );
00171 CH_Group *findGroup(const char *name, bool create);
00172 void findGroups( UT_PtrArray< CH_Group* > &groups,
00173 const char *pattern, bool minimal );
00174 void insertGroup( CH_Group *source,
00175 const char *new_name=0 );
00176 bool getGroupsFromChannels(
00177 const CH_ChannelRefHashTable& channels,
00178 CH_GroupList& groups);
00179 void propagateInTreeFlag();
00180
00181 public:
00182
00183 void save(ostream &os, int binary) const;
00184 bool load(UT_IStream &is);
00185
00186 private:
00187 UT_String myName;
00188 CH_Group *myParent;
00189 unsigned myScopeFlags: CH_NUM_FLAGS;
00190 unsigned myDirtyScopeFlags: CH_NUM_FLAGS;
00191 unsigned myIsInTree: 1;
00192
00193 CH_ChannelRefHashTable myChannels;
00194
00195 UT_PtrArray<CH_Group *> myGroups;
00196 };
00197
00198 #endif