Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

SubjectManagerImpl.h

Go to the documentation of this file.
00001 /***************** <Tweek heading BEGIN do not edit this line> ****************
00002  * Tweek
00003  *
00004  * -----------------------------------------------------------------
00005  * File:          $RCSfile: SubjectManagerImpl.h,v $
00006  * Date modified: $Date: 2003/08/03 00:08:28 $
00007  * Version:       $Revision: 1.19 $
00008  * -----------------------------------------------------------------
00009  ***************** <Tweek heading END do not edit this line> *****************/
00010 
00011 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00012  *
00013  * VR Juggler is (C) Copyright 1998-2003 by Iowa State University
00014  *
00015  * Original Authors:
00016  *   Allen Bierbaum, Christopher Just,
00017  *   Patrick Hartling, Kevin Meinert,
00018  *   Carolina Cruz-Neira, Albert Baker
00019  *
00020  * This library is free software; you can redistribute it and/or
00021  * modify it under the terms of the GNU Library General Public
00022  * License as published by the Free Software Foundation; either
00023  * version 2 of the License, or (at your option) any later version.
00024  *
00025  * This library is distributed in the hope that it will be useful,
00026  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00027  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00028  * Library General Public License for more details.
00029  *
00030  * You should have received a copy of the GNU Library General Public
00031  * License along with this library; if not, write to the
00032  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00033  * Boston, MA 02111-1307, USA.
00034  *
00035  *************** <auto-copyright.pl END do not edit this line> ***************/
00036 
00037 #ifndef _TWEEK_SUBJECT_MANAGER_IMPL_H_
00038 #define _TWEEK_SUBJECT_MANAGER_IMPL_H_
00039 
00040 #include <tweek/tweekConfig.h>
00041 
00042 #include <string>
00043 #include <map>
00044 #include <vpr/vpr.h>
00045 #include <vpr/Sync/Mutex.h>
00046 #include <vpr/Sync/Guard.h>
00047 #include <vpr/Util/GUID.h>
00048 
00049 #include <tweek/CORBA/Subject.h>
00050 #include <tweek/CORBA/SubjectManager.h>
00051 
00052 
00053 namespace tweek
00054 {
00055 
00056 class CorbaManager;
00057 class SubjectImpl;
00058 
00067 class TWEEK_CLASS_API SubjectManagerImpl
00068    : public POA_tweek::SubjectManager,
00069      public PortableServer::RefCountServantBase
00070 {
00071 public:
00072    virtual ~SubjectManagerImpl();
00073 
00091    void registerSubject(SubjectImpl* subject, const char* name);
00092 
00104    vpr::ReturnStatus unregisterSubject(const char* name);
00105 
00110    virtual Subject_ptr getSubject(const char* name);
00111 
00116    virtual tweek::SubjectManager::SubjectList* getAllSubjects();
00117 
00122    virtual tweek::SubjectManager::SubjectManagerInfoList* getInfo();
00123 
00132    virtual char* getName();
00133 
00134    void setName(const std::string& name)
00135    {
00136       mName = name;
00137    }
00138 
00148    void setApplicationName(const std::string& appName)
00149    {
00150       addInfoItem(std::string(APPNAME_KEY), appName);
00151    }
00152 
00162    void setUserName(const std::string& userName)
00163    {
00164       addInfoItem(USERNAME_KEY, userName);
00165    }
00166 
00171    void addInfoItem(const std::string& key, const std::string& value)
00172    {
00173       vpr::Guard<vpr::Mutex> lock(mInfoMapMutex);
00174       mInfoMap[key] = value;
00175    }
00176 
00177    const vpr::GUID& getGUID() const
00178    {
00179       return mGUID;
00180    }
00181 
00182 protected:
00183    // Only this class can instantiate me.
00184    friend class tweek::CorbaManager;
00185 
00190    SubjectManagerImpl(const CorbaManager& corba_mgr)
00191       : mCorbaMgr(corba_mgr), mGUID(), mName("")
00192    {
00193       mGUID.generate();
00194       initInfoMap();
00195    }
00196 
00197    // These two have to be here because Visual C++ will try to make them
00198    // exported public symbols.  This causes problems because copying
00199    // vpr::Mutex objects is not allowed.
00200    SubjectManagerImpl(const SubjectManagerImpl& sm);
00201 
00202    void operator=(const SubjectManagerImpl& sm)
00203    {
00204       /* Do nothing. */ ;
00205    }
00206 
00207    void registerSubject(Subject_ptr subject, const std::string& name);
00208 
00213    void initInfoMap();
00214 
00215 private:
00216    const CorbaManager& mCorbaMgr;
00217    vpr::GUID           mGUID;
00218    std::string         mName;
00219 
00220    typedef std::map<std::string, Subject_ptr> subject_map_t;
00221    subject_map_t mSubjects;
00222    vpr::Mutex    mSubjectsMutex;
00223 
00224    typedef std::map<std::string, PortableServer::ObjectId_var> subject_id_map_t;
00225    subject_id_map_t mSubjectIds;
00226    vpr::Mutex       mSubjectIdsMutex;
00227 
00228    std::map<std::string, std::string> mInfoMap;
00229    vpr::Mutex                         mInfoMapMutex;
00230 
00231    static const std::string USERNAME_KEY;
00232    static const std::string APPNAME_KEY;
00233 };
00234 
00235 } // End of tweek namespace
00236 
00237 #endif /* _TWEEK_SUBJECT_MANAGER_IMPL_H_ */

Generated on Sun May 2 14:41:03 2004 for Tweek by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002