Aegis  4.25.D505
/home/archives/aegis/branch.4/branch.25/delta28933.505/libaegis/project.h
Go to the documentation of this file.
00001 //
00002 // aegis - project change supervisor
00003 // Copyright (C) 1992-1999, 2001-2008, 2011, 2012 Peter Miller
00004 // Copyright (C) 2007, 2008 Walter Franzini
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 3 of the License, or (at
00009 // 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 GNU
00014 // 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, see <http://www.gnu.org/licenses/>.
00018 //
00019 
00020 #ifndef PROJECT_H
00021 #define PROJECT_H
00022 
00023 #include <common/ac/time.h>
00024 
00025 #include <libaegis/pattr.fmtgen.h>
00026 #include <libaegis/pstate.fmtgen.h>
00027 #include <libaegis/view_path.h>
00028 #include <libaegis/change.h>
00029 
00030 class string_list_ty; // forward
00031 class sub_context_ty; // forward
00032 class fstate_src_ty; // forward
00033 class itab_ty; // forward
00034 
00047 class project
00048 {
00049 public:
00056     typedef project *pointer;
00057 
00068     ~project();
00069 
00076     project(string_ty *name);
00077 
00078     // NOTE: methods are sorted alphabetically.  To have methods
00079     // grouped, make sure they change their suffix rather than their
00080     // prefix.  E.g. thingumy_get and thingumy_set rather than
00081     // get_thingumy and set_thingumy.
00082     //
00083     // Note: public or protected or private, it doesn't matter, keep
00084     // them sorted.
00085 
00086     // ----------  A  ------------------------------------------------------
00087 
00105     nstring attribute_get(const nstring &name);
00106 
00125     bool attribute_get_boolean(const nstring &name);
00126 
00127     // ----------  B  ------------------------------------------------------
00128 
00136     string_ty *baseline_path_get(bool resolve = false);
00137 
00145     project *bind_branch(change::pointer bp);
00146 
00155     void bind_existing();
00156 
00164     bool bind_existing_errok();
00165 
00173     void bind_keep(const nstring &path);
00174 
00180     void bind_new();
00181 
00182     // ----------  C  ------------------------------------------------------
00183 
00197     time_t change_completion_timestamp(long change_number);
00198 
00207     change::pointer change_get(void);
00208 
00218     change::pointer change_get_raw() { return pcp; }
00219 
00229     string_ty *change_path_get(long change_number);
00230 
00231     void
00232     change_reset()
00233     {
00234         change::pointer tmp = pcp;
00235         pcp = 0;
00236         change_free(tmp);
00237     }
00238 
00246     string_ty *changes_path_get();
00247 
00248 public: // during transition, then private
00253     void convert_to_new_format();
00254 
00255 public:
00265     void copy_the_owner(project *pp);
00266 
00280     void copyright_years_slurp(int *a, int amax, int *alen_p);
00281 
00282     // ----------  D  ------------------------------------------------------
00283     // ----------  E  ------------------------------------------------------
00284     // ----------  F  ------------------------------------------------------
00285 
00302     bool file_directory_query(const nstring &filename, nstring_list &result_in,
00303         nstring_list &result_out, view_path_ty as_view_path);
00304 
00321     void file_directory_query(string_ty *filename,
00322         struct string_list_ty *result_in, struct string_list_ty *result_out,
00323         view_path_ty as_view_path);
00324 
00333     bool file_exists(const nstring &filename);
00334 
00347     fstate_src_ty *file_find(const nstring &filename,
00348         view_path_ty as_view_path);
00349 
00362     fstate_src_ty *file_find(string_ty *filename, view_path_ty as_view_path);
00363 
00378     fstate_src_ty *file_find(fstate_src_ty *c_src, view_path_ty as_view_path);
00379 
00394     fstate_src_ty *file_find(cstate_src_ty *c_src, view_path_ty as_view_path);
00395 
00409     fstate_src_ty *file_find_by_uuid(string_ty *uuid, view_path_ty vp);
00410 
00425     fstate_src_ty *file_find_fuzzy(string_ty *filename,
00426         view_path_ty as_view_path);
00427 
00428 private:
00439     struct string_list_ty *file_list_get(view_path_ty as_view_path);
00440 
00441 public:
00446     void file_list_invalidate();
00447 
00456     fstate_src_ty *file_new(string_ty *file_name);
00457 
00468     fstate_src_ty *file_new(fstate_src_ty *meta);
00469 
00481     fstate_src_ty *file_nth(size_t n, view_path_ty as_view_path);
00482 
00492     project *find_branch(const char *number);
00493 
00494     // ----------  G  ------------------------------------------------------
00495 
00496 private:
00501     void get_the_owner();
00502 
00503 public:
00508     user_ty::pointer get_user() const;
00509 
00514     int gid_get();
00515 
00516     // ----------  H  ------------------------------------------------------
00517 
00527     string_ty *history_path_get();
00528 
00544     string_ty *home_path_get();
00545 
00559     void home_path_set(string_ty *dir);
00560     void home_path_set(const nstring &dir);
00561 
00562     // ----------  I  ------------------------------------------------------
00563 
00574     string_ty *info_path_get();
00575 
00584     bool is_a_trunk() const { return (parent == 0); }
00585 
00586     // ----------  J  ------------------------------------------------------
00587     // ----------  K  ------------------------------------------------------
00588     // ----------  L  ------------------------------------------------------
00589 
00598     void list_inner(string_list_ty &result);
00599 
00605     void lock_prepare_everything();
00606 
00607 private:
00616     void lock_sync();
00617 
00618     // ----------  M  ------------------------------------------------------
00619     // ----------  N  ------------------------------------------------------
00620 
00621 public:
00629     string_ty *name_get() const;
00630 
00631     // ----------  O  ------------------------------------------------------
00632     // ----------  P  ------------------------------------------------------
00633 
00641     long parent_branch_number_get() const { return parent_bn; }
00642 
00650     project *parent_get() { return (parent ? parent : this); }
00651 
00661     pstate_ty *pstate_get();
00662 
00668     void pstate_lock_prepare();
00669 
00680     string_ty *pstate_path_get();
00681 
00692     void search_path_get(string_list_ty *result, bool resolve);
00693 
00704     void search_path_get(nstring_list &result, bool resolve);
00705 
00710     void pstate_write();
00711 
00712     // ----------  Q  ------------------------------------------------------
00713     // ----------  R  ------------------------------------------------------
00714     // ----------  S  ------------------------------------------------------
00715     // ----------  T  ------------------------------------------------------
00716 
00721     project *trunk_get();
00722 
00723     // ----------  U ------------------------------------------------------
00724     // ----------  V  ------------------------------------------------------
00725     // ----------  W  ------------------------------------------------------
00726     // ----------  X  ------------------------------------------------------
00727     // ----------  Y  ------------------------------------------------------
00728     // ----------  Z  ------------------------------------------------------
00729     // ---------------------------------------------------------------------
00730 
00735     int uid_get();
00736 
00741     int umask_get();
00742 
00743 public: // during transition
00744     long            reference_count;
00745 
00746 private:
00751     string_ty *name;
00752 
00763     string_ty *home_path;
00764 
00772     string_ty *baseline_path_unresolved;
00773 
00781     string_ty *baseline_path;
00782 
00789     itab_ty *change2time_stp;
00790 
00797     string_ty *history_path;
00798 
00805     string_ty *info_path;
00806 
00813     string_ty *pstate_path;
00814 
00821     string_ty *changes_path;
00822 
00829     pstate_ty *pstate_data;
00830 
00835     bool is_a_new_file;
00836 
00844     long lock_magic;
00845 
00855     change::pointer pcp;
00856 
00861     int uid;
00862 
00867     int gid;
00868 
00874     project *parent;
00875 
00881     long parent_bn;
00882 
00889     struct string_list_ty *file_list[view_path_MAX];
00890 
00900     struct symtab_ty *file_by_uuid[view_path_MAX];
00901 
00902     //
00903     // If you add an instance variable to this class, make sure you
00904     // dispose of it in the destructor and initialize in in the
00905     // constructor.  Both may be found in libaegis/project.cc
00906     //
00907 
00908 private:
00913     user_ty::pointer up;
00914 
00921     bool off_limits;
00922 
00930     project();
00931 
00938     project(const project &);
00939 
00946     project &operator=(const project &);
00947 };
00948 
00949 project *project_alloc(string_ty *name);
00950 
00951 inline DEPRECATED void
00952 project_bind_existing(project *pp)
00953 {
00954     pp->bind_existing();
00955 }
00956 
00957 inline DEPRECATED bool
00958 project_bind_existing_errok(project *pp)
00959 {
00960     return pp->bind_existing_errok();
00961 }
00962 
00963 inline DEPRECATED project *
00964 project_bind_branch(project *ppp, change::pointer bp)
00965 {
00966     return ppp->bind_branch(bp);
00967 }
00968 
00969 inline DEPRECATED void
00970 project_bind_new(project *pp)
00971 {
00972     pp->bind_new();
00973 }
00974 
00975 void project_list_get(struct string_list_ty *);
00976 
00977 inline DEPRECATED void
00978 project_list_inner(struct string_list_ty *result, project *pp)
00979 {
00980     pp->list_inner(*result);
00981 }
00982 
00983 inline DEPRECATED project *
00984 project_find_branch(project *pp, const char *number)
00985 {
00986     return pp->find_branch(number);
00987 }
00988 
00989 void project_free(project *);
00990 
00991 inline nstring
00992 project_name_get(project *pp)
00993 {
00994     return nstring(pp->name_get());
00995 }
00996 
00997 project *project_copy(project *);
00998 
00999 inline DEPRECATED change::pointer
01000 project_change_get(project *pp)
01001 {
01002     return pp->change_get();
01003 }
01004 
01005 inline DEPRECATED string_ty *
01006 project_home_path_get(project *pp)
01007 {
01008     return pp->home_path_get();
01009 }
01010 
01011 string_ty *project_Home_path_get(project *);
01012 string_ty *project_top_path_get(project *, int);
01013 
01025 nstring project_rss_path_get(project *pp, bool resolve = false);
01026 
01027 inline DEPRECATED void
01028 project_home_path_set(project *pp, string_ty *dir)
01029 {
01030     pp->home_path_set(dir);
01031 }
01032 
01033 inline DEPRECATED string_ty *
01034 project_baseline_path_get(project *pp, bool resolve = false)
01035 {
01036     return pp->baseline_path_get(resolve);
01037 }
01038 
01039 inline DEPRECATED string_ty *
01040 project_history_path_get(project *pp)
01041 {
01042     return pp->history_path_get();
01043 }
01044 
01053 string_ty *project_history_filename_get(project *, struct fstate_src_ty *);
01054 
01055 inline DEPRECATED string_ty *
01056 project_info_path_get(project *pp)
01057 {
01058     return pp->info_path_get();
01059 }
01060 
01061 inline DEPRECATED string_ty *
01062 project_changes_path_get(project *pp)
01063 {
01064     return pp->changes_path_get();
01065 }
01066 
01067 DEPRECATED
01068 string_ty *project_change_path_get(project *, long);
01069 
01070 inline DEPRECATED string_ty *
01071 project_pstate_path_get(project *pp)
01072 {
01073     return pp->pstate_path_get();
01074 }
01075 
01076 inline DEPRECATED pstate_ty *
01077 project_pstate_get(project *pp)
01078 {
01079     return pp->pstate_get();
01080 }
01081 
01082 inline DEPRECATED void
01083 project_pstate_write(project *pp)
01084 {
01085     pp->pstate_write();
01086 }
01087 
01088 void project_pstate_write_top(project *);
01089 
01090 inline DEPRECATED void
01091 project_pstate_lock_prepare(project *pp)
01092 {
01093     pp->pstate_lock_prepare();
01094 }
01095 
01096 void project_pstate_lock_prepare_top(project *);
01097 void project_baseline_read_lock_prepare(project *);
01098 void project_baseline_write_lock_prepare(project *);
01099 void project_history_lock_prepare(project *);
01100 void project_error(project *, struct sub_context_ty *, const char *);
01101 void project_fatal(project *, struct sub_context_ty *, const char *)
01102     NORETURN;
01103 void project_verbose(project *, struct sub_context_ty *, const char *);
01104 void project_change_append(project *, long, int);
01105 void project_change_delete(project *, long);
01106 int project_change_number_in_use(project *, long);
01107 nstring project_version_short_get(project *);
01108 nstring project_version_get(project *);
01109 
01110 inline DEPRECATED int
01111 project_uid_get(project *pp)
01112 {
01113     return pp->uid_get();
01114 }
01115 
01116 inline DEPRECATED int
01117 project_gid_get(project *pp)
01118 {
01119     return pp->gid_get();
01120 }
01121 
01122 user_ty::pointer project_user(project *);
01123 void project_become(project *);
01124 void project_become_undo(project *pp);
01125 long project_next_test_number_get(project *);
01126 int project_is_readable(project *);
01127 long project_minimum_change_number_get(project *);
01128 void project_minimum_change_number_set(project *, long);
01129 bool project_reuse_change_numbers_get(project *);
01130 void project_reuse_change_numbers_set(project *, bool);
01131 long project_minimum_branch_number_get(project *);
01132 void project_minimum_branch_number_set(project *, long);
01133 bool project_skip_unlucky_get(project *);
01134 void project_skip_unlucky_set(project *, bool);
01135 bool project_compress_database_get(project *);
01136 void project_compress_database_set(project *, bool);
01137 int project_develop_end_action_get(project *);
01138 void project_develop_end_action_set(project *, int);
01139 bool project_protect_development_directory_get(project *);
01140 void project_protect_development_directory_set(project *, bool);
01141 
01142 int break_up_version_string(const char *, long *, int, int *, int);
01143 void extract_version_from_project_name(string_ty **, long *, int, int *);
01144 int project_name_ok(string_ty *);
01145 
01146 pconf_ty *project_pconf_get(project *);
01147 
01169 project *project_new_branch(project *pp, user_ty::pointer up,
01170     long change_number, string_ty *topdir = 0, string_ty *reason = 0);
01171 
01172 inline DEPRECATED void
01173 project_file_list_invalidate(project *pp)
01174 {
01175     pp->file_list_invalidate();
01176 }
01177 
01178 string_ty *project_brief_description_get(project *);
01179 
01192 change::pointer project_uuid_find(project *pp, string_ty *uuid);
01193 
01194 // vim: set ts=8 sw=4 et :
01195 #endif // PROJECT_H