Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
handle_types.h
Package: leda.tar.gz [view]
Upload User: gzelex
Upload Date: 2007-01-07
Package Size: 707k
Code Size: 3k
Category:
Mathimatics-Numerical algorithms
Development Platform:
MultiPlatform
- /*******************************************************************************
- +
- + LEDA-R 3.2.3
- +
- + handle_types.h
- +
- + Copyright (c) 1995 by Max-Planck-Institut fuer Informatik
- + Im Stadtwald, 66123 Saarbruecken, Germany
- + All rights reserved.
- +
- *******************************************************************************/
- #ifndef LEDA_HANDLE_H
- #define LEDA_HANDLE_H
- //------------------------------------------------------------------------------
- // handle_base/rep: base classes for handle types string, point, segment,...
- //------------------------------------------------------------------------------
- class handle_rep {
- friend class handle_base;
- protected:
- int count;
- handle_rep() { count = 1; }
- virtual ~handle_rep() {}
- public:
- LEDA_MEMORY(handle_rep)
- };
- class handle_base {
- protected:
- handle_rep* PTR;
- public:
- handle_base() {}
- handle_base(const handle_base& x) { PTR = x.PTR; PTR->count++; }
- ~handle_base() { if (PTR && --PTR->count == 0) delete PTR;}
- handle_base& operator=(const handle_base& x)
- { x.PTR->count++;
- if (PTR && --PTR->count == 0) delete PTR; // left side may be 0
- PTR = x.PTR;
- return *this;
- }
- int refs() const { return PTR->count; }
- friend unsigned long ID_Number(const handle_base& x)
- { return (unsigned long)x.PTR; }
- friend bool identical(const handle_base& x, const handle_base& y)
- { return x.PTR == y.PTR; }
- #if !defined(__EXPLICIT_DESTRUCTION__)
- void clear() { if (PTR && --PTR->count == 0) delete PTR; }
- friend void explicit_destruction(handle_base* p) { p->clear(); }
- #endif
- #if !defined(__TEMPLATE_FUNCTIONS__)
- // without function templates we define Copy,Convert,Clear, ..
- // functions valid for all handle types derived from handle_base
- GenPtr copy() const { PTR->count++; return PTR; }
- GenPtr conv() const { return PTR; }
- void clear() { if (PTR && --PTR->count == 0) delete PTR; }
- friend inline GenPtr Copy(const handle_base&);
- friend inline GenPtr Convert(const handle_base&);
- friend inline void Clear(handle_base&);
- friend inline int compare(const handle_base&, const handle_base&);
- friend inline int Hash(const handle_base&);
- friend inline void Print(const handle_base&, ostream&);
- friend inline void Read(handle_base&, istream&);
- #endif
- };
- #if !defined(__TEMPLATE_FUNCTIONS__)
- inline GenPtr Copy(const handle_base& x) { return x.copy(); }
- inline GenPtr Convert(const handle_base& x) { return x.conv(); }
- inline void Clear(handle_base& x) { x.clear(); }
- inline int compare(const handle_base& x, const handle_base& y)
- { return compare(x.PTR, y.PTR); }
- inline int Hash(const handle_base& x) { return *(int*)x.PTR; }
- inline void Print(const handle_base& x, ostream& os) { Print(x,os); }
- inline void Read(handle_base& x, istream& is) { Read(x,is); }
- #endif
- #define LEDA_HANDLE_TYPE(T) /* historical, not used anymore */
- #endif