C:/Projets/hexamonkey/core/interpreter/scope/scope.h
Go to the documentation of this file.
00001 //This file is part of the HexaMonkey project, a multimedia analyser
00002 //Copyright (C) 2013  Sevan Drapeau-Martin, Nicolas Fleury
00003 
00004 //This program is free software; you can redistribute it and/or
00005 //modify it under the terms of the GNU General Public License
00006 //as published by the Free Software Foundation; either version 2
00007 //of the License, or (at your option) any later version.
00008 
00009 //This program is distributed in the hope that it will be useful,
00010 //but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //GNU General Public License for more details.
00013 
00014 //You should have received a copy of the GNU General Public License
00015 //along with this program; if not, write to the Free Software
00016 //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017 
00018 #ifndef SCOPE_H
00019 #define SCOPE_H
00020 
00021 #include "core/variable/variable.h"
00022 #include "core/variable/variablepath.h"
00023 #include "core/interpreter/scope/scopeptr.h"
00024 
00025 class Variant;
00026 
00038 class Scope
00039 {
00040 public:
00041     typedef ScopePtr Ptr;
00042 
00043     virtual ~Scope() {}
00049     Variable get(const Variant& key, bool modifiable = false);
00050 
00057     Variable get(const VariablePath& path, bool modifiable = false);
00058 
00064     Variable declare(const Variant& key, const Variant &initialValue = Variant());
00065 
00071     bool assignSubscope(const Variant& key, const Ptr& subscope);
00072     bool assignSubscope(const Variant &key, Scope* subscope);
00073     bool assignSubscope(const VariablePath& path, const Ptr& subscope);
00074 
00078     void remove(const Variant& key);
00079     void remove(const VariablePath& path);
00080 
00086     Ptr getScope(const Variant& key);
00087 
00088     Ptr getScope(const VariablePath& path);
00089 
00093     virtual Variable getValue(bool modifiable);
00094 
00095 protected:
00099     virtual Variable doGet(const Variant& key, bool modifiable);
00103     virtual Variable doDeclare(const Variant& key, const Variant& initialValue);
00107     virtual Ptr doGetScope(const Variant& key);
00108 
00112     virtual bool doAssignSubscope(const Variant& key, const Ptr& subscope);
00113 
00117     virtual void doRemove(const Variant &key);
00118 
00119 private :
00120     const Scope::Ptr _getScope(const VariablePath& path, int max);
00121 };
00122 
00123 #endif // SCOPE_H