torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DDBStreamHelper.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Source for the DDBStreamHelper class.
18 
21 
22 namespace torc {
23 namespace architecture {
24 
26 
27  std::ostream& operator <<(std::ostream& os, const DDB& ddb) {
28  // check to see whether there is an existing database association for this stream
29  typedef std::map<std::ostream*, const class DDB*> OStreamToDDBMap;
30  OStreamToDDBMap::const_iterator p = DDBStreamHelper::sStreamToDatabase.find(&os);
31  if(p == DDBStreamHelper::sStreamToDatabase.end()) {
32  // if no association exists, create a new association between the stream and database
33  std::pair<OStreamToDDBMap::iterator, bool> inserted
34  = DDBStreamHelper::sStreamToDatabase.insert(std::make_pair(&os, &ddb));
35  p = inserted.first; // implicitly assuming that insertion always succeeds
36  }
37  return os;
38  }
39 
40 } // namespace architecture
41 } // namespace torc
42 
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
static OStreamToDDBMap sStreamToDatabase
Map of streams to databases.
Header for the DDBStreamHelper class.
std::ostream & operator<<(std::ostream &os, const DDB &ddb)
std::map< std::ostream *, const class DDB * > OStreamToDDBMap
Map of streams to database pointers.
Header for the DDB class.