AndroMeta  2.0.0
AndroMeta/include/AndroMeta/MDLOntology.h
00001 /*
00002  * Copyright 2009-2012 AndroMeta LLC. All rights reserved.
00003  *
00004  * AndroMeta LLC retains all intellectual property and proprietary 
00005  * rights to this software and related documentation and any modifications 
00006  * thereto.  Any use, reproduction, disclosure, or distribution of this 
00007  * software and related documentation without an express license agreement 
00008  * from AndroMeta LLC is strictly prohibited.
00009  * 
00010  */
00011 
00023 #ifndef ANDROMETA_MDL_ONTOLOGY_H
00024 #define ANDROMETA_MDL_ONTOLOGY_H
00025 
00026 #include <AndroMeta/MEmitter.h>
00027 #include <AndroMeta/MVar.h>
00028 #include <AndroMeta/MTime.h>
00029 
00030 #include <ostream>
00031 
00032 namespace Meta{
00033 
00043   class MDLOntology{
00044   public:
00045   
00049     MDLOntology(const mstr& ontologyPath);
00050     
00055     MDLOntology(const mstr& ontologyPath, const mstr& flatOntologyPath);
00056     
00060     ~MDLOntology();
00061         
00065     void findDomains(const mstr& user,
00066                      const mvec& extends,
00067                      const mvec& notExtends,
00068                      mvec& out,
00069                      const mstr& creator="",
00070                      const mvar& startDomainMap=undef);
00071     
00075     void setErrorStream(std::ostream& estr);
00076     
00080     bool hasDomain(const mstr& domain);
00081     
00085     mvec normalizeExtends(const mvec& extends);
00086     
00090     mvec normalizeNotExtends(const mvec& extends);
00091     
00096     mvec domainsExtended(const mstr& domain);
00097     
00102     mvec fullDomainsExtended(const mstr& domain);
00103     
00107     mvec attributes(const mstr& domain);
00108     
00112     void createIndex(mvar& index, bool tags);
00113     
00117     void setAttribute(const mstr& creator,
00118                       const mstr& domain,
00119                       const mstr& time,
00120                       const mstr& attribute,
00121                       const mstr& value);
00122     
00126     void createDomain(const mstr& creator, const mstr& domain);
00127     
00131     const mstr& creator(const mstr& domain);
00132     
00136     mvec setDomainsExtended(const mstr& domain, const mvec& domains);
00137     
00141     void addAttribute(const mstr& creator,
00142                       const mstr& domain,
00143                       const mstr& attribute,
00144                       const mstr& attributeDomain);
00145 
00149     void deleteAttribute(const mstr& domain, const mstr& attribute);
00150     
00154     void save(bool backup);
00155     
00160     mreal epsilon();
00161     
00165     void setEpsilon(const mreal& epsilon);
00166     
00170     void deleteDomain(const mstr& domain);
00171     
00175     void setDomainDescription(const mstr& creator,
00176                               const mstr& domain,
00177                               const mstr& description);
00178     
00182     mstr domainDescription(const mstr& domain);
00183     
00187     void setAttributeDescription(const mstr& creator,
00188                                  const mstr& domain,
00189                                  const mstr& attribute,
00190                                  const mstr& description);
00191     
00195     mstr attributeDescription(const mstr& domain, const mstr& attribute);
00196     
00200     void removeEvents(const mstr& domain, const mstr& attribute);
00201 
00206     void removeEvent(const mstr& domain,
00207                      const mstr& time,
00208                      const mstr& attribute);
00209     
00213     mvec events(const mstr& domain);
00214     
00219     mvec events(const mstr& domain, const mstr& attribute);
00220     
00224     void clearEvents(const mstr& domain);
00225     
00229     void addEvent(const mstr& creator,
00230                   const mstr& domain,
00231                   const mstr& time,
00232                   const mstr& attribute,
00233                   const mstr& value);
00234     
00238     bool lock(const mstr& domain, const mstr& user);
00239     
00243     void unlock(const mstr& domain, const mstr& user);
00244     
00248     bool isLocked(const mstr& domain, const mstr& user);
00249     
00250     enum TimeType{
00251       TimeAt=0,
00252       TimeNext=1,
00253       TimePrevious=2
00254     };
00255     
00259     mstr runModel(const mstr& domain,
00260                   TimeType timeType,
00261                   const mstr& time,
00262                   mvar& out,
00263                   const mtime& timeout,
00264                   bool full,
00265                   bool description,
00266                   bool concise);
00267     
00271     void query(const mvec& domains, const mvar& time, mnode code, mvec& out); 
00272     
00276     void setPublicRead(const mstr& domain, bool flag);
00277     
00281     void setPublicWrite(const mstr& domain, bool flag);
00282     
00286     bool isPublicRead(const mstr& domain);
00287     
00291     bool isPublicWrite(const mstr& domain);
00292     
00297     void walkLinks(const mstr& user,
00298                    const mstr& domain,
00299                    const mstr& time,
00300                    size_t maxLinks,
00301                    mvar& out);
00302     
00306     void flatten(const mstr& outputPath, bool tags);
00307     
00311     static void createOntology(const mstr& path);
00312 
00316     static void patchOntology120(const mstr& path, const mstr& newPath);
00317     
00321     static void patchOntology200(const mstr& path);
00322     
00326     void mergeOntology(const mstr& mergePath);
00327     
00331     int addMethod(const mstr& creator, const mstr& domain, const mstr& method="");
00332     
00336     void renameMethod(const mstr& creator,
00337                       const mstr& domain,
00338                       int methodId,
00339                       const mstr& newMethod);
00340     
00344     void setMethodCode(const mstr& creator,
00345                        const mstr& domain,
00346                        int methodId,
00347                        const mstr& code);
00348     
00352     mstr addMethodParameter(const mstr& creator,
00353                             const mstr& domain,
00354                             int methodId,
00355                             const mstr& parameter="");
00356     
00360     void renameMethodParameter(const mstr& creator,
00361                                const mstr& domain,
00362                                int methodId,
00363                                const mstr& parameter,
00364                                const mstr& newParameter);
00365     
00369     void setMethodParameterType(const mstr& creator,
00370                                 const mstr& domain,
00371                                 int methodId,
00372                                 const mstr& parameter,
00373                                 const mstr& type);
00374     
00378     void setMethodParameterDomain(const mstr& creator,
00379                                   const mstr& domain,
00380                                   int methodId,
00381                                   const mstr& parameter,
00382                                   const mstr& parameterDomain);
00383     
00387     void setMethodParameterDefaultValue(const mstr& creator,
00388                                         const mstr& domain,
00389                                         int methodId,
00390                                         const mstr& parameter,
00391                                         const mstr& value);
00392     
00396     void deleteMethod(const mstr& domain, int methodId);
00397     
00401     void deleteMethodParameter(const mstr& creator,
00402                                const mstr& domain,
00403                                int methodId,
00404                                const mstr& parameter);
00405     
00409     void reorderMethodParameters(const mstr& creator,
00410                                  const mstr& domain,
00411                                  int methodId,
00412                                  const mvec& parameters);
00413     
00417     void methods(const mstr& domain, bool extended, mvec& out);
00418     
00422     void codeAssistMethods(const mstr& domain,
00423                            int methodId,
00424                            const mstr& code,
00425                            int cursor,
00426                            mvec& out);
00427     
00431     static MDLOntology* get(const mstr& path);
00432     
00437     static void release(MDLOntology* ontology);
00438     
00442     static void releaseAll();
00443     
00444   private:
00445     class MDLOntology_* x_;
00446   };
00447   
00448 } // end namespace Meta
00449 
00450 #endif // ANDROMETA_MDL_ONTOLOGY_H