Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
asset-diagnostics.hpp
Go to the documentation of this file.
1 /*
2  ASSET-DIAGNOSTICS.hpp - collection of test and debug helpers
3 
4  Copyright (C) Lumiera.org
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
32 #ifndef ASSET_ASSET_DIAGNOSTICS_H
33 #define ASSET_ASSET_DIAGNOSTICS_H
34 
35 
36 #include "proc/assetmanager.hpp"
37 #include "lib/format-string.hpp"
38 #include "lib/format-cout.hpp"
39 #include "lib/util-foreach.hpp"
40 #include "lib/util.hpp"
41 
42 #include <functional>
43 
44 using util::contains;
45 using util::for_each;
46 using util::_Fmt;
47 using std::placeholders::_1;
48 using std::bind;
49 using std::string;
50 using std::cout;
51 
52 
53 namespace proc {
54 namespace asset {
55 
56  inline void
57  dump (PcAsset& aa)
58  {
59  if (!aa)
60  cout << "Asset(NULL)\n";
61  else
62  {
63  _Fmt fmt("%s %|50T.| id=%s adr=%p smart-ptr=%p use-count=%u");
64  cout << fmt % aa % aa->getID() % aa.get() % &aa % (aa.use_count() - 1) << "\n";
65  } }
66 
67 
68  inline void
70  {
71  list<PcAsset> assets (AssetManager::instance().listContent());
72  cout << "----all-registered-Assets----\n";
73  for_each (assets, bind (&dump, _1));
74  }
75 
76 
77  template<class CHI, class PAR>
78  inline bool
80  {
81  return (child == parent)
82  || (0 < child->getParents().size()
83  && (parent == child->getParents()[0])
84  && (contains (parent->getDependant(), child)))
85  ;
86  }
87 
88 
89 
90 
91 }} // namespace proc::asset
92 #endif
Proc-Layer Interface: Asset Lookup and Organisation.
Automatically use custom string conversion in C++ stream output.
void dump(PcAsset &aa)
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
Definition: trait.hpp:76
The asset subsystem of the Proc-Layer.
Definition: id-scheme.hpp:64
Front-end for printf-style string template interpolation.
A front-end for using printf-style formatting.
static lib::Depend< AssetManager > instance
get at the system-wide asset manager instance.
bool contains(MAP &map, typename MAP::key_type const &key)
shortcut for containment test on a map
Definition: util.hpp:205
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Proc-Layer implementation namespace root.
Definition: id-scheme.hpp:63
TAR * get() const
Definition: p.hpp:96
disable_if< can_IterForEach< Container >, FUN > for_each(Container const &coll, FUN doIt)
operate on all elements of a STL container.
bool dependencyCheck(lib::P< CHI > child, lib::P< PAR > parent)
Perform operations "for each element" of a collection.