CPN
Computational Process Networks
PseudoNode.h
Go to the documentation of this file.
1 //=============================================================================
2 // Computational Process Networks class library
3 // Copyright (C) 1997-2006 Gregory E. Allen and The University of Texas
4 //
5 // This library is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Library General Public License as published
7 // by the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Library General Public License for more details.
14 //
15 // The GNU Public License is available in the file LICENSE, or you
16 // can write to the Free Software Foundation, Inc., 59 Temple Place -
17 // Suite 330, Boston, MA 02111-1307, USA, or you can find it on the
18 // World Wide Web at http://www.fsf.org.
19 //=============================================================================
20 #pragma once
21 
22 #include <cpn/common.h>
23 #include <cpn/bits/QueueReleaser.h>
24 #include <cpn/utils/Logger.h>
26 #include <map>
27 
28 namespace D4R {
29  class Node;
30 }
31 
32 namespace CPN {
33 
34  class CPN_API PseudoNode : private QueueReleaser {
35  public:
36  PseudoNode(const std::string &name_, Key_t k, shared_ptr<Context> ctx);
37  virtual ~PseudoNode();
38 
40  const std::string &GetName() const { return name; }
41 
43  Key_t GetKey() const { return nodekey; }
44 
52  shared_ptr<QueueReader> GetIQueue(const std::string &portname);
53 
61  shared_ptr<QueueWriter> GetOQueue(const std::string &portname);
62 
64  void CreateReader(shared_ptr<QueueBase> q);
66  void CreateWriter(shared_ptr<QueueBase> q);
68  void NotifyTerminate();
70  virtual void Shutdown();
71  virtual bool IsPurePseudo();
72 
74  virtual void LogState();
75  protected:
77  private:
78  PseudoNode(const PseudoNode &);
79  void ReleaseReader(Key_t ekey);
80  void ReleaseWriter(Key_t ekey);
81  shared_ptr<QueueReader> GetReader(Key_t ekey);
82  shared_ptr<QueueWriter> GetWriter(Key_t ekey);
83 
84 
87  const std::string name;
88  const Key_t nodekey;
89  shared_ptr<D4R::Node> d4rnode;
90 
91  typedef std::map<Key_t, shared_ptr<QueueReader> > ReaderMap;
92  typedef std::map<Key_t, shared_ptr<QueueWriter> > WriterMap;
95 
96  shared_ptr<Context> context;
97  };
98 }
99 
Logger object that is used for forwarding log messages.
Definition: Logger.h:57
const std::string name
Definition: PseudoNode.h:87
shared_ptr< D4R::Node > d4rnode
Definition: PseudoNode.h:89
const Key_t nodekey
Definition: PseudoNode.h:88
WriterMap writermap
Definition: PseudoNode.h:94
Sync::ReentrantLock lock
Definition: PseudoNode.h:85
uint64_t Key_t
Definition: common.h:79
std::map< Key_t, shared_ptr< QueueWriter > > WriterMap
Definition: PseudoNode.h:92
ReaderMap readermap
Definition: PseudoNode.h:93
Key_t GetKey() const
Definition: PseudoNode.h:43
Sync::ReentrantCondition cond
Definition: PseudoNode.h:86
const std::string & GetName() const
Definition: PseudoNode.h:40
shared_ptr< Context > context
Definition: PseudoNode.h:96
A very simple logging interface.
Works just like a pthread condition but works with the ReentrantLock.
#define CPN_API
Definition: common.h:36
std::map< Key_t, shared_ptr< QueueReader > > ReaderMap
Definition: PseudoNode.h:91
A reentrant lock implementation.