Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

ToolDirectoryServer.H

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // ToolDirectoryServer.H
00020 // Last modified on Mon May 23 23:26:15 EDT 2005 by ken@xorian.net         
00021 //      modified on Wed Apr 27 09:25:03 EDT 2005 by irina.furman@intel.com 
00022 //      modified on Fri Jun  1 11:50:26 PDT 2001 by yuanyu 
00023 //      modified on Thu Feb 10 22:34:27 PST 2000 by mann   
00024 //      modified on Fri Mar  1 12:39:21 PST 1996 by levin  
00025 //      modified on Tue Jan 23 16:30:27 PST 1996 by horning
00026 
00027 // The following defines the interface for creating an SRPC server 
00028 // to implement "evaluator directories", which provide a file naming
00029 // environment during execution of an encapsulated tool.
00030 
00031 // The server is created at the first opportunity and remains in 
00032 // existence for the duration of the evaluator with which it shares
00033 // an address space.
00034 
00035 #ifndef ToolDirectoryServer_H
00036 #define ToolDirectoryServer_H
00037 
00038 #include "EvalBasics.H"
00039 #include "Val.H"
00040 #include "WordKey.H"
00041 
00042 // Initialize
00043 void create_tool_directory_server();
00044 
00045 // Data structures shared between RunTool and the server.
00046 // It records the dependency while "spying" on a RunTool call.
00047 class DirInfo {
00048 public:
00049   Binding b;
00050   DepPath path;
00051   bool isRoot;
00052   bool coarseDep;
00053   bool child_lookup;
00054 };
00055 
00056 // DirInfoTbl
00057 typedef Table<WordKey, DirInfo*>::Default DirInfoTbl;
00058 typedef Table<WordKey, DirInfo*>::Iterator DirInfoIter;
00059 
00060 class DirInfos {
00061 public:
00062   Basics::mutex mu; // Used to protect dirInfoTbl and dep
00063   DirInfoTbl *dirInfoTbl;
00064   DPaths *dep;
00065   void AddDpnd(DirInfo *dir, const Text& name, Val v, const PathKind pk);
00066   Word LookupDir(DirInfo *dir, const Text& name, Val v, Word dirHandle);
00067 };
00068 
00069 // DirInfosTbl
00070 typedef Table<WordKey, DirInfos*>::Default DirInfosTbl;
00071 
00072 class RunToolCalls {
00073 public:
00074   RunToolCalls(int numCalls) {
00075     dirInfosTbl = NEW_CONSTR(DirInfosTbl, (numCalls));
00076   }
00077   bool Get(const WordKey& k, /*OUT*/ DirInfos*& v) {
00078     this->mu.lock();
00079     bool res = this->dirInfosTbl->Get(k, v);
00080     this->mu.unlock();
00081     return res;
00082   }
00083   bool Put(const WordKey& k, DirInfos*& v, bool resize = true) {
00084     this->mu.lock();
00085     bool res = this->dirInfosTbl->Put(k, v, resize);
00086     this->mu.unlock();
00087     return res;
00088   }
00089   bool Delete(const WordKey& k, /*OUT*/ DirInfos*& v, bool resize = true) {
00090     this->mu.lock();
00091     bool res = this->dirInfosTbl->Delete(k, v, resize);
00092     this->mu.unlock();
00093     return res;
00094   }
00095 private:
00096   DirInfosTbl *dirInfosTbl;
00097   Basics::mutex mu;
00098 };
00099 
00100 // Used to record volatile directories for all pending runtool calls.
00101 extern RunToolCalls runToolCalls;
00102 
00103 // Get a new handle for a new volatile directory.
00104 Word GetNewHandle();
00105 
00106 #endif // ToolDirectoryServer_H

Generated on Mon May 8 00:48:40 2006 for Vesta by  doxygen 1.4.2