umbrello API Documentation

uniqueid.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2006                                                    *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 // own header
00013 #include "uniqueid.h"
00014 
00015 // system includes
00016 #include <kapplication.h>
00017 
00018 namespace UniqueID {
00019 
00023 Uml::IDType m_uniqueID;
00024 
00025 Uml::IDType gen() {
00026     static char buf[20];
00027     int length = 12;
00028     int i = 0;
00029     // Source: KDE4 kdelibs/kdecore/krandom.cpp KRandom::randomString()
00030     while (length--) {
00031         int r = kapp->random() % 62;
00032         r += 48;
00033         if (r > 57)
00034             r += 7;
00035         if (r > 90)
00036             r += 6;
00037         buf[i++] = char(r);
00038     }
00039     buf[i] = '\0';
00040     m_uniqueID = std::string(buf);
00041     return m_uniqueID;
00042 }
00043 
00044 void init() {
00045     m_uniqueID = Uml::id_Reserved;
00046 }
00047 
00048 Uml::IDType get() {
00049     return m_uniqueID;
00050 }
00051 
00052 void set(Uml::IDType id) {
00053     m_uniqueID = id;
00054 }
00055 
00056 }  // end namespace UniqueID
00057 
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:08:02 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003