FAUST compiler  0.9.9.6b8
occurrences.hh
Go to the documentation of this file.
00001 /************************************************************************
00002  ************************************************************************
00003     FAUST compiler
00004     Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale
00005     ---------------------------------------------------------------------
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  ************************************************************************
00020  ************************************************************************/
00021 
00022 #ifndef __OCCURENCES__
00023 #define __OCCURENCES__
00024 
00025 #include "tlib.hh"
00026 
00032 class Occurrences
00033 {
00034     Tree    fKey;                   // specific property key
00035 
00036  public:
00037     Occurrences(Tree root);         // count the occurrences of each subtree of root
00038     int getCount(Tree t);           // return the number of occurrences of t in root
00039 
00040  private:
00041     Tree specificKey(Tree root);    // specific key for occurences counting in root
00042     void countOccurrences(Tree t);  // increment the occurrences of t and its subtrees
00043     void setCount(Tree t, int c);   // set the number of occurrences of t
00044 };
00045 
00046 #endif