21  static const char WILDCARD = 
'%';                                     
 
   23  static const char* 
const INCLUDE_DIRECTIVE    =   
"#include";         
 
   24  static const char* 
const NAMESPACE_DIRECTIVE  =   
"namespace";        
 
   25  static const char* 
const INCLUDE_EXTENSION    =   
".hh";              
 
   26  static const char* 
const SOFTWARE_DIRECTORY   =   
"software";         
 
   36    public std::map<std::string, std::set<std::string> >
 
   38    static const char JPP_PREFIX           =  
'J';    
 
   39    static const char DIRECTORY_SEPARATOR  =  
'/';    
 
   54      bool is_valid(
const key_type& key)
 const 
   56        for (const_iterator p = this->begin(); p != this->end(); ++p) {
 
   62          for (const_iterator q = this->begin(); q != p; ++q) {
 
   79    JDirectory(
const std::string& dir = 
"")
 
   84      const string JPP_DIR = (dir != 
"" ? dir : getenv(
"JPP_DIR"));
 
   85      const string TOP     = JPP_DIR + DIRECTORY_SEPARATOR + SOFTWARE_DIRECTORY;
 
   87      for (
const auto& top : 
ls(TOP)) {
 
   89        if (top[0] == JPP_PREFIX && rm.count(top) == 0) {
 
   91          const string SUB = TOP + DIRECTORY_SEPARATOR + top;
 
   93          for (
const auto& file : 
ls(SUB)) {
 
   95            if (file.find(INCLUDE_EXTENSION) != string::npos) {
 
   97              const string file_name = SUB + DIRECTORY_SEPARATOR + file;
 
   99              ifstream in(file_name.c_str());
 
  101              for (
string buffer; 
getline(in, buffer) && buffer.find(NAMESPACE_DIRECTIVE) == string::npos; ) {
 
  103                if (buffer.find(INCLUDE_DIRECTIVE) != string::npos) {
 
  105                  istringstream is(buffer);
 
  107                  string key, include_file;
 
  109                  is >> 
key >> include_file;
 
  113                    const size_t pos = include_file.find(DIRECTORY_SEPARATOR);
 
  115                    if (pos != string::npos) {
 
  117                      const string dir = include_file.substr(1, pos - 1);
 
  120                        (*this)[top].insert(dir);
 
  141    JDirectory(
const JDirectory& input, 
const key_type& key)
 
  143      this->
copy(input, key);
 
  153    const mapped_type& get(
const key_type& key)
 const 
  155      static const mapped_type buffer;
 
  157      const_iterator p = this->find(key);
 
  159      if (p != this->end())
 
  172    path_type 
getPath(
const key_type& key)
 const 
  176      evaluate(key, get(key));
 
  188    bool is_valid(
const key_type& key)
 const 
  192      return evaluate(key, get(key));
 
  201    inline void print(std::ostream& out)
 const 
  205      for (const_iterator i = this->begin(); i != this->end(); ++i) {
 
  207        out << i->first << 
" -> {";
 
  209        for (
const auto& dir : i->second) {
 
  210          out << 
" " << dir << 
",";
 
  224    inline void print(std::ostream& out, 
const JDirectory::key_type& key)
 const 
  226      JDirectory(*
this, key).print(out);
 
  236    void copy(
const JDirectory& input, 
const key_type& key)
 
  238      (*this)[
key] = input.get(key);
 
  240      for (
const auto& dir : input.get(key)) {
 
  241        if (this->find(dir) == this->end()) {
 
  255    bool evaluate(
const key_type& key, 
const mapped_type& 
target)
 const 
  257      if (!path.is_valid(key)) {     
 
  261      for (mapped_type::const_iterator i = 
target.begin(); i != 
target.end(); ++i) {
 
  265        if (!evaluate(key, this->get(*i))) {
 
  275    mutable path_type path;          
 
  297    JParser<> zap(
"Example program to test dependencies of include files");
 
  306  catch(
const exception &error) {
 
  307    FATAL(error.what() << endl);
 
  311  const JDirectory directory(jpp);
 
  318    if (pos != string::npos) {
 
  319      outputFile.replace(pos, 1, (dir != 
"" ? dir.c_str() : 
"Jpp"));
 
  324    out << 
"\\documentclass[border=5mm]{standalone}"   << endl;
 
  326    out << 
"\\usepackage{tikz}"                        << endl;
 
  327    out << 
"\\usetikzlibrary{graphs, graphdrawing}"    << endl;
 
  328    out << 
"\\usegdlibrary{layered}"                   << endl;
 
  329    out << 
"\\begin{document}"                         << endl;
 
  331    out << 
"\\tikz \\graph [layered layout]"           << endl;
 
  335      directory.print(out);
 
  337      directory.print(out, dir);
 
  341    out << 
"\\end{document}"                           << endl;
 
  347  for (JDirectory::const_iterator i = directory.begin(); i != directory.end(); ++i) {
 
  349    DEBUG(i->first << 
": " << flush);
 
  351    if (!directory.is_valid(i->first)) {
 
  353      const JDirectory::path_type path = directory.getPath(i->first);
 
  355      for (JDirectory::path_type::const_iterator dir = path.begin(); dir != path.end(); ++dir) {
 
  363  for (JDirectory::const_iterator i = directory.begin(); i != directory.end(); ++i) {
 
  364    ASSERT(directory.is_valid(i->first), 
"check validity " << i->first);
 
 
int main(int argc, char **argv)
 
General purpose messaging.
 
#define DEBUG(A)
Message macros.
 
#define ASSERT(A,...)
Assert macro.
 
Utility class to parse command line options.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
void print(const TH1 &h1, std::ostream &out)
Print histogram parameters.
 
Utility class to parse command line options.
 
void copy(const Head &from, JHead &to)
Copy header from from to to.
 
std::string getPath(const std::string &file_name)
Get path, i.e. part before last JEEP::PATHNAME_SEPARATOR if any.
 
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
 
bool is_double_quoted(const std::string &value)
Check quotation.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
bool is_valid(const json &js)
Check validity of JSon data.
 
Auxiliary data structure to list files in directory.